chat : add keyboard shortcut to jump between conversation tabs

Shift+Cmd/Ctrl+Left/Right cycles the open tabs, mirroring the existing
Shift+Cmd/Ctrl+Up/Down conversation navigation.

Assisted-by: pi
This commit is contained in:
Aleksander Grygier
2026-08-21 15:38:46 +02:00
committed by GitHub
parent bbd11affe9
commit e13011bbbd
2 changed files with 36 additions and 1 deletions
@@ -9,6 +9,8 @@ interface KeyboardShortcutsCallbacks {
deleteActiveConversation?: () => void;
navigateToPrevConversation?: () => void;
navigateToNextConversation?: () => void;
navigateToPrevTab?: () => void;
navigateToNextTab?: () => void;
toggleSidebar?: () => void;
}
@@ -82,6 +84,16 @@ export function useKeyboardShortcuts(callbacks: KeyboardShortcutsCallbacks) {
event.preventDefault();
callbacks.navigateToNextConversation?.();
}
if (isCmdOrCtrl && event.shiftKey && event.key === KeyboardKey.ARROW_LEFT) {
event.preventDefault();
callbacks.navigateToPrevTab?.();
}
if (isCmdOrCtrl && event.shiftKey && event.key === KeyboardKey.ARROW_RIGHT) {
event.preventDefault();
callbacks.navigateToNextTab?.();
}
}
return { handleKeydown };
+24 -1
View File
@@ -76,6 +76,27 @@
}
}
function navigateToTab(direction: -1 | 1) {
// only makes sense with conversation tabs enabled
if (!settingsStore.config.conversationTabs) return;
const openTabs = tabsStore.openTabs;
if (openTabs.length === 0) return;
const activeId = page.params.id ?? NEW_CHAT_TAB_ID;
const idx = openTabs.indexOf(activeId);
// active tab not in list (e.g. a non-chat route): start from an edge
const targetIdx =
idx === -1
? direction === 1
? 0
: openTabs.length - 1
: (idx + direction + openTabs.length) % openTabs.length;
void tabsStore.activate(openTabs[targetIdx]);
}
function navigateToConversation(direction: -1 | 1) {
const allConvs = conversationsStore.conversations;
@@ -120,7 +141,9 @@
const { handleKeydown } = useKeyboardShortcuts({
editActiveConversation: () => chatSidebar?.editActiveConversation?.(),
navigateToNextConversation: () => navigateToConversation(1),
navigateToPrevConversation: () => navigateToConversation(-1)
navigateToNextTab: () => navigateToTab(1),
navigateToPrevConversation: () => navigateToConversation(-1),
navigateToPrevTab: () => navigateToTab(-1)
});
function checkApiKey() {