vt: an alt-screen snapshot can break an escape sequence in the live terminal #53
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found while fixing #1 (
d774b26); it predates that change.To format the primary screen and its scrollback while an alt screen shows,
snapshot_historyflips the live terminal withCSI ?47l, formats, thenCSI ?47h(crates/vt/src/ghostty/wire.rs:140and:151).If the PTY stream last stopped in the middle of an escape sequence (the parser holds a continuation), that
vt_writelands inside the unfinished sequence: the sequence is corrupted and the remainder of it, when it arrives, prints as text, in the engine and so for every client. Snapshots happen on every attach and resync, so this is most likely during floods, exactly when resyncs happen.Fix ideas:
Done when: a test feeds half an escape sequence (e.g.
\x1b[38;2;1) under an alt screen, takes a snapshot, feeds the rest, and the live screen and a fresh snapshot match the same stream fed without the snapshot.Fixed on main:
fe2dac2(Merge #53). The live terminal is flipped with ?47l/?47h only when its parser is at ground. Mid-sequence, the primary screen is formatted from a GHOSTSNP copy (CAN ends the copy's sequence), and the live terminal is never written to. Wire snapshots now also end with the pending continuation, so a client fed a mid-sequence snapshot finishes the sequence correctly. Tests: an_alt_screen_snapshot_mid_sequence_leaves_the_stream_alone (CSI, ESC, OSC, UTF-8, over-limit OSC, on both screens) and a reattach.spec.ts Playwright case that fails on the old main. PLAN.md: S1 vt/snapshot notes.