Repository navigation
perf(vt): stateful single-pass control-sequence framer - #76
Merged
Merged
Conversation
…e engine The side scanner was stateless per PTY read: only OSC 52 survived a split, each ESC handler searched to the end of the chunk (quadratic for many unterminated OSCs), and the OSC 52 carry was re-scanned from scratch on every read (quadratic for a long unterminated sequence). src/vt/framer.rs is a byte state machine that follows the engine's own boundaries (vte 0.13 table: ESC restarts, CAN/SUB cancel, C0 executes inside ESC/CSI, no 8-bit C1 introducers). It withholds ESC/CSI/OSC until complete, keeps DCS/APC/SOS/PM away from the engine, and reports completed sequences to the handlers, which now receive exact bodies. Handlers that read engine state run after the engine has consumed their sequence. The carry is bounded and an over-long sequence is dropped whole. Also fixed, each with a regression test in tests/vt_split_invariance.rs: split CSI/OSC/DCS/APC lost; split Sixel/Kitty payload printed on the grid; title ending at a later BEL; CSI 6n reporting the end-of-read cursor; split ESC # n lost; CSI ?38h swallowing earlier sequences; split OSC 1337;Canvas. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Step 3c of the responsiveness work: one stateful, linear-time control-sequence framer (
src/vt/framer.rs) in front of the VT engine, replacing the stateless per-read side scans insrc/vt/scan.rsandsrc/vt/scan_osc_dcs.rs.CSI 6n, DECRQM, alt-screen switches, Sixel/Kitty placement,ESC # n) run after the engine has consumed their sequence.Bugs this fixes
ESC # nandOSC 1337;Canvaswere lost.CSI 6nreported the end-of-read cursor.ESC[2J ESC[?38hin one read printed "J".Measurements (release, before → after)
Normal throughput is unchanged within noise (single runs).
Verification
tests/vt_split_invariance.rs(15 tests): 38 corpus items at every 2-way split and byte-by-byte, 40 seeded generated streams under random chunking, 4 invalid-UTF-8/raw-C1 items. Compared: grid, scrollback, modes, events, query replies, OSC 52 output. Scanner steps are asserted equal to input bytes.src/, the 14 tests that completed all fail.phase68_69_surface_parityandswarm_wiring, which fail on main and are fixed by ci: six-cell OS/arch matrix, coverage gate, VT fuzz test, fix two stale swarm tests #71.GOLDENS OK 11.Behaviour changes
Known gaps
spawned_child_pty_receives_bilterm_env) failed once under load during development and passed on every rerun; not proven to be a flake.ghostty-vtfeature build and asciicast recording were not tested.🤖 Generated with Claude Code