Skip to content

fix: stop Left and Esc from detaching the switcher - #25

Merged
minglong51 merged 4 commits into
mainfrom
fix/hub-left-arrow-ux
Aug 31, 2026
Merged

fix: stop Left and Esc from detaching the switcher#25
minglong51 merged 4 commits into
mainfrom
fix/hub-left-arrow-ux

Conversation

@minglong51

Copy link
Copy Markdown
Owner

Problem

In the session switcher, Left with an empty composer detached the tmux client — and so did a bare Esc, because the key parser's fallback for an unrecognised escape was "left". Unknown CSI sequences (Delete, Home, PageUp, Ctrl-Left) leaked trailing bytes (~, ;5D) into the composer as text, and Ctrl-C / Ctrl-D were silently ignored. The least deliberate keys exited; the reflex keys did nothing.

Change

Mirrors the cascade of Claude Code's agent view (Esc clears → else leaves; Ctrl-C clears → twice leaves) while keeping Ctrl-Q as the instant exit.

Key Behaviour
Left Moves the composer cursor; never detaches
Esc Clears the composer → else returns to the job the switcher was opened from (re-resolved at keypress) → else detaches
Ctrl-C / Ctrl-D Clears the composer → else the same key twice within 2 s detaches; hint lapses on its own; any other key disarms
Ctrl-Q Detaches immediately (unchanged)
Delete / Home / PageUp / Ctrl-arrows Consumed whole; nothing leaks

Parser now reads CSI parameter bytes up to a final byte (0x40–0x7E), drains over-long sequences, keeps SS3 arrows and bracketed paste, and widens the inter-byte timeout from 30 ms to 100 ms so an arrow split across a slow link stays an arrow.

Verification

  • python3 -m unittest tests.test_profiles tests.test_release tests.test_provider_evidence tests.test_provider_probe: 122 OK
  • python3 tests/hub_pty.py (macOS, tmux 3.7c): passes with a new _exercise_switcher_keys block; the block fails against main's binary at its first assertion (Left on an empty composer detached the client)
  • An independent Codex review of the first commit found four defects (stale source job stranding the client on the standby screen, cross-keyed Ctrl-C/Ctrl-D, hint outliving its window, CSI cap not draining); all fixed in the second commit

🤖 Generated with Claude Code

https://claude.ai/code/session_01GJRuZLJk4cT5dvakGL1Wgy

minglong51 and others added 4 commits August 30, 2026 20:45
Left only moves the composer cursor. Esc clears the composer, returns to
the job the switcher was opened from, or leaves when there is no job to
return to. Ctrl-C clears the composer and leaves on a second press within
2 seconds; Ctrl-D twice does the same; Ctrl-Q still leaves immediately.
Unknown CSI sequences (Delete, Home, PageUp, Ctrl-Left) are consumed
whole instead of leaking bytes into the composer.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GJRuZLJk4cT5dvakGL1Wgy
Re-resolve the source job at Esc time so a removed job detaches instead
of stranding the client on the standby screen. Key the Ctrl-C/Ctrl-D
confirmation to the same key, clear text on either, disarm on any other
key, and drop the hint once the 2-second window lapses. Drain over-long
CSI sequences whole and widen the inter-byte timeout to 100 ms so split
arrows over slow links stay arrows.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GJRuZLJk4cT5dvakGL1Wgy
Exercise Left, Esc, Ctrl-C, Ctrl-D, and whole-CSI consumption in the
switcher: Left never detaches, stray Delete/Home/Ctrl-Left bytes stay out
of the composer, Ctrl-C and Ctrl-D clear text, only a same-key double
press within 2 seconds detaches, the hint lapses on its own, typing
disarms it, and Esc returns to a live source job, detaches when that
job is gone, and detaches from a bare hub.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GJRuZLJk4cT5dvakGL1Wgy
The task snapshot is taken before the key wait, so a job removed in that
window still looked alive and Esc switched to a dead session, stranding
the client on the standby screen. Ask tmux whether the session exists
when Esc is pressed; macOS CI hit the race.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GJRuZLJk4cT5dvakGL1Wgy
@minglong51
minglong51 merged commit 92c45bf into main Aug 31, 2026
5 of 6 checks passed
@minglong51
minglong51 deleted the fix/hub-left-arrow-ux branch August 31, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant