Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add terminal shortcut routing policy#2610

Merged
nwparker merged 1 commit into
mainfrom
nwparker/terminal-shortcut-policy
May 22, 2026
Merged

Add terminal shortcut routing policy#2610
nwparker merged 1 commit into
mainfrom
nwparker/terminal-shortcut-policy

Conversation

@nwparker
Copy link
Copy Markdown
Contributor

Summary

Follow-up to #2581. This keeps the new keybinding customization path, but makes terminal/TUI shortcut ownership explicit instead of changing the default behavior silently.

  • Adds terminalShortcutPolicy with two modes: Orca first (default) and Terminal first (opt-in).
  • Keeps default behavior familiar: Cmd+J, Cmd+P, and other app shortcuts still work from focused terminal/TUI sessions unless the user opts into Terminal-first.
  • Adds Settings > Shortcuts UI for the policy, plus per-shortcut terminal-context badges (Orca first, Terminal first, Terminal, Terminal active).
  • Mirrors xterm focus to the main process so before-input-event can route shortcuts using the same policy as renderer handlers.
  • Routes menu-backed shortcuts (Settings, Export PDF, Force Reload) through the shortcut policy instead of native Electron accelerators so Terminal-first is not bypassed.
  • Adds a first-time notification when Orca captures a potentially conflicting shortcut while terminal focus is active, with a direct action to open Shortcuts settings.
  • Normalizes malformed persisted terminalShortcutPolicy values back to orca-first on load/update.

Behavior Notes

  • Default: Orca-first. A focused TUI coding agent still gets quick Orca navigation affordances like the worktree switcher.
  • Terminal-first opt-in: non-terminal app/global shortcuts pass through when a terminal has keyboard focus. Terminal-scoped shortcuts and explicitly terminal-active app shortcuts remain active.
  • Browser guest shortcuts still use browser/app context; this change is scoped to focused terminal input.

Review Notes / Risks

  • I found and fixed one persistence-boundary issue during review: invalid policy values could otherwise linger in settings state even though runtime matchers normalized them.
  • Menu items for Settings / Export PDF / Force Reload now show shortcut labels but rely on the shared shortcut router for keyboard dispatch. That is intentional so terminal policy applies, but it is the main behavior-surface change in this PR.
  • Native platform-reserved chords may still be consumed by Electron/OS before a terminal can receive them; Terminal-first can stop Orca from acting on known shortcuts, but it cannot make every platform-reserved chord deliverable to the shell.

Validation

  • pnpm run typecheck
  • pnpm run lint
  • pnpm exec vitest run --config config/vitest.config.ts src/shared/keybindings.test.ts src/shared/window-shortcut-policy.test.ts src/renderer/src/components/terminal-pane/keyboard-handlers.test.ts src/main/window/createMainWindow.test.ts src/main/menu/register-app-menu.test.ts src/main/persistence.test.ts
  • pnpm test — 893 files passed, 1 skipped; 9347 tests passed, 10 skipped
  • Electron UI verification before PR branch cleanup: Settings search for keyboard, Shortcuts page policy dropdown, Terminal-first badge updates, and restored default Orca first afterward. CDP keypress simulation did not reliably exercise Electron before-input-event, so native shortcut routing is covered by main-window tests.

Related: #1493, #713, #891, #1502, #858, #1168

@nwparker nwparker force-pushed the nwparker/terminal-shortcut-policy branch from a08fc55 to 9ce26f6 Compare May 22, 2026 06:54
@nwparker nwparker merged commit 81fcfea into main May 22, 2026
1 check passed
@nwparker nwparker deleted the nwparker/terminal-shortcut-policy branch May 22, 2026 06:58
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