fix(cli-core): suppress transient progress in quiet and redirected output

Signed-off-by: Rudy Celekli <rudy@gradiahq.com>
This commit is contained in:
Rudy Celekli committed 2026-10-10 12:33:47 -04:00
1 parent ca74bd4f79
commit cf7cdf986c
2 files changed
+17 -1

No files matched your search

+13
View File
@@ -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%/);
});
+4 -1
View File
@@ -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 {