File: src/server/server.zig:1679-1687, src/tty/tty_key.zig:95-111
Severity: HIGH
Status: ✅ FIXED
Server.esc_pending_since_ms timestamps every byte buffered while the
parser is mid-sequence; each new byte refreshes the budget, so expiry is
inactivity-based like tmux.run() flushes stale sequences via flushPendingEscape() (raw bytes to the
active pane, parser reset) and clamps the poll timeout to the pending
deadline so the flush fires on time instead of after a long sleep.escape-time
(tmux-compatible default 500 ms; 0 flushes immediately).Tests: lone ESC flushed verbatim at escape-time 0; partial SS3 prefix survives within the budget; run() flushes a stale sequence and unblocks the loop.
Pressing Escape alone leaves esc_buf = [0x1b] and input_reader.state == .esc
indefinitely. The next keystroke resolves the ambiguity wrong:
k: delivered as Alt+k (M-k) instead of Esc, k.run() only
shortens its poll timeout for mouse autoscroll).tmux solves this with escape-time (flush a pending ESC after N ms). szn has
no equivalent.
feedEsc can only produce .escape on a second 0x1b or complete a sequence;
there is no time-based flush of esc_buf + input_reader.reset() in the poll
loop.
Track a monotonic timestamp when the first byte enters a non-ground parser
state; in run(), clamp the poll timeout to the remaining escape-time budget
(tmux default ~500 ms, configurable option) and on expiry forward the buffered
raw bytes to the active pane and reset the reader.