Skip to content

The agent that grows with you

fix(webapp): user Alt binds fire while typing in an app window; conflicts compare canonical combos

Teknium2ffe82904be0
diff --git a/apps/desktop/src/lib/keybinds/actions.ts b/apps/desktop/src/lib/keybinds/actions.ts
index 08bcd225025..ef31b72eab7 100644
--- a/apps/desktop/src/lib/keybinds/actions.ts
+++ b/apps/desktop/src/lib/keybinds/actions.ts
@@ -60,10 +60,10 @@ function hostAction(
return inChromiumAppWindow() ? native : tab
},
// Alt+letter has no Cmd/Ctrl, so it needs the editable-target opt-in to
- // fire from the composer the way the native ⌘/Ctrl chord does.
- get editableTargetPolicy() {
- return inChromiumAppWindow() ? undefined : 'modified'
- }
+ // fire from the composer the way the native ⌘/Ctrl chord does. Fixed, not
+ // keyed on the window kind: a user's Alt rebind outlives a move into an
+ // app window, and the Ctrl defaults there pass the input gate anyway.
+ editableTargetPolicy: 'modified'
}
}
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 bb6bc0d20c1..8677b248454 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
@@ -155,3 +155,23 @@ it('a non-Chromium web-app window keeps the browser-tab defaults', async () => {
expect(bindingsFor(shortcut.id)).toEqual([shortcut.tab])
}
})
+
+it('a user Alt binding still fires from the composer inside an app window', async () => {
+ setPlatform('Win32')
+ const moveTo = stubDisplayMode('browser')
+ const { setBinding } = await import('@/store/keybinds')
+ const { actionAllowedInInput } = await import('./combo')
+
+ setBinding('view.closeTab', ['alt+shift+q'])
+ moveTo('standalone')
+
+ expect(actionAllowedInInput('view.closeTab', 'alt+shift+q')).toBe(true)
+})
+
+it('reports an app-window Ctrl default as a conflict for the same chord spelled mod', async () => {
+ setPlatform('Win32')
+ stubDisplayMode('standalone')
+ const { conflictsFor } = await import('@/store/keybinds')
+
+ expect(conflictsFor('session.focusSearch', 'mod+tab')).toEqual(['session.next'])
+})
diff --git a/apps/desktop/src/store/keybinds.ts b/apps/desktop/src/store/keybinds.ts
index 57562670897..5c6411ac70b 100644
--- a/apps/desktop/src/store/keybinds.ts
+++ b/apps/desktop/src/store/keybinds.ts
@@ -186,14 +186,16 @@ export function resetAllBindings(): void {
// Other actions that already use `combo` (excluding `actionId` itself). A
// `passthrough` action layered over a later one shares the chord by design,
-// so that pair is not reported from either side.
+// so that pair is not reported from either side. Combos compare the way
+// dispatch keys them, so `mod+tab` meets an app window's `ctrl+tab`.
export function conflictsFor(actionId: string, combo: string, bindings = $bindings.get()): string[] {
const actions = allKeybindActions()
const self = actions.findIndex(action => action.id === actionId)
+ const key = canonicalizeCombo(combo)
return actions
.filter((action, index) => {
- if (index === self || !bindingsFor(action.id, bindings).includes(combo)) {
+ if (index === self || !bindingsFor(action.id, bindings).some(other => canonicalizeCombo(other) === key)) {
return false
}