Skip to content

The agent that grows with you

fix(desktop): profile Cmd+1-9 always switch profiles; tab slots get their own action (#92569)

Brooklyn Nicholsone0eb93a168d8
diff --git a/apps/desktop/src/app/hooks/use-keybinds.ts b/apps/desktop/src/app/hooks/use-keybinds.ts
index 175a25641a8..4592e16956d 100644
--- a/apps/desktop/src/app/hooks/use-keybinds.ts
+++ b/apps/desktop/src/app/hooks/use-keybinds.ts
@@ -17,7 +17,7 @@ import {
import { setWorkspaceScope } from '@/components/pane-shell/workspace-scope'
import { onReleaseTypingFocus } from '@/components/ui/keyboard-first'
import { findBarClaimsCombo } from '@/lib/find-in-page'
-import { contributedKeybindHandler, PROFILE_SLOT_COUNT, SESSION_SLOT_COUNT } from '@/lib/keybinds/actions'
+import { contributedKeybindHandler, PROFILE_SLOT_COUNT, SESSION_SLOT_COUNT, TAB_SLOT_COUNT } from '@/lib/keybinds/actions'
import { handleApprovalKey, releaseApprovalKey } from '@/lib/keybinds/approval-keys'
import { actionAllowedInInput, comboFromEvent, isEditableTarget } from '@/lib/keybinds/combo'
import { composerFocusKeysAllowed, isComposerFocusSoftCombo, typeToFocusChar } from '@/lib/keybinds/composer-focus-keys'
@@ -137,16 +137,13 @@ export function useKeybinds(deps: KeybindRuntimeDeps): void {
}
for (let slot = 1; slot <= PROFILE_SLOT_COUNT; slot += 1) {
- // ⌘1…⌘9 switch the FOCUSED zone's tab when it's a real tab strip; only a
- // single-pane (or unfocused) layout falls through to the profile switch.
+ // Unconditional (#92569): ⌘1…⌘9 are PROFILE switchers, period. The old
+ // tab-first dispatch (activateTreeTabSlot before switchProfileToSlot)
+ // lived inside this handler, so session tabs silently ate the chord and
+ // rebinding could not change the semantics. Positional tab switching
+ // moved to the unbound view.tabSlot.N actions below.
profileSwitchHandlers[`profile.switch.${slot}`] = () => {
- const pane = activateTreeTabSlot(slot)
-
- if (pane) {
- leavePageForWorkspaceChat(pane)
- } else {
- switchProfileToSlot(slot)
- }
+ switchProfileToSlot(slot)
}
}
@@ -166,6 +163,21 @@ export function useKeybinds(deps: KeybindRuntimeDeps): void {
}
}
+ // view.tabSlot.N: activate the Nth visible tab in the focused zone's tab
+ // strip. Ships unbound (#92569) — users who want positional tab switching
+ // can assign chords in Settings → Keyboard Shortcuts.
+ const tabSlotHandlers: HandlerMap = {}
+
+ for (let slot = 1; slot <= TAB_SLOT_COUNT; slot += 1) {
+ tabSlotHandlers[`view.tabSlot.${slot}`] = () => {
+ const pane = activateTreeTabSlot(slot)
+
+ if (pane) {
+ leavePageForWorkspaceChat(pane)
+ }
+ }
+ }
+
commitSwitcherRef.current = () => goToSession(commitOnCtrlUp())
const stepSession = (direction: 1 | -1) => {
@@ -175,7 +187,7 @@ export function useKeybinds(deps: KeybindRuntimeDeps): void {
// ⌃Tab cycles the focused session/main tab strip; only a non-tabbed focus
// falls through to the recent-session switcher. Landing on the workspace
- // under a full page routes back to the chat (same as ⌘1).
+ // under a full page routes back to the chat (same as view.tabSlot.1).
const cycleTab = (direction: 1 | -1) => {
const pane = cycleTreeTabInFocusedZone(direction)
@@ -239,6 +251,7 @@ export function useKeybinds(deps: KeybindRuntimeDeps): void {
'session.next': () => cycleTab(1),
'session.prev': () => cycleTab(-1),
...sessionSlotHandlers,
+ ...tabSlotHandlers,
'session.focusSearch': requestSessionSearchFocus,
'session.togglePin': deps.toggleSelectedPin,
'session.archive': deps.archiveSelectedSession,
diff --git a/apps/desktop/src/components/pane-shell/tree/tab-slot-shown.test.ts b/apps/desktop/src/components/pane-shell/tree/tab-slot-shown.test.ts
index 85ec5b6c0ff..087e487b863 100644
--- a/apps/desktop/src/components/pane-shell/tree/tab-slot-shown.test.ts
+++ b/apps/desktop/src/components/pane-shell/tree/tab-slot-shown.test.ts
@@ -3,6 +3,10 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
// ⌘1…⌘9 / ⌃Tab must index the same tabs the strip paints. A chrome-hidden
// pane (Focus layout's `files`) stays in `group.panes` but isn't a chip —
// indexing the raw array made ⌘2 land on the strip's first session tab.
+//
+// NOTE: `activateTreeTabSlot` backs the `view.tabSlot.N` actions (shipped
+// unbound), NOT `profile.switch.N` — ⌘1…⌘9 switch profiles unconditionally
+// (#92569).
describe('activateTreeTabSlot indexes shown panes only', () => {
beforeEach(() => {
diff --git a/apps/desktop/src/i18n/de.ts b/apps/desktop/src/i18n/de.ts
index 4273f242bda..a6b2dcdf566 100644
--- a/apps/desktop/src/i18n/de.ts
+++ b/apps/desktop/src/i18n/de.ts
@@ -711,6 +711,15 @@ export const deOverrides = {
'view.findInPage': 'Auf Seite suchen',
'view.findNext': 'Nächsten Treffer suchen',
'view.findPrevious': 'Vorherigen Treffer suchen',
+ 'view.tabSlot.1': 'Zu Tab 1 wechseln',
+ 'view.tabSlot.2': 'Zu Tab 2 wechseln',
+ 'view.tabSlot.3': 'Zu Tab 3 wechseln',
+ 'view.tabSlot.4': 'Zu Tab 4 wechseln',
+ 'view.tabSlot.5': 'Zu Tab 5 wechseln',
+ 'view.tabSlot.6': 'Zu Tab 6 wechseln',
+ 'view.tabSlot.7': 'Zu Tab 7 wechseln',
+ 'view.tabSlot.8': 'Zu Tab 8 wechseln',
+ 'view.tabSlot.9': 'Zu Tab 9 wechseln',
'appearance.toggleMode': 'Hell / dunkel umschalten',
'profile.default': 'Zu Standardprofil wechseln',
'profile.switch.1': 'Zu Profil 1 wechseln',
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index 6494e5ab7da..184c84d2064 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -767,6 +767,15 @@ export const en: Translations = {
'view.findInPage': 'Find in page',
'view.findNext': 'Find next match',
'view.findPrevious': 'Find previous match',
+ 'view.tabSlot.1': 'Switch to tab 1',
+ 'view.tabSlot.2': 'Switch to tab 2',
+ 'view.tabSlot.3': 'Switch to tab 3',
+ 'view.tabSlot.4': 'Switch to tab 4',
+ 'view.tabSlot.5': 'Switch to tab 5',
+ 'view.tabSlot.6': 'Switch to tab 6',
+ 'view.tabSlot.7': 'Switch to tab 7',
+ 'view.tabSlot.8': 'Switch to tab 8',
+ 'view.tabSlot.9': 'Switch to tab 9',
'appearance.toggleMode': 'Toggle light / dark',
'profile.default': 'Switch to default profile',
'profile.switch.1': 'Switch to profile 1',
diff --git a/apps/desktop/src/i18n/es.ts b/apps/desktop/src/i18n/es.ts
index de8e2a2ac6c..f9dac15ad7a 100644
--- a/apps/desktop/src/i18n/es.ts
+++ b/apps/desktop/src/i18n/es.ts
@@ -711,6 +711,15 @@ export const esOverrides = {
'view.findInPage': 'Buscar en la página',
'view.findNext': 'Siguiente coincidencia',
'view.findPrevious': 'Coincidencia anterior',
+ 'view.tabSlot.1': 'Cambiar a la pestaña 1',
+ 'view.tabSlot.2': 'Cambiar a la pestaña 2',
+ 'view.tabSlot.3': 'Cambiar a la pestaña 3',
+ 'view.tabSlot.4': 'Cambiar a la pestaña 4',
+ 'view.tabSlot.5': 'Cambiar a la pestaña 5',
+ 'view.tabSlot.6': 'Cambiar a la pestaña 6',
+ 'view.tabSlot.7': 'Cambiar a la pestaña 7',
+ 'view.tabSlot.8': 'Cambiar a la pestaña 8',
+ 'view.tabSlot.9': 'Cambiar a la pestaña 9',
'appearance.toggleMode': 'Alternar claro / oscuro',
'profile.default': 'Cambiar al perfil predeterminado',
'profile.switch.1': 'Cambiar al perfil 1',
diff --git a/apps/desktop/src/i18n/fr.ts b/apps/desktop/src/i18n/fr.ts
index 29b52def42c..8590d38d0e3 100644
--- a/apps/desktop/src/i18n/fr.ts
+++ b/apps/desktop/src/i18n/fr.ts
@@ -710,6 +710,15 @@ export const frOverrides = {
'view.findInPage': 'Rechercher dans la page',
'view.findNext': 'Rechercher la correspondance suivante',
'view.findPrevious': 'Rechercher la correspondance précédente',
+ 'view.tabSlot.1': "Basculer vers l'onglet 1",
+ 'view.tabSlot.2': "Basculer vers l'onglet 2",
+ 'view.tabSlot.3': "Basculer vers l'onglet 3",
+ 'view.tabSlot.4': "Basculer vers l'onglet 4",
+ 'view.tabSlot.5': "Basculer vers l'onglet 5",
+ 'view.tabSlot.6': "Basculer vers l'onglet 6",
+ 'view.tabSlot.7': "Basculer vers l'onglet 7",
+ 'view.tabSlot.8': "Basculer vers l'onglet 8",
+ 'view.tabSlot.9': "Basculer vers l'onglet 9",
'appearance.toggleMode': 'Basculer clair / sombre',
'profile.default': 'Basculer vers le profil par défaut',
'profile.switch.1': 'Basculer vers le profil 1',
diff --git a/apps/desktop/src/lib/keybinds/actions.test.ts b/apps/desktop/src/lib/keybinds/actions.test.ts
index cbafe8ab09c..9b595672305 100644
--- a/apps/desktop/src/lib/keybinds/actions.test.ts
+++ b/apps/desktop/src/lib/keybinds/actions.test.ts
@@ -86,3 +86,30 @@ describe('KEYBIND_ACTIONS', () => {
}
})
})
+
+describe('profile.switch.N vs view.tabSlot.N (#92569)', () => {
+ it('profile switchers claim ⌘1…⌘9; tab-slot actions ship unbound', () => {
+ // The bug: the profile handler dispatched tab-first, so open session
+ // tabs silently ate ⌘1…⌘9 and rebinding the chord could not change the
+ // semantics. The contract now: profile.switch.N owns the mod+N defaults
+ // unconditionally, and positional tab switching is its own action with
+ // no default chord.
+ for (let slot = 1; slot <= 9; slot += 1) {
+ expect(defaultBindings()[`profile.switch.${slot}`]).toContain(`mod+${slot}`)
+ expect(keybindAction(`view.tabSlot.${slot}`)).toMatchObject({ category: 'view', defaults: [] })
+ expect(defaultBindings()[`view.tabSlot.${slot}`]).toEqual([])
+ }
+ })
+
+ it('tab-slot actions precede profile switchers so a rebind wins the combo race', () => {
+ // defaultBindings builds its combo index in KEYBIND_ACTIONS order; a
+ // user binding mod+2 to view.tabSlot.2 must win over profile.switch.2's
+ // default claim of the same combo — first action to claim it wins.
+ const ids = KEYBIND_ACTIONS.map(action => action.id)
+ const firstTabSlot = ids.indexOf('view.tabSlot.1')
+ const firstProfileSwitch = ids.indexOf('profile.switch.1')
+
+ expect(firstTabSlot).toBeGreaterThanOrEqual(0)
+ expect(firstProfileSwitch).toBeGreaterThan(firstTabSlot)
+ })
+})
diff --git a/apps/desktop/src/lib/keybinds/actions.ts b/apps/desktop/src/lib/keybinds/actions.ts
index cbe2344401a..b5608b7c88b 100644
--- a/apps/desktop/src/lib/keybinds/actions.ts
+++ b/apps/desktop/src/lib/keybinds/actions.ts
@@ -44,6 +44,17 @@ const PROFILE_SWITCH_ACTIONS: KeybindActionMeta[] = Array.from({ length: PROFILE
defaults: [comboForSlot(i + 1)]
}))
+// Positional tab-slot jumps — activate the Nth visible tab in the focused
+// zone's tab strip. No default chords: ⌘1…⌘9 belong to profile switching
+// (#92569), and users who want positional tabs can bind chords in the panel.
+export const TAB_SLOT_COUNT = 9
+
+const TAB_SLOT_ACTIONS: KeybindActionMeta[] = Array.from({ length: TAB_SLOT_COUNT }, (_, i) => ({
+ id: `view.tabSlot.${i + 1}`,
+ category: 'view' as const,
+ defaults: []
+}))
+
// Positional jumps — ^1…^9, mirroring profiles' ⌘1…⌘9.
export const SESSION_SLOT_COUNT = 9
@@ -71,6 +82,9 @@ export const KEYBIND_ACTIONS: readonly KeybindActionMeta[] = [
{ id: 'composer.dictate', category: 'composer', defaults: [] },
// ── Profiles ─────────────────────────────────────────────────────────────
+ // Tab-slot actions BEFORE profile switchers so a user rebinding a chord to
+ // a tab slot wins the combo-index race (first action to claim a combo wins).
+ ...TAB_SLOT_ACTIONS,
{ id: 'profile.default', category: 'profiles', defaults: ['mod+d'] },
...PROFILE_SWITCH_ACTIONS,
{ id: 'profile.next', category: 'profiles', defaults: ['mod+shift+]'] },