diff --git a/src/lib/components/chat/MessageInput.svelte b/src/lib/components/chat/MessageInput.svelte index 45b875569d..32e55e53bb 100644 --- a/src/lib/components/chat/MessageInput.svelte +++ b/src/lib/components/chat/MessageInput.svelte @@ -2278,7 +2278,10 @@ } } - if (e.key === 'Escape') { + if ( + $settings?.keyboardShortcuts !== false && + matchKeybinding(e) === Shortcut.CLEAR_INPUT_SELECTIONS + ) { console.log('Escape'); atSelectedModel = undefined; selectedToolIds = []; diff --git a/src/lib/components/chat/Settings/Shortcuts.svelte b/src/lib/components/chat/Settings/Shortcuts.svelte index 3aeb4c1533..1a10820d6c 100644 --- a/src/lib/components/chat/Settings/Shortcuts.svelte +++ b/src/lib/components/chat/Settings/Shortcuts.svelte @@ -76,7 +76,8 @@ }; const getConflict = (id: Shortcut, chord: string): Shortcut | null => { - if (!isConfigurableShortcut(id) || !chord) return null; + // Modals always close on Esc on their own, so sharing it is not a conflict + if (!isConfigurableShortcut(id) || !chord || chord === 'Escape') return null; for (const [otherId, otherChord] of Object.entries($keybindings)) { if (otherId !== id && otherChord === chord) return otherId as Shortcut; } diff --git a/src/lib/i18n/locales/en-US/translation.json b/src/lib/i18n/locales/en-US/translation.json index d02f5e5961..241d05a90e 100644 --- a/src/lib/i18n/locales/en-US/translation.json +++ b/src/lib/i18n/locales/en-US/translation.json @@ -3391,6 +3391,8 @@ "settings.personal.shortcuts.addPrompt.label": "Add Custom Prompt", "settings.personal.shortcuts.allowToolCall.label": "Allow Tool Call", "settings.personal.shortcuts.attachFile.label": "Attach File From Knowledge", + "settings.personal.shortcuts.clearInputSelections.description": "Remove the model override, deselect tools and filters, and turn off web search, image generation, and code interpreter. Only active when the chat input is in focus.", + "settings.personal.shortcuts.clearInputSelections.label": "Clear Input Selections", "settings.personal.shortcuts.closeModal.label": "Close Modal", "settings.personal.shortcuts.command.label": "Command", "settings.personal.shortcuts.copyLastCodeBlock.label": "Copy Last Code Block", diff --git a/src/lib/shortcuts.ts b/src/lib/shortcuts.ts index b09601e862..ff3a2b92e8 100644 --- a/src/lib/shortcuts.ts +++ b/src/lib/shortcuts.ts @@ -36,6 +36,7 @@ export enum Shortcut { //Input FOCUS_INPUT = 'focusInput', + CLEAR_INPUT_SELECTIONS = 'clearInputSelections', ACCEPT_AUTOCOMPLETE = 'acceptAutocomplete', PREVENT_FILE_CREATION = 'preventFileCreation', NAVIGATE_PROMPT_HISTORY_UP = 'navigatePromptHistoryUp', @@ -71,6 +72,7 @@ export const CONFIGURABLE_SHORTCUTS = [ Shortcut.TOGGLE_CONTROLS, Shortcut.CLOSE_MODAL, Shortcut.FOCUS_INPUT, + Shortcut.CLEAR_INPUT_SELECTIONS, Shortcut.GENERATE_MESSAGE_PAIR, Shortcut.REGENERATE_RESPONSE, Shortcut.ALLOW_TOOL_CALL, @@ -97,6 +99,7 @@ export const DEFAULT_KEYBINDINGS: KeybindingsMap = { [Shortcut.TOGGLE_CONTROLS]: '', [Shortcut.CLOSE_MODAL]: 'Escape', [Shortcut.FOCUS_INPUT]: 'Shift+Escape', + [Shortcut.CLEAR_INPUT_SELECTIONS]: 'Escape', [Shortcut.GENERATE_MESSAGE_PAIR]: 'Cmd+Shift+Enter', [Shortcut.REGENERATE_RESPONSE]: 'Cmd+R', [Shortcut.ALLOW_TOOL_CALL]: 'Cmd+Alt+Enter', @@ -300,6 +303,13 @@ export const shortcuts: ShortcutRegistry = { category: 'Input', configurable: true }, + [Shortcut.CLEAR_INPUT_SELECTIONS]: { + name: (t) => t('settings.personal.shortcuts.clearInputSelections.label'), + keys: ['Escape'], + category: 'Input', + configurable: true, + tooltip: 'settings.personal.shortcuts.clearInputSelections.description' + }, [Shortcut.ACCEPT_AUTOCOMPLETE]: { name: (t) => t('settings.personal.shortcuts.acceptAutocomplete.label'), keys: ['Tab'],