fix(server): strip replayable terminal queries from history - #5319
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Approved bdb85ee This is a straightforward bug fix that extends existing terminal history sanitization to strip additional query/reply escape sequences (DECRQM, XTVERSION, Kitty keyboard, DCS) that cause junk output when replayed. The changes follow established patterns, are well-documented, and include comprehensive tests. You can customize Macroscope's approvability policy. Learn more. |
## What's Changed * fix(web): blink the terminal cursor again by @StiensWout in pingdotgg/t3code#5314 * fix(terminal): protect held Ctrl/Cmd+W close shortcut by @StiensWout in pingdotgg/t3code#5322 * fix(server): strip replayable terminal queries from history by @StiensWout in pingdotgg/t3code#5319 * fix(contracts): decode ServerProviders forward-compatibly by @Brechard in pingdotgg/t3code#5327 * fix(web): simplify chat code blocks by @t3-code[bot] in pingdotgg/t3code#5301 * fix(web): align multiline error alert controls by @t3-code[bot] in pingdotgg/t3code#5304 * Upgrade Effect to beta.103 by @juliusmarminge in pingdotgg/t3code#5331 ## New Contributors * @Brechard made their first contribution in pingdotgg/t3code#5327 **Full Changelog**: pingdotgg/t3code@v0.0.32-nightly.20260804.993...v0.0.32-nightly.20260804.997 Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.32-nightly.20260804.997
Summary
Why
Reopening a terminal replays its persisted output. Capability queries in that history can trigger fresh replies, which the shell then displays as visible gibberish at the prompt.
Validation
pnpm exec vitest run --config apps/server/vite.config.ts apps/server/src/terminal/Manager.test.ts --testNamePattern='(strips replay|handles CSI|preserves clear|ESC sequences)'vp run --filter t3 typecheckvp fmt --check apps/server/src/terminal/Manager.ts apps/server/src/terminal/Manager.test.tsImplemented and validated by Codex (GPT-5.6) in T3 Code.
Playwright verification
The recording shows query traffic around visible terminal output, a thread reload/reopen, and the same clean output after history reattachment.
Note
Low Risk
Scoped to terminal history persistence and sanitization logic with regression tests; no auth, data, or live output path changes.
Overview
Extends persisted terminal history sanitization so reopening a session no longer replays capability queries that make the terminal answer again and leave junk at the prompt.
CSI stripping now drops DECRQM/DECRPM (
$p/$y), XTVERSION (>q), and kitty keyboard (?u) traffic, with guards so setters like DECSTR, DECSCL, DECSCUSR, and restore-cursor still stay in history.DCS stripping is new via
shouldStripDcsSequencefor DECRQSS and XTGETTCAP query/reply pairs ($q/$rand+q/+r), in both 7-bit (ESC P) and 8-bit (0x90) forms. Live PTY output is unchanged; only what gets written to history is filtered.Tests add reopen scenarios for mixed CSI/DCS traffic, chunk-split sequences, and setter preservation alongside existing OSC behavior.
Reviewed by Cursor Bugbot for commit bdb85ee. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Strip replayable CSI and DCS query sequences from terminal history
shouldStripCsiSequencein Manager.ts to also strip DECRQM/DECRPM ($p/$y), XTVERSION (>q), and kitty keyboard (?u) query/reply sequences, while preserving setter sequences like DECSTR (!p) and restore-cursor (u).shouldStripDcsSequencehelper that detects and strips DCS-based query/reply traffic (DECRQSS, XTGETTCAP, and their[01]$r/[01]+rreplies).sanitizeTerminalHistoryChunkto apply DCS stripping alongside the existing OSC and CSI filtering, covering both 7-bit and 8-bit encodings and sequences split across output chunks.Macroscope summarized bdb85ee.
closes #4776