From 546a334328ee0f8aa629c062a6a15057c4bb6ab7 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Wed, 22 Oct 2025 17:12:05 -0400 Subject: [PATCH] refac --- src/lib/components/chat/Chat.svelte | 7 +++ src/lib/components/chat/ShortcutItem.svelte | 10 ++-- src/lib/components/chat/ShortcutsModal.svelte | 51 ++++++------------- src/lib/shortcuts.ts | 30 ++--------- 4 files changed, 32 insertions(+), 66 deletions(-) diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index b4df96204b..cfa4680d01 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -2572,3 +2572,10 @@ {/if} + + diff --git a/src/lib/components/chat/ShortcutItem.svelte b/src/lib/components/chat/ShortcutItem.svelte index 3b6c2e3cd6..494631a984 100644 --- a/src/lib/components/chat/ShortcutItem.svelte +++ b/src/lib/components/chat/ShortcutItem.svelte @@ -47,7 +47,7 @@ } -
+
{#if shortcut.tooltip} @@ -59,13 +59,13 @@ {$i18n.t(shortcut.name)} {/if}
-
- {#each shortcut.keys.filter(key => !(key.toLowerCase() === 'delete' && shortcut.keys.includes('Backspace'))) as key} +
+ {#each shortcut.keys.filter((key) => !(key.toLowerCase() === 'delete' && shortcut.keys.includes('Backspace'))) as key}
{formatKey(key)}
{/each}
-
\ No newline at end of file +
diff --git a/src/lib/components/chat/ShortcutsModal.svelte b/src/lib/components/chat/ShortcutsModal.svelte index d5a28b46f4..1395518035 100644 --- a/src/lib/components/chat/ShortcutsModal.svelte +++ b/src/lib/components/chat/ShortcutsModal.svelte @@ -32,7 +32,7 @@ return $settings[shortcut.setting.id] === shortcut.setting.value; }); - const result = allShortcuts.reduce((acc, shortcut) => { + categorizedShortcuts = allShortcuts.reduce((acc, shortcut) => { const category = shortcut.category; if (!acc[category]) { acc[category] = []; @@ -40,59 +40,40 @@ acc[category].push(shortcut); return acc; }, {}); - - const newCategorizedShortcuts = {}; - for (const category in result) { - const half = Math.ceil(result[category].length / 2); - newCategorizedShortcuts[category] = { - left: result[category].slice(0, half), - right: result[category].slice(half) - }; - } - categorizedShortcuts = newCategorizedShortcuts; } -
-
+
+
{$i18n.t('Keyboard Shortcuts')}
- {#each Object.entries(categorizedShortcuts) as [category, columns], i} - {#if i > 0} -
-
+ {#each Object.entries(categorizedShortcuts) as [category, items], categoryIndex} + {#if categoryIndex > 0} +
+
{/if} -
-
{$i18n.t(category)}
+
+
{$i18n.t(category)}
-
+
-
- {#each columns.left as shortcut} - - {/each} -
-
- {#each columns.right as shortcut} - +
+ {#each items as shortcut} +
+ +
{/each}
{/each} - -
- {@html $i18n.t( - 'Shortcuts with an asterisk (*) are situational and only active under specific conditions.' - )} -
@@ -115,4 +96,4 @@ input[type='number'] { -moz-appearance: textfield; } - \ No newline at end of file + diff --git a/src/lib/shortcuts.ts b/src/lib/shortcuts.ts index 520e00eecf..3e8c45f70f 100644 --- a/src/lib/shortcuts.ts +++ b/src/lib/shortcuts.ts @@ -29,8 +29,6 @@ export enum Shortcut { ACCEPT_AUTOCOMPLETE = 'acceptAutocomplete', PREVENT_FILE_CREATION = 'preventFileCreation', NAVIGATE_PROMPT_HISTORY_UP = 'navigatePromptHistoryUp', - SEND_MESSAGE_NORMAL = 'sendMessageNormal', - SEND_MESSAGE_MOD = 'sendMessageMod', ATTACH_FILE = 'attachFile', ADD_PROMPT = 'addPrompt', TALK_TO_MODEL = 'talkToModel', @@ -105,26 +103,6 @@ export const shortcuts: ShortcutRegistry = { category: 'Input', tooltip: 'Only active when "Paste Large Text as File" setting is toggled on.' }, - [Shortcut.SEND_MESSAGE_NORMAL]: { - name: 'Send Message', - keys: ['Enter'], - category: 'Input', - tooltip: 'The behavior of this shortcut is determined by the "Enter Key Behavior" setting.', - setting: { - id: 'ctrlEnterToSend', - value: false - } - }, - [Shortcut.SEND_MESSAGE_MOD]: { - name: 'Send Message', - keys: ['mod', 'Enter'], - category: 'Input', - tooltip: 'The behavior of this shortcut is determined by the "Enter Key Behavior" setting.', - setting: { - id: 'ctrlEnterToSend', - value: true - } - }, [Shortcut.ATTACH_FILE]: { name: 'Attach File From Knowledge', keys: ['#'], @@ -159,20 +137,20 @@ export const shortcuts: ShortcutRegistry = { category: 'Message', tooltip: 'Only active when the chat input is in focus and an LLM is generating a response.' }, - [Shortcut.NAVIGATE_PROMPT_HISTORY_UP]: { + [Shortcut.NAVIGATE_PROMPT_HISTORY_UP]: { name: 'Edit Last Message', keys: ['ArrowUp'], category: 'Message', - tooltip: 'Only can be triggered when the chat input is in focus.' + tooltip: 'Only can be triggered when the chat input is in focus.' }, [Shortcut.COPY_LAST_RESPONSE]: { name: 'Copy Last Response', keys: ['mod', 'shift', 'KeyC'], category: 'Message' }, - [Shortcut.COPY_LAST_CODE_BLOCK]: { + [Shortcut.COPY_LAST_CODE_BLOCK]: { name: 'Copy Last Code Block', keys: ['mod', 'shift', 'Semicolon'], category: 'Message' } -}; \ No newline at end of file +};