Fix Escape propagation when command palette is visible
Merged
LA
9mo ago+1138+1138+0123456789012345678901234567890123456789-12-12-01234567890123456789
Summary
- consume plain
Escapewhile command palette is visible so the key does not propagate to the terminal/browser below - explicitly dismiss the visible command palette window from app-level shortcut routing when handling plain
Escape - add regressions for both shortcut-consumption logic and app-level Escape-dismiss notification routing
Testing
xcodebuild -quiet -project GhosttyTabs.xcodeproj -scheme cmux-unit -configuration Debug -destination 'platform=macOS' -derivedDataPath /tmp/cmux-escape-prop-fail -only-testing:cmuxTests/CommandPaletteOpenShortcutConsumptionTests/testConsumesEscapeWhenPaletteIsVisible test(fails before fix withXCTAssertTrue failed, then passes after fix)xcodebuild -quiet -project GhosttyTabs.xcodeproj -scheme cmux-unit -configuration Debug -destination 'platform=macOS' -derivedDataPath /tmp/cmux-escape-prop-fail -only-testing:cmuxTests/CommandPaletteOpenShortcutConsumptionTests -only-testing:cmuxTests/AppDelegateShortcutRoutingTests/testEscapeDismissesVisibleCommandPaletteAndIsConsumed test(passes)codex --dangerously-bypass-approvals-and-sandbox --model gpt-5.3-codex -c model_reasoning_effort="xhigh" --search review --uncommitted(final pass: no actionable findings)
Issues
- Task reference: user request in HQ session: "after cmd+p or cmd+shift+p, if we press Escape, the cmd+p/cmd+shift+p closes, but the escape key also propagates to the terminal below"
Summary by cubic
Stops Escape from leaking to the terminal/browser when the command palette is open, pending open, or just dismissed. Escape cleanly dismisses the palette and is consumed, while respecting IME input.
- Bug Fixes
- Consume plain Escape when the palette is effectively visible (visible, overlay shown, responder active) or just requested to open (Cmd+P/Cmd+Shift+P/menu/API), and dismiss via commandPaletteToggleRequested.
- Respect IME marked text: Escape passes through composition and does not dismiss.
- Suppress Escape repeats and key-up after dismiss; add a short grace window and prune stale pending-open state so Escape doesn’t leak or over-consume.
- Expanded tests cover IME, menu/shortcut-triggered pending-open races, repeat/key-up suppression, and window scoping.
Summary by CodeRabbit
- Bug Fixes
- Improved escape key handling for command palette dismissal
- Enhanced command palette behavior across multiple windows
- Better input method editor compatibility during command palette interactions
- Refined window routing and state management for more reliable command palette behavior