Repository navigation
Conversation
Replay of checkpointed DECSET 1003/1006 armed the renderer even when the owning TUI was gone, so mouse motion typed SGR reports into readline. Omit those modes from rehydrateSequences; live TUIs re-assert on startup. Fixes stablyai#18424
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (9)
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughMouse tracking is no longer included in terminal rehydration sequences. A new helper removes mouse-enable sequences from stored snapshots during cold restore. Terminal mode metadata still records mouse tracking. Tests now verify that alternate-screen and bracketed-paste modes replay while mouse protocols and encodings do not. Seed expectations and related regression tests reflect the new behavior. Merge Risk: ⚪ Minimal · up to Pane restoration no longer re-enables mouse tracking that can send mouse reports into a bare shell, while preserving alternate-screen, bracketed-paste, and application-cursor restoration. The change is covered across restore paths with no remaining merge-blocking risk. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the bug, solution, scope, preserved behavior, linked issue, testing evidence, and trade-offs. However, it does not follow the repository template and omits required sections such as Visual Proof or an explicit N/A, AI Disclosure, Review, Notes, and Checklist. Resolution Reformat the description using the repository template. Add the missing required sections, including Visual Proof with an explicit N/A and reason if applicable, Testing details, checklist status, review notes, and AI Disclosure information where applicable. Full details: Linked Issues checkExplanation The changes directly address issue [ Full details: Out of Scope Changes checkExplanation The changed implementation, restore-path integration, comments, and regression tests are related to preventing mouse-tracking rehydration. The changes do not introduce unrelated functionality or address excluded issues.
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 |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
buildRehydrateSequencesstops re-arming mouse — drops the?9h/?1000h/?1002h/?1003hreporting switch and the?1006h/?1016hSGR-encoding branch, keeping alt-screen, bracketed paste, and application-cursor rehydration intact.omitMouseTrackingFromRehydrateSequencesstrips baked mouse DECSET — the same six sequences arereplaceAll-removed from a storedrehydrateSequencesstring, wired intocoldRestoreInfoFromSnapshotso pre-fix checkpoints are cleaned on restore without a schema change.- Tests pin the new behavior — a new
terminal-mode-rehydrate-sequences.test.tscovers the generator and strip paths end-to-end againstHeadlessEmulator, and theheadless-emulator,repro-7329,repro-12101, and seed-segment suites are updated fromtoContaintonot.toContain/toBe('').
The fix is sound: rehydrateSequences was a redundant mouse channel — SerializeAddon's own trailer inside snapshotAnsi (and frameRestoreAnsi for live alt-screen owners) already re-arms mouse for live reattach, while cold restore disarms the trailer via COLD_RESTORE_SEED_MODE_RESET. Removing the rehydrate channel only eliminates the dead-TUI leak it was causing. All 15 new/affected unit tests pass locally.
ℹ️ Stale comments still point at the removed rehydrate-mouse mechanism
The code change is correct, but two "Why" comments outside the diff still attribute mouse re-arming on reattach to rehydrateSequences/buildRehydrateSequences, which is no longer true — mouse now comes from SerializeAddon's trailer and frameRestoreAnsi. Worth a follow-up so the next reader isn't misled.
Technical details
# Update stale docs that reference rehydrateSequences re-arming mouse
## Affected sites
- src/shared/terminal-mode-reset-profiles.ts:30-33 — `POST_REPLAY_REATTACH_RESET_KEEP_MOUSE` comment reads "an alt-screen reattach replays the daemon's rehydrateSequences, which re-arm the live TUI's mouse modes".
- tests/e2e/terminal-reattach-mouse-mode-leak.spec.ts — header comment (lines 5-10) and "What it does NOT cover" (lines 22-25) plus inline notes (~100-111, ~150-152) state "buildRehydrateSequences re-arms the mode on reattach".
## Required outcome
- Re-state the mechanism accurately: mouse re-arming on live reattach now comes from SerializeAddon's snapshotAnsi trailer (and frameRestoreAnsi for alt-screen), not rehydrateSequences. The reset-profile and E2E behavior are unchanged.DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
Closing this rehydrate-only PR as superseded by merged #22735, which grounds the full cold-restore payload (mouse and focus modes) and is present in v1.4.215. The new #18424 report on v1.4.212 predates that release fix; I asked the reporter to retest on v1.4.215. The overlapping #20087 proposal also covers fresh-PTY reset, but this PR no longer needs to remain open. |

Description
Restoring a pane no longer replays DECSET mouse tracking from a checkpoint when the TUI that armed it does not come back, so mouse motion cannot type SGR reports (
35;col;rowM) into a bare bash prompt.buildRehydrateSequencesomitsmouseTracking/sgrMouseMode(and SGR-pixels). Live TUIs re-assert those modes on startup. Older checkpoints that already baked?1003h/?1006hinto the stored string are stripped on restore without changing the checkpoint schema.Focused fix
rehydrateSequences(new snapshots and stored checkpoint strings).modes.mouseTrackingpersistence; OpenCode wheel-after-restore (fix(terminal): restore OpenCode mouse-wheel scroll after session restore #11176); live alt-screenframeRestoreAnsimouse for a still-running TUI; gating restore on process identity.Preserves
modes.mouseTracking/sgrMouseModestill recorded).COLD_RESTORE_SEED_MODE_RESET).rehydrateSequencesprefix the daemon snapshot uses.Evidence
pnpm exec vitest run --config config/vitest.config.ts src/main/daemon/terminal-mode-rehydrate-sequences.test.ts src/main/daemon/headless-emulator.test.ts src/main/daemon/terminal-history-seed-segments.test.ts src/main/daemon/repro-7329-remote-snapshot-corruption.test.ts src/main/daemon/repro-12101-mouse-tracking-survives-agent-death.test.ts src/main/daemon/history-reader.test.ts src/main/daemon/reattach-snapshot.test.tsmouseTracking: anyandsgrMouseMode: truemust not emit?1003h/?1006hinrehydrateSequences; alt-screen / bracketed paste still do.pnpm tc:nodepass.User-regression-tradeoffs
rehydrateSequences. Cost is zero for the TUIs this bug names (they re-assert on startup). Distinct from fix(terminal): restore OpenCode mouse-wheel scroll after session restore #11176 (OpenCode wheel after restore).Fixes #18424