open-webui/src/lib/shortcuts.ts

157 lines
3.5 KiB
TypeScript
Raw Normal View History

type ShortcutRegistry = {
2025-10-18 04:32:03 +00:00
[key in Shortcut]?: {
name: string;
keys: string[];
category: string;
tooltip?: string;
2025-10-18 04:32:03 +00:00
setting?: {
id: string;
value: any;
};
};
};
export enum Shortcut {
//Chat
NEW_CHAT = 'newChat',
NEW_TEMPORARY_CHAT = 'newTemporaryChat',
DELETE_CHAT = 'deleteChat',
//Global
SEARCH = 'search',
OPEN_SETTINGS = 'openSettings',
SHOW_SHORTCUTS = 'showShortcuts',
TOGGLE_SIDEBAR = 'toggleSidebar',
CLOSE_MODAL = 'closeModal',
//Input
FOCUS_INPUT = 'focusInput',
ACCEPT_AUTOCOMPLETE = 'acceptAutocomplete',
PREVENT_FILE_CREATION = 'preventFileCreation',
NAVIGATE_PROMPT_HISTORY_UP = 'navigatePromptHistoryUp',
ATTACH_FILE = 'attachFile',
ADD_PROMPT = 'addPrompt',
TALK_TO_MODEL = 'talkToModel',
//Message
2025-10-18 04:32:03 +00:00
GENERATE_MESSAGE_PAIR = 'generateMessagePair',
REGENERATE_RESPONSE = 'regenerateResponse',
COPY_LAST_CODE_BLOCK = 'copyLastCodeBlock',
COPY_LAST_RESPONSE = 'copyLastResponse',
STOP_GENERATING = 'stopGenerating'
}
export const shortcuts: ShortcutRegistry = {
//Chat
[Shortcut.NEW_CHAT]: {
name: 'New Chat',
keys: ['mod', 'shift', 'KeyO'],
category: 'Chat'
},
[Shortcut.NEW_TEMPORARY_CHAT]: {
name: 'New Temporary Chat',
keys: ['mod', 'shift', 'Quote'],
category: 'Chat'
},
[Shortcut.DELETE_CHAT]: {
name: 'Delete Chat',
2025-10-18 04:32:03 +00:00
keys: ['mod', 'shift', 'Backspace', 'Delete'],
category: 'Chat'
},
//Global
[Shortcut.SEARCH]: {
name: 'Search',
keys: ['mod', 'KeyK'],
category: 'Global'
},
[Shortcut.OPEN_SETTINGS]: {
name: 'Open Settings',
keys: ['mod', 'Period'],
category: 'Global'
},
[Shortcut.SHOW_SHORTCUTS]: {
name: 'Show Shortcuts',
keys: ['mod', 'Slash'],
category: 'Global'
},
[Shortcut.TOGGLE_SIDEBAR]: {
name: 'Toggle Sidebar',
keys: ['mod', 'shift', 'KeyS'],
category: 'Global'
},
[Shortcut.CLOSE_MODAL]: {
name: 'Close Modal',
keys: ['Escape'],
category: 'Global'
},
//Input
[Shortcut.FOCUS_INPUT]: {
2025-10-18 04:32:03 +00:00
name: 'Focus Chat Input',
keys: ['shift', 'Escape'],
category: 'Input'
},
[Shortcut.ACCEPT_AUTOCOMPLETE]: {
name: 'Accept Autocomplete Generation\nJump to Prompt Variable',
keys: ['Tab'],
category: 'Input'
},
[Shortcut.PREVENT_FILE_CREATION]: {
name: 'Prevent File Creation',
keys: ['mod', 'shift', 'KeyV'],
category: 'Input',
tooltip: 'Only active when "Paste Large Text as File" setting is toggled on.'
},
[Shortcut.ATTACH_FILE]: {
name: 'Attach File From Knowledge',
keys: ['#'],
category: 'Input'
},
[Shortcut.ADD_PROMPT]: {
name: 'Add Custom Prompt',
keys: ['/'],
category: 'Input'
},
[Shortcut.TALK_TO_MODEL]: {
name: 'Talk to Model',
keys: ['@'],
category: 'Input'
},
//Message
2025-10-18 04:32:03 +00:00
[Shortcut.GENERATE_MESSAGE_PAIR]: {
name: 'Generate Message Pair',
keys: ['mod', 'shift', 'Enter'],
category: 'Message',
tooltip: 'Only active when the chat input is in focus.'
},
2025-10-18 04:32:03 +00:00
[Shortcut.REGENERATE_RESPONSE]: {
name: 'Regenerate Response',
keys: ['mod', 'KeyR'],
category: 'Message'
},
[Shortcut.STOP_GENERATING]: {
name: 'Stop Generating',
keys: ['Escape'],
category: 'Message',
tooltip: 'Only active when the chat input is in focus and an LLM is generating a response.'
2025-10-18 04:32:03 +00:00
},
2025-10-22 21:12:05 +00:00
[Shortcut.NAVIGATE_PROMPT_HISTORY_UP]: {
2025-10-18 04:32:03 +00:00
name: 'Edit Last Message',
keys: ['ArrowUp'],
category: 'Message',
2025-10-22 21:12:05 +00:00
tooltip: 'Only can be triggered when the chat input is in focus.'
2025-10-18 04:32:03 +00:00
},
[Shortcut.COPY_LAST_RESPONSE]: {
name: 'Copy Last Response',
keys: ['mod', 'shift', 'KeyC'],
category: 'Message'
},
2025-10-22 21:12:05 +00:00
[Shortcut.COPY_LAST_CODE_BLOCK]: {
2025-10-18 04:32:03 +00:00
name: 'Copy Last Code Block',
keys: ['mod', 'shift', 'Semicolon'],
category: 'Message'
}
2025-10-22 21:12:05 +00:00
};