szn

Bug 350 — No escape-time timer: lone ESC becomes Alt+next-key

350. ESC ambiguity resolved by whatever the user types next

File: src/server/server.zig:1679-1687, src/tty/tty_key.zig:95-111 Severity: HIGH Status: ✅ FIXED

Fix (applied)

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.

Problem

Pressing Escape alone leaves esc_buf = [0x1b] and input_reader.state == .esc indefinitely. The next keystroke resolves the ambiguity wrong:

tmux solves this with escape-time (flush a pending ESC after N ms). szn has no equivalent.

Root Cause

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.

Fix (proposed)

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.