Skip to content

feat(shortcuts): allow adding secondary chords to a shortcut - #4658

Open
CaiJingLong wants to merge 2 commits into
binaricat:mainfrom
CaiJingLong:feat/shortcut-extras
Open

CaiJingLong wants to merge 2 commits into
binaricat:mainfrom
CaiJingLong:feat/shortcut-extras

Conversation

@CaiJingLong

Copy link
Copy Markdown

Problem

Settings → Shortcuts lets you re-record the single chord bound to each action. There is no way to add a second one — recording a new chord overwrites the default, so a user who wants e.g. both ⌘J and an easier ⌘⇧O for Quick Switch has to give up the default.

Change

  • CustomKeyBindings records gain an optional extra: { mac?, pc? }[]. The stored shape stays additive, so older builds ignore the new field and new builds read existing records unchanged; the sync record/version semantics are untouched.
  • resolveKeyBindings expands each extra into a real KeyBinding with id <base>::extra-<n> and extraOf set. The existing dispatcher (checkAppShortcut, the global keydown loop) therefore matches secondary chords with no special casing, and settings keeps rendering one row per action.
  • Conflicts follow the existing custom-binding rule: a secondary chord counts as a custom chord, so a default that already occupies it is disabled. Two custom chords may still collide, as before.
  • UI: each non-pattern row gets a + button; extra chords render beneath their base row with re-record and remove buttons. "Reset all" clears them; resetting one scheme keeps them. Pattern rows ([1...9], arrows) do not offer the button.
  • Action-scoped guards now scan every binding for the action instead of the first one: closing a tab while a dialog is open, Quick Switch / pane zoom / host list while a text field has focus, and SFTP terminal search. Their secondary chords previously fell through to the terminal.
  • Strings added for en, es, ru, zh-CN, zh-TW.

Testing

  • 7 new tests in domain/customKeyBindings.test.ts: extra expansion and action resolution, conflict eviction, add / re-record / remove, reset-one-scheme keeps extras, empty override cleanup → 26 pass.
  • Related suites pass: AppHandlers.globalHotkeys, AppHandlers.closeTabPane, settingsLocales, localeParityLocales.
  • eslint clean on all changed files.
  • tsc --noEmit in this checkout reports pre-existing errors (unbuilt @netcatty/plugin-contract, strict Host literals); nothing new in the changed lines. The one error in SettingsShortcutsTab.tsx (SettingsAnchor children) is present on main too.

Note

I could not attach a screenshot: the settings row layout change would need a running dev build. Happy to add one if you want it before merge.

Each shortcut row only accepted one chord, so binding a second, easier chord meant overwriting the default one.

Settings > Shortcuts now offers an add button per row. Secondary chords are stored in the existing custom-binding record as `extra`, expanded into real bindings that carry `extraOf`, and matched by the same dispatcher. They render under their base row and can be re-recorded or removed individually. A secondary chord that a default already occupies disables that default, following the existing custom-binding conflict rule; resetting one scheme keeps the secondary chords.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-02T15:24:24.036379Z 7c1c6f5 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7c1c6f5bd9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread application/app/AppHandlers.ts Resolved
Comment thread domain/customKeyBindings.ts Resolved
The editor's capture-phase close-tab handler and the SFTP native-paste eligibility check still read only the first binding for their action, so a secondary chord added in Settings matched the global dispatcher but did nothing in those paths. Both now scan every binding for the action.
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