szn

Bug 183 — Escape key cannot cancel choose mode — InputReader never emits .special.escape for bare 0x1B

183. Escape key cannot cancel choose mode — InputReader never emits .special.escape for bare 0x1B

File: src/tty/tty_key.zig:94–106, src/server/server.zig:923 Severity: MEDIUM Status: ✅ FIXED

Two complementary changes:

  1. feedEsc(0x1B) — When a second 0x1B arrives while the reader is in .esc state, return Event{ .key = .{ .special = .{ .key = .escape } } } instead of treating it as Alt+0x1B. Double-ESC in choose mode now cancels. Unit test added: "esc esc = escape key".

  2. processInput choose-mode path — If the InputReader is stuck in .esc state (from a previous bare 0x1B) and the current byte is not [ or O (i.e. not a legitimate CSI/SS3 continuation), flush the reader back to .ground and emit a synthetic Escape event. This handles the single-ESC case even when no second 0x1B follows — e.g. ESC arriving alone in one buffer and the next byte in another.