chat : add close-tab keyboard shortcut

Assisted-by: pi
This commit is contained in:
Aleksander Grygier
2026-08-21 15:38:46 +02:00
committed by GitHub
parent 1723443567
commit 79434c514b
2 changed files with 27 additions and 2 deletions
+3 -1
View File
@@ -16,5 +16,7 @@ export enum KeyboardKey {
O_LOWER = 'o',
O_UPPER = 'O',
SPACE = ' ',
TAB = 'Tab'
TAB = 'Tab',
X_LOWER = 'x',
X_UPPER = 'X'
}
@@ -1,5 +1,6 @@
import { page } from '$app/state';
import { KeyboardKey } from '$lib/enums';
import { conversationsStore } from '$lib/stores';
import { conversationsStore, NEW_CHAT_TAB_ID, settingsStore, tabsStore } from '$lib/stores';
interface KeyboardShortcutsCallbacks {
activateSearchMode?: () => void;
@@ -41,6 +42,28 @@ export function useKeyboardShortcuts(callbacks: KeyboardShortcutsCallbacks) {
callbacks.editActiveConversation?.();
}
if (
event.shiftKey &&
isCmdOrCtrl &&
(event.key === KeyboardKey.X_LOWER || event.key === KeyboardKey.X_UPPER)
) {
// several components register this shortcut; only let the first handler
// act so the synchronous navigation does not cascade-close every tab
if (event.defaultPrevented) return;
event.preventDefault();
// close-tab only makes sense with conversation tabs enabled
if (!settingsStore.config.conversationTabs) return;
const activeId =
page.params.id ?? (page.route.id === '/(chat)' ? NEW_CHAT_TAB_ID : undefined);
if (activeId) {
void tabsStore.close(activeId, activeId);
}
}
if (
isCmdOrCtrl &&
event.shiftKey &&