diff --git a/packages/app/src/components/prompt-input.tsx b/packages/app/src/components/prompt-input.tsx index 156b0b3a4a22..b0112b1363b9 100644 --- a/packages/app/src/components/prompt-input.tsx +++ b/packages/app/src/components/prompt-input.tsx @@ -28,7 +28,8 @@ import { Select } from "@opencode-ai/ui/select" import { useDialog } from "@opencode-ai/ui/context/dialog" import { ModelSelectorPopover } from "@/components/dialog-select-model" import { useProviders } from "@/hooks/use-providers" -import { useCommand } from "@/context/command" +import { matchKeybind, parseKeybind, useCommand } from "@/context/command" +import { useSettings } from "@/context/settings" import { Persist, persisted } from "@/utils/persist" import { usePermission } from "@/context/permission" import { useLanguage } from "@/context/language" @@ -100,6 +101,11 @@ const EXAMPLES = [ const NON_EMPTY_TEXT = /[^\s\u200B]/ +const PROMPT_SUBMIT_ID = "prompt.submit" +const PROMPT_NEWLINE_ID = "prompt.newline" +const DEFAULT_PROMPT_SUBMIT_KEYBIND = "enter" +const DEFAULT_PROMPT_NEWLINE_KEYBIND = "shift+enter" + export const PromptInput: Component = (props) => { const sdk = useSDK() @@ -112,9 +118,42 @@ export const PromptInput: Component = (props) => { const dialog = useDialog() const providers = useProviders() const command = useCommand() + const settings = useSettings() const permission = usePermission() const language = useLanguage() const platform = usePlatform() + + // Register Enter / Shift+Enter as rebindable commands so they surface in + // the Keyboard Shortcuts settings UI (grouped under "Prompt" via the + // "prompt." id prefix). The actual dispatch stays local in handleKeyDown + // below so the editor always wins over the global keymap. + // + // `disabled: true` excludes these from the global keymap in context/command + // so a focused non-editable target (e.g. a