Summary
When a worktree has multiple split panes, pressing Ctrl-R can be delivered to every pane instead of only the active/focused pane. This is especially visible when multiple Claude Code sessions are running: one inactive pane can receive Ctrl-R and enter a stuck/search-like input state.
Expected
Keyboard input should be routed to the single active Ghostty surface in the key window. Inactive split panes should not forward keyDown, keyUp, or modifier changes to Ghostty.
Actual
performKeyEquivalent already checks that the surface is the window's first responder, but the lower-level keyDown / keyUp / flagsChanged paths did not have the same guard. If those paths are invoked for a stale/non-active surface, that surface can still forward the event to its PTY.
Repro
- Open a worktree with two split panes.
- Run Claude Code or another TUI in both panes.
- Focus one pane.
- Press
Ctrl-R.
- Observe that the inactive pane can also receive
Ctrl-R and become stuck / enter an unintended input mode.
Proposed fix
Guard terminal keyboard input at GhosttySurfaceView so only window.firstResponder === self forwards keyboard events to Ghostty, while preserving windowless initialization/test paths.
Summary
When a worktree has multiple split panes, pressing
Ctrl-Rcan be delivered to every pane instead of only the active/focused pane. This is especially visible when multiple Claude Code sessions are running: one inactive pane can receiveCtrl-Rand enter a stuck/search-like input state.Expected
Keyboard input should be routed to the single active Ghostty surface in the key window. Inactive split panes should not forward
keyDown,keyUp, or modifier changes to Ghostty.Actual
performKeyEquivalentalready checks that the surface is the window's first responder, but the lower-levelkeyDown/keyUp/flagsChangedpaths did not have the same guard. If those paths are invoked for a stale/non-active surface, that surface can still forward the event to its PTY.Repro
Ctrl-R.Ctrl-Rand become stuck / enter an unintended input mode.Proposed fix
Guard terminal keyboard input at
GhosttySurfaceViewso onlywindow.firstResponder === selfforwards keyboard events to Ghostty, while preserving windowless initialization/test paths.