fix(terminal): trap Ctrl+Z in non-shell sessions to prevent accidental suspend - #404
Open
timkjr wants to merge 1 commit into
Open
fix(terminal): trap Ctrl+Z in non-shell sessions to prevent accidental suspend#404timkjr wants to merge 1 commit into
timkjr wants to merge 1 commit into
Conversation
…l suspend Ctrl+Z (SIGTSTP) suspends the foreground job on the pane's tty. In a plain shell session that's the user's own job-control tool (suspend, fg back), but in claude/omp/pi/codex/etc. sessions it stops an unattended agent loop dead with no visible output — the same failure shape as an XOFF freeze, just via job control instead of tty flow control. Ink-based TUIs usually run in raw mode (ISIG off) where ^Z is inert, but that only holds once the CLI is actually running and stays in raw mode; it's live at the shell prompt before launch and during any raw-mode toggle. Swallow it client-side in attachCustomKeyEventHandler, mode-gated so shell sessions keep normal job control, mirroring the existing Ctrl+V/Ctrl+Backspace interception pattern in the same handler. Case-insensitive key match (Caps Lock flips ev.key to 'Z' without setting shiftKey, so a plain === 'z' check let the exact suspend keystroke this exists to catch slip through). Also cover subagent/teammate terminal windows (panels-ui.js's initTeammateTerminal), which render a separate xterm instance with no custom key handler at all and are always running an agent CLI — never a shell — so the trap there is unconditional. Co-Authored-By: Claude Sonnet 5 <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.
Summary
attachCustomKeyEventHandler, mode-gated so shell sessions keep normal Ctrl+Z job control (suspend/fg) untouched. Mirrors the existing Ctrl+V/Ctrl+Backspace interception pattern in the same handler.ev.keyto'Z'without settingshiftKey, so a plain=== 'z'check let the exact suspend keystroke this exists to catch slip through.panels-ui.js'sinitTeammateTerminal), which render a separate xterm instance with no custom key handler at all and always run an agent CLI (never a shell), so the trap there is unconditional.Test plan
npm run check:frontend-syntax— both changed files parse cleanlyterminal-copy-selection.test.ts,shortcut-registry-overlay.test.ts)/code-review --level high(including the Caps Lock finding that shaped this diff)🤖 Generated with Claude Code