fix(cli): suppress ANSI escape codes in non-TTY progress output#124
Conversation
7fc2774 to
418aaf7
Compare
788be01 to
78fd863
Compare
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
miguel-heygen
left a comment
There was a problem hiding this comment.
Duplicate output lines at 10% boundaries
There's no dedup guard — multiple calls rounding to the same threshold will print duplicate lines. For example, if the producer calls with 49.7 then 50.1, both round to 50 and both satisfy rounded % 10 === 0:
50% encoding
50% encoding
Fix with a module-level guard:
let lastPrintedThreshold = -1;
// inside the non-TTY branch:
const rounded = Math.round(percent);
if ((rounded % 10 === 0 || rounded === 100) && rounded !== lastPrintedThreshold) {
lastPrintedThreshold = rounded;
stdout.write(` ${rounded}% ${stage}\n`);
}Also worth considering: early-return for the non-TTY path to avoid computing the full bar/color line variable that's never used in that branch.
renderProgress() was writing \r\x1b[2K escape codes even when stdout is not a TTY, corrupting output for CI pipelines and AI agents. Now writes clean text lines at 10% intervals when not a TTY. Reproducer: cd my-video npx hyperframes render --output out.mp4 2>&1 | cat # Output contained raw escape codes: \x1b[2K
418aaf7 to
c61ae83
Compare
78fd863 to
0b2576b
Compare
miguel-heygen
left a comment
There was a problem hiding this comment.
Addressed: added lastPrintedThreshold dedup guard to prevent duplicate lines. Also moved non-TTY check to early-return at top to skip unused bar/color computation.
|
Consolidated into fix/cli-polish. |

PR Stack
Summary
renderProgress()was writing\r\x1b[2Kescape codes even when stdout is not a TTY, corrupting output for CI pipelines and AI agentsstdout.isTTYand writes clean text lines at 10% intervals when piped/redirectedReproducer
Stack
3/8 — Depends on #123
🤖 Generated with Claude Code