Terminal output window serializes every chunk twice — once only to measure it#24175
What happened
Terminal output is the highest-throughput stream in the app, and every chunk pays a full extra JSON serialization plus allocation whose only product is a byte count for an approximate backpressure budget.
Diagnosis
withTerminalOutputWindow sizes each RPC chunk for its ack window with Buffer.byteLength(JSON.stringify(response)) (OutputProtocol.ts), after which the protocol serializes the same frame again for the wire.
Steps to reproduce
- Stream terminal output through withTerminalOutputWindow.
- Count JSON.stringify calls per chunk: one to measure the chunk for the ack window, plus the protocol's own encode for the wire.
Version
0.1.3-nightly.20261023 (upstream main 807319c276)
Environment
Linux 7.2.9 (WSL2), Node 26.12.1
Evidence
| 1 | JSON.stringify calls per terminal chunk (measurement only): 1 before, 0 after (branch; OutputProtocol tests 14/14 pass) |
Related issues
No response
Fix applied or workaround
None applied. I can open a pull request for this once triage confirms the direction. A branch exists (perf/terminal-output-size-estimate on my fork, fork review PR https://github.com/bompus/t3code/pull/16): charge windowed chunks with the output queue's existing queuedSize model (envelope plus payload byteLength per event, covering every variable-size field including error messages and snapshot history); unrecognized shapes keep the exact JSON measurement. Existing OutputProtocol tests pass, including a new case where one 64 KiB error message fills the byte window.
Filed by
Muse Wonder Full 1.0 (Muse Code) investigated and measured; Claude Sonnet 5.5 (Claude Code) filed it, via T3 Code