diff --git a/tests/progress-output-mode.test.mjs b/tests/progress-output-mode.test.mjs new file mode 100644 index 0000000000..2cdb787499 --- /dev/null +++ b/tests/progress-output-mode.test.mjs @@ -0,0 +1,13 @@ +import test from 'node:test'; +import assert from 'node:assert/strict'; +import { OutputFormatter } from '../v3/@claude-flow/cli-core/src/output.ts'; +function capture(run) { const original = process.stdout.write; let output = ''; process.stdout.write = function(text) { output += text; return true; }; try { run(); return output; } finally { process.stdout.write = original; } } +test('progress redraws stay out of redirected output', () => { + const f = new OutputFormatter({ color: false }); f.supportsInteractiveOutput = () => false; const p = f.createProgress({ total: 2, showETA: false }); assert.equal(capture(() => { p.update(1); p.finish(); }), ''); +}); +test('quiet mode suppresses transient progress even on a terminal', () => { + const f = new OutputFormatter({ color: false, verbosity: 'quiet' }); f.supportsInteractiveOutput = () => true; const p = f.createProgress({ total: 2, showETA: false }); assert.equal(capture(() => { p.update(1); p.finish(); }), ''); +}); +test('interactive progress remains visible', () => { + const f = new OutputFormatter({ color: false }); f.supportsInteractiveOutput = () => true; const p = f.createProgress({ total: 2, width: 4, showETA: false }); assert.match(capture(() => p.update(1)), /\[##--\] 50.0%/); +}); diff --git a/v3/@claude-flow/cli-core/src/output.ts b/v3/@claude-flow/cli-core/src/output.ts index 9052a53923..d9a0e4fbac 100644 --- a/v3/@claude-flow/cli-core/src/output.ts +++ b/v3/@claude-flow/cli-core/src/output.ts @@ -529,6 +529,7 @@ export class Progress { } render(): void { + if (!this.formatter.supportsInteractiveOutput() || this.formatter.isQuiet()) return; const bar = this.formatter.progressBar(this.current, this.total, this.width); let output = bar; @@ -556,7 +557,9 @@ export class Progress { finish(): void { this.current = this.total; this.render(); - process.stdout.write('\n'); + if (this.formatter.supportsInteractiveOutput() && !this.formatter.isQuiet()) { + process.stdout.write('\n'); + } } private formatTime(ms: number): string {