fix: detect statusline width from controlling terminal#510
Conversation
jarrodwatts
left a comment
There was a problem hiding this comment.
This targets a real piped-stdout width problem, but I am holding it because it adds synchronous /dev/tty probing to the hot statusline path. The HUD can run every few hundred milliseconds, so this needs more proof before it belongs in core width detection.
Required fixes:
- Add a positive mocked test for the /dev/tty fallback and a failure/unavailable-tty test.
- Demonstrate or avoid repeated open/destroy cost in the hot path. A lightweight cache or setup-level width propagation may be better if repeated probing is measurable.
- Confirm Node and Bun behavior for the tty.WriteStream lifecycle, including close/destroy behavior after openSync.
Security review found no token/network issue. The hold is runtime risk and testability.
|
Thanks for adding the cache and mocked tty-probe coverage. I am leaving this open for a maintainer width-strategy decision after the forceMaxWidth merge. The remaining question is whether core width detection should probe /dev/tty in the statusline process at all, even with per-process caching.\n\nNo credential or network issue was found. The open risk is runtime behavior in the hot statusline path, plus overlap with the setup-level COLUMNS work in #513 and the broader row-budget work in #511. |
Summary
process.stdout.columnsisundefinedand terminal width detection fails/dev/ttyfallback: opens the controlling terminal directly to query its column count when stdout/stderr streams andCOLUMNSenv are all unavailable/dev/tty) and whenCLAUDE_HUD_DISABLE_TTY_WIDTH=1is set (for testing)Test plan
tests/terminal.test.jsto setCLAUDE_HUD_DISABLE_TTY_WIDTH=1in the test harness so unit tests don't accidentally read the real terminal