Skip to content

The agent that grows with you

fix(desktop): shipped ctrl/mod default pairs no longer show conflict warnings

Tekniumfe53d0152d1c
diff --git a/apps/desktop/src/lib/keybinds/browser-app-window-defaults.test.ts b/apps/desktop/src/lib/keybinds/browser-app-window-defaults.test.ts
index 8677b248454..0f1d3bc3d61 100644
--- a/apps/desktop/src/lib/keybinds/browser-app-window-defaults.test.ts
+++ b/apps/desktop/src/lib/keybinds/browser-app-window-defaults.test.ts
@@ -175,3 +175,16 @@ it('reports an app-window Ctrl default as a conflict for the same chord spelled
expect(conflictsFor('session.focusSearch', 'mod+tab')).toEqual(['session.next'])
})
+
+it('factory defaults spelled ctrl and mod do not warn against each other', async () => {
+ setPlatform('Win32')
+ stubDisplayMode('standalone')
+ const { conflictsFor, bindingsFor } = await import('@/store/keybinds')
+ const { allKeybindActions } = await import('@/lib/keybinds/actions')
+
+ const warned = allKeybindActions().filter(action =>
+ bindingsFor(action.id).some(combo => conflictsFor(action.id, combo).length > 0)
+ )
+
+ expect(warned.map(action => action.id).filter(id => /^(profile\.switch|session\.slot)\./.test(id))).toEqual([])
+})
diff --git a/apps/desktop/src/store/keybinds.ts b/apps/desktop/src/store/keybinds.ts
index 5c6411ac70b..dcb6d36b8a7 100644
--- a/apps/desktop/src/store/keybinds.ts
+++ b/apps/desktop/src/store/keybinds.ts
@@ -192,10 +192,20 @@ export function conflictsFor(actionId: string, combo: string, bindings = $bindin
const actions = allKeybindActions()
const self = actions.findIndex(action => action.id === actionId)
const key = canonicalizeCombo(combo)
+ // Two shipped defaults spelled differently (`ctrl+1` vs `mod+1`) overlap by
+ // design off macOS; the alias only conflicts once a user binding (or a combo
+ // being proposed for this action) is involved.
+ const proposed = explicitIds.has(actionId) || !bindingsFor(actionId, bindings).includes(combo)
return actions
.filter((action, index) => {
- if (index === self || !bindingsFor(action.id, bindings).some(other => canonicalizeCombo(other) === key)) {
+ const userSide = proposed || explicitIds.has(action.id)
+
+ const clashes = bindingsFor(action.id, bindings).some(
+ other => other === combo || (userSide && canonicalizeCombo(other) === key)
+ )
+
+ if (index === self || !clashes) {
return false
}