This commit is contained in:
Timothy Jaeryang Baek
2026-07-27 01:03:10 -04:00
parent b40b6fd698
commit de681aa543
3 changed files with 56 additions and 1 deletions
@@ -168,10 +168,13 @@
<!-- {$i18n.t('Delete Chat')} -->
<!-- {$i18n.t('Open Model Selector')} -->
<!-- {$i18n.t('Toggle Dictation')} -->
<!-- {$i18n.t('Navigate to Previous Chat')} -->
<!-- {$i18n.t('Navigate to Next Chat')} -->
<!-- {$i18n.t('Search')} -->
<!-- {$i18n.t('Open Settings')} -->
<!-- {$i18n.t('Show Shortcuts')} -->
<!-- {$i18n.t('Toggle Sidebar')} -->
<!-- {$i18n.t('Toggle Controls')} -->
<!-- {$i18n.t('Close Modal')} -->
<!-- {$i18n.t('Focus Chat Input')} -->
<!-- {$i18n.t('Accept Autocomplete Generation\nJump to Prompt Variable')} -->
+27
View File
@@ -23,12 +23,15 @@ export enum Shortcut {
DELETE_CHAT = 'deleteChat',
OPEN_MODEL_SELECTOR = 'openModelSelector',
TOGGLE_DICTATION = 'toggleDictation',
NAVIGATE_CHAT_UP = 'navigateChatUp',
NAVIGATE_CHAT_DOWN = 'navigateChatDown',
//Global
SEARCH = 'search',
OPEN_SETTINGS = 'openSettings',
SHOW_SHORTCUTS = 'showShortcuts',
TOGGLE_SIDEBAR = 'toggleSidebar',
TOGGLE_CONTROLS = 'toggleControls',
CLOSE_MODAL = 'closeModal',
//Input
@@ -57,10 +60,13 @@ export const CONFIGURABLE_SHORTCUTS = [
Shortcut.DELETE_CHAT,
Shortcut.OPEN_MODEL_SELECTOR,
Shortcut.TOGGLE_DICTATION,
Shortcut.NAVIGATE_CHAT_UP,
Shortcut.NAVIGATE_CHAT_DOWN,
Shortcut.SEARCH,
Shortcut.OPEN_SETTINGS,
Shortcut.SHOW_SHORTCUTS,
Shortcut.TOGGLE_SIDEBAR,
Shortcut.TOGGLE_CONTROLS,
Shortcut.CLOSE_MODAL,
Shortcut.FOCUS_INPUT,
Shortcut.GENERATE_MESSAGE_PAIR,
@@ -78,10 +84,13 @@ export const DEFAULT_KEYBINDINGS: KeybindingsMap = {
[Shortcut.DELETE_CHAT]: 'Cmd+Shift+Backspace',
[Shortcut.OPEN_MODEL_SELECTOR]: 'Cmd+Shift+M',
[Shortcut.TOGGLE_DICTATION]: 'Cmd+Shift+L',
[Shortcut.NAVIGATE_CHAT_UP]: '',
[Shortcut.NAVIGATE_CHAT_DOWN]: '',
[Shortcut.SEARCH]: 'Cmd+K',
[Shortcut.OPEN_SETTINGS]: 'Cmd+.',
[Shortcut.SHOW_SHORTCUTS]: 'Cmd+/',
[Shortcut.TOGGLE_SIDEBAR]: 'Cmd+Shift+S',
[Shortcut.TOGGLE_CONTROLS]: '',
[Shortcut.CLOSE_MODAL]: 'Escape',
[Shortcut.FOCUS_INPUT]: 'Shift+Escape',
[Shortcut.GENERATE_MESSAGE_PAIR]: 'Cmd+Shift+Enter',
@@ -225,6 +234,18 @@ export const shortcuts: ShortcutRegistry = {
category: 'Chat',
configurable: true
},
[Shortcut.NAVIGATE_CHAT_UP]: {
name: 'Navigate to Previous Chat',
keys: [],
category: 'Chat',
configurable: true
},
[Shortcut.NAVIGATE_CHAT_DOWN]: {
name: 'Navigate to Next Chat',
keys: [],
category: 'Chat',
configurable: true
},
//Global
[Shortcut.SEARCH]: {
@@ -251,6 +272,12 @@ export const shortcuts: ShortcutRegistry = {
category: 'Global',
configurable: true
},
[Shortcut.TOGGLE_CONTROLS]: {
name: 'Toggle Controls',
keys: [],
category: 'Global',
configurable: true
},
[Shortcut.CLOSE_MODAL]: {
name: 'Close Modal',
keys: ['Escape'],
+26 -1
View File
@@ -38,7 +38,9 @@
showSearch,
showSidebar,
showControls,
mobile
mobile,
chatId,
chats
} from '$lib/stores';
import Sidebar from '$lib/components/layout/Sidebar.svelte';
@@ -232,6 +234,17 @@
await goto(`/auth?redirect=${encodeURIComponent(currentUrl)}`);
};
const navigateChat = async (direction: -1 | 1) => {
if (!$chats?.length) return;
const currentIndex = $chats.findIndex((chat) => chat.id === $chatId);
const nextChat = currentIndex === -1 ? $chats[0] : $chats[currentIndex + direction];
if (nextChat) {
await goto(`/c/${nextChat.id}`);
}
};
onMount(async () => {
if ($user === undefined || $user === null) {
await gotoAuth();
@@ -292,6 +305,18 @@
console.log('Shortcut triggered: TOGGLE_SIDEBAR');
event.preventDefault();
showSidebar.set(!$showSidebar);
} else if (shortcut === Shortcut.NAVIGATE_CHAT_UP) {
console.log('Shortcut triggered: NAVIGATE_CHAT_UP');
event.preventDefault();
await navigateChat(-1);
} else if (shortcut === Shortcut.NAVIGATE_CHAT_DOWN) {
console.log('Shortcut triggered: NAVIGATE_CHAT_DOWN');
event.preventDefault();
await navigateChat(1);
} else if (shortcut === Shortcut.TOGGLE_CONTROLS) {
console.log('Shortcut triggered: TOGGLE_CONTROLS');
event.preventDefault();
showControls.set(!$showControls);
} else if (shortcut === Shortcut.DELETE_CHAT) {
console.log('Shortcut triggered: DELETE_CHAT');
event.preventDefault();