Skip to content

fix(app): make prompt submit and newline rebindable#23430

Open
CasualDeveloper wants to merge 1 commit intoanomalyco:devfrom
CasualDeveloper:fix/16226-web-rebindable-prompt-submit
Open

fix(app): make prompt submit and newline rebindable#23430
CasualDeveloper wants to merge 1 commit intoanomalyco:devfrom
CasualDeveloper:fix/16226-web-rebindable-prompt-submit

Conversation

@CasualDeveloper
Copy link
Copy Markdown
Contributor

@CasualDeveloper CasualDeveloper commented Apr 19, 2026

Issue for this PR

Closes #16226

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Every shortcut in the web UI is rebindable via Settings → Keyboard Shortcuts — except the one users hit most: Enter / Shift+Enter in the prompt composer. prompt-input.tsx hardcodes event.key === "Enter".

This PR registers two new web commands so they auto-surface in that settings page under the existing "Prompt" group (grouping is already driven by the prompt. id prefix in settings-keybinds.tsx):

  • prompt.submit — default enter
  • prompt.newline — default shift+enter

The two Enter branches in handleKeyDown now dispatch via matchKeybind(submitKeybinds(), event) / matchKeybind(newlineKeybinds(), event) against the configured bindings. event.stopPropagation() after a match so the editor always wins over the global keymap — prevents double-fire if a user picks a modified binding like mod+enter. The IME bail and the Shift+Enter-over-IME ordering are preserved.

Defaults match the previous hardcoded behavior byte-for-byte. No new config schema, no new settings UI, no migration. Same underlying ask as #11898 and #9836. (Supersedes #23378 which was auto-closed by the compliance bot for an unchecked "tested locally" box before I had run the manual walkthrough.)

How did you verify your code works?

  • bun typecheck in packages/app — clean.
  • bun test src/i18n/parity.test.ts src/components/prompt-input/submit.test.ts — 6 passed, 0 failed.
  • Manual browser walkthrough via Chrome DevTools, driving the real composer on a built dev instance. Verified all four combinations across default and swapped bindings:
Bindings Key pressed Expected Observed
Default (submit=enter, newline=shift+enter) Shift+Enter `
` inserted in editor
✓ `hello
world` in editor innerHTML
Default Enter (empty) preventDefault, no submit ✓ editor untouched, zero network fetches
Swapped (submit=shift+enter, newline=enter) Enter `
` inserted in editor
✓ `alpha
beta` in editor innerHTML
Swapped Shift+Enter (empty) preventDefault, no submit ✓ editor untouched, zero network fetches
  • Also verified: Settings → Keyboard Shortcuts shows the new rows under the "Prompt" group; "Reset to defaults" restores `Enter` / `⇧Enter`; no accidental API submissions during any test thanks to `event.stopPropagation()` + the existing empty-content guard in `handleSubmit`.
  • AI Assistance: OpenCode + anthropic/claude-opus-4-7
  • Review: Human operator (@CasualDeveloper) directed the work and ran the browser walkthrough. Code inspected; behaviors verified via DOM assertions and fetch monitoring.

Screenshots / recordings

Before
Screenshot_2026-04-19_at_12 31 08 PM

After
Screenshot_2026-04-19_at_10 29 57 PM

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds rebindable keybind support for prompt submission vs newline insertion in the web prompt composer by introducing prompt.submit and prompt.newline commands and switching PromptInput’s Enter handling to keybind matching.

Changes:

  • Add two new command titles to the English i18n dictionary.
  • Register prompt.submit / prompt.newline commands with default bindings (Enter / Shift+Enter).
  • Update PromptInput.handleKeyDown to dispatch submit/newline via matchKeybind(...) and stop propagation on matches.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/app/src/i18n/en.ts Adds labels for the two new prompt keybind commands.
packages/app/src/components/prompt-input.tsx Registers new commands and routes Enter handling through configured keybinds.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/app/src/components/prompt-input.tsx
CasualDeveloper added a commit to CasualDeveloper/opencode that referenced this pull request Apr 19, 2026
Per Copilot review on anomalyco#23430: registering the commands with their
default Enter / Shift+Enter keybinds put them in the global command
keymap. When focus was on a non-editable target (a <button>, etc.) the
global handler would match, call preventDefault/stopPropagation, and
invoke the undefined onSelect \u2014 silently swallowing Enter across the
whole app.

`disabled: true` excludes them from `keymap()` build in
context/command.tsx while the catalog, options, and settings UI still
list them (none of those code paths filter by disabled). Local dispatch
in prompt-input.tsx is unaffected because handleKeyDown reads keybinds
directly from `settings.keybinds`, not from the registered command
option.
Register `prompt.submit` (default `enter`) and `prompt.newline`
(default `shift+enter`) as web commands so they appear in the existing
Settings → Keyboard Shortcuts UI alongside every other rebindable
shortcut. `handleKeyDown` in prompt-input.tsx now dispatches via
`matchKeybind` against the configured keybinds instead of hardcoded
`event.key === "Enter"` checks. Defaults preserve current behavior
byte-for-byte.

Related: anomalyco#16226, anomalyco#11898, anomalyco#9836
@CasualDeveloper CasualDeveloper force-pushed the fix/16226-web-rebindable-prompt-submit branch from be64e5e to b7e445b Compare April 19, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Setting to send prompt only with send button, not hitting enter.

2 participants