diff --git a/cmd/chat_print.go b/cmd/chat_print.go index aef907a6..e26c4337 100644 --- a/cmd/chat_print.go +++ b/cmd/chat_print.go @@ -189,9 +189,9 @@ func writePrintUsageEvent(sessionID string, usage *engine.StreamUsage) { // printTextUsageFooter renders a muted token/elapsed summary to stderr after a // one-shot text-mode run. It writes to stderr so stdout stays pure for scripts, -// and is skipped entirely when no usage event was received. +// and is skipped entirely when no usage event was received or --quiet is set. func printTextUsageFooter(usage *engine.StreamUsage, started time.Time) { - if usage == nil { + if usage == nil || IsQuiet() { return } parts := []string{fmt.Sprintf("%d in ยท %d out", usage.PromptTokens, usage.CompletionTokens)} diff --git a/cmd/chat_print_usage_test.go b/cmd/chat_print_usage_test.go index 28220278..da19d3ed 100644 --- a/cmd/chat_print_usage_test.go +++ b/cmd/chat_print_usage_test.go @@ -85,4 +85,19 @@ func TestPrintTextUsageFooter(t *testing.T) { t.Errorf("expected no output for nil usage, got: %q", got) } }) + + t.Run("skips output when quiet is set", func(t *testing.T) { + old := quietFlag + quietFlag = true + defer func() { quietFlag = old }() + got := captureStderr(t, func() { + printTextUsageFooter(&engine.StreamUsage{ + PromptTokens: 100, + CompletionTokens: 50, + }, started) + }) + if got != "" { + t.Errorf("expected no output under --quiet, got: %q", got) + } + }) }