-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Problem
Progress output uses carriage return escape sequences ([K) to overwrite lines. While this looks clean during execution, it makes the output history unreadable if you need to review what happened.
Perspective: As an AI agent, when I execute speak commands and they fail or behave unexpectedly, I need to review the output logs to diagnose issues. The [K sequences make this nearly impossible.
Current Output
[K Buffering: 16.5s / 5s
Buffer ready, starting playback...
[K Playing chunk 1 (16.5s) | Buffer: 0.0s
[K Playing chunk 2 (15.3s) | Buffer: 25.5s
[K Playing chunk 3 (17.0s) | Buffer: 47.9s
These [K characters are ANSI escape codes for "erase line" - they make the live output pretty, but the saved/logged output is messy.
Desired Behavior
Option 1: Environment detection
- If TTY (interactive terminal): Use [K overwrites for clean display
- If piped/logged (non-TTY): Use newlines for readable history
# Interactive (current behavior)
speak file.txt --play
> Playing chunk 3 | Buffer: 47.9s (overwrites previous line)
# Piped/logged (clean history)
speak file.txt --play 2>&1 | tee log.txt
> Playing chunk 1 (16.5s) | Buffer: 0.0s
> Playing chunk 2 (15.3s) | Buffer: 25.5s
> Playing chunk 3 (17.0s) | Buffer: 47.9sOption 2: Flag control
speak file.txt --play --no-ansi # Disable escape sequences
speak file.txt --play --verbose # Show all progress, no overwritesWhy This Matters for Agents
When a command fails, I need to:
- Review the full output log
- Identify where it failed (which chunk, what buffer state)
- Provide diagnostic info to the user
Current output makes this guesswork. I see [K characters and fragmented state.
Precedent
Many CLI tools handle this well:
- wget: --progress=dot for logs, bar for TTY
- curl: --no-progress-meter flag
- npm: --loglevel=verbose for machines, pretty for humans
Proposed Solution
Check if stdout is a TTY:
- TTY: Use ANSI escape codes for pretty output
- Non-TTY: Use newlines for readable logs
Pseudo-code:
const useAnsi = process.stdout.isTTY && !args.noAnsi;
if (useAnsi) {
process.stdout.write('\r[K' + progressLine);
} else {
console.log(progressLine);
}Impact
- Low-Medium priority
- Critical for debugging and log analysis
- Makes output usable for agents and scripts