GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(app): dispatch command shortcuts through @opentui/keymap by Brendonovich · Pull Request #64394 · anomalyco/opencode

Conversation

@Brendonovich

@Brendonovich Brendonovich commented Nov 17, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Summary

Desktop and web shortcuts now run through @opentui/keymap, the engine the TUI already uses. This is the first of three stacked PRs. The next two add key chords and a leader key on top.

  • One dispatcher. A single keymap in shell/commands/keymap.ts replaces the keydown listener in command.tsx. Commands register exactly as before, and dispatch keeps its current rules:
    • The palette's keys win over other commands.
    • On shared keys, a command with a when comes first, then the user's own binding, then registration order.
    • A command can return false to pass the key on.
    • Keys that type a character don't fire in text fields unless the command is editable.
    • The ⌥ and bracket layout fallbacks still apply.
    • Shortcuts pause while a dialog is open or a shortcut is being recorded.
  • Keys during IME input. Keys are ignored while an IME is composing, including Safari's keyCode 229 case.
  • Shortcuts scoped to an element. A command can take a target element, and its keys then only fire while focus is inside it, ahead of global commands on the same keys. The first user is a new Stop session command (Escape, Ctrl+G) scoped to the prompt editor, which can now be rebound in Settings > Shortcuts.
  • The keymap is the only handler for attach and stop. The composer no longer handles ⌘U or Escape/Ctrl+G itself. file.attach and prompt.stop own those keys, so rebinding either one takes effect in the prompt too.

Shortcuts are still single key combos in this PR. Settings > Shortcuts is unchanged apart from the new Stop session row.

Feature flag

None. Shortcut behavior should be unchanged. The visible additions are the Stop session command in the palette and its row in Settings, which keep the Escape and Ctrl+G keys the prompt already used.

Stack

  1. This PR: the @opentui/keymap engine.
  2. Key chords, based on this branch.
  3. Leader key, based on the chords branch.

Validation

  • bun typecheck and lint pass in packages/app.
  • bun run test:unit (2733) and bun run test:browser (357) pass.
  • The new keymap.test.ts drives the real keymap with DOM key events. It covers dispatch order, declining commands, text fields, focus targets, IME composition, blocked shortcuts and keyboard layouts.
  • Moved coverage:
    • composer-ime.test.ts drops its three Escape rows. The contract that Escape doesn't stop a session while an IME composes is now owned by keymap.test.ts ("keys are left to the IME while it composes"), since the keymap is what stops.
    • The composer component test that checks opening the file picker keeps history browsing now opens it from the Add menu instead of ⌘U, because stories run without the command keymap. It still fails when attach() ends browsing.
  • The composer component tests pass. The shortcut-heavy e2e specs fail the same set of tests with and without this change on macOS, because those tests press Ctrl and assume Linux.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Brendonovich
feat(app): dispatch command shortcuts through @opentui/keymap
acca4c3
@Brendonovich Brendonovich mentioned this pull request Nov 17, 2026
feat(app): run shortcuts through @opentui/keymap with chords and a leader key #64393
Closed
opencodejr[bot]
opencodejr Bot reviewed Nov 17, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The keymap port looks sound apart from one regression: the palette no longer wins over other commands on its keys (see inline). The old rules for which keys fire in text fields carry over to outsideText. Stop session's skip rules give an open list, editing a queued prompt and shell mode the key first, as the editor did before.

I checked it with tsc -b, the unit tests in src/shell/commands and src/composer (328 pass) and test:browser (360 pass). I couldn't run the desktop/web app here. A small test of my own confirmed the palette problem.

Public API is unchanged: no SDK, server, plugin, config or CLI surface. Users get a new prompt.stop command they can rebind in Settings > Shortcuts, with the same default Escape and Ctrl+G keys.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/app/src/shell/commands/keymap.ts

options
.map((option, index) => ({ option, index, rank: (option.when ? 2 : 0) + (custom(option.id) ? 1 : 0) }))
.sort((a, b) => b.rank - a.rank || a.index - b.index)

@opencodejr opencodejr Bot Nov 17, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This sort undoes the palette-first order that command.tsx sets up. The palette has rank 0 (unless the user rebound it), so any command with a when, or any command the user rebound onto mod+k / mod+shift+p, now sorts ahead of it and takes the key. Before, handleKeyDown always opened the palette for its keys. I confirmed this with a quick test: command.palette plus a custom-bound x, both on mod+k, runs x. One fix is to give the palette a rank above every other command, or keep it out of the sort, so it always comes first.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Brendonovich
refactor(app): leave composer attach and stop keys to the command keymap
5c3ae7d
opencodejr[bot]
opencodejr Bot reviewed Nov 17, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The new commits look sound. The composer no longer handles ⌘U or Escape/Ctrl+G itself, and file.attach and prompt.stop now own those keys. When prompt.stop's skip declines Escape, the key still reaches the editor's own handling for an open list, an edited queued prompt and shell mode. file.attach keeps the normal-mode-only rule.

I checked it with unit tests in src/shell/commands and src/composer (328 pass), test:browser (357 pass) and tsc -b. I couldn't run the desktop/web app here.

Public API is unchanged.

The palette precedence point from my earlier review is still open: the rank sort in keymap.ts still puts commands with a when, and commands the user rebound, ahead of the palette.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Brendonovich
Brendonovich merged commit cf9d130 into dev Nov 18, 2026
12 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@Brendonovich
Brendonovich deleted the keymap-engine branch November 18, 2026 03:12
Hona added a commit that referenced this pull request Nov 18, 2026
@Hona
Merge remote-tracking branch 'origin/dev' into persisted-browser
ea13b16
command.tsx: dev dispatches command keys through @opentui/keymap (#64394) instead of the window keydown handler. The page prompt's keyboard ownership moves into the keymap's block check, which now gets the key's event: a key inside a surface registered with ownKeyboard runs no command, and keymap.test.ts pins it.
@Edo771977 Edo771977 mentioned this pull request Nov 18, 2026
chore: merge upstream/dev into the fork Edo771977/opencode#92
Merged
@thdxr thdxr mentioned this pull request Nov 20, 2026
port goal pill and stop session updates anomalyco/opencode-rune#230
Open
@Hona Hona mentioned this pull request Nov 20, 2026
feat(keymap): prompt.stop and file.attach as Desktop's commands anomalyco/opencode-rune#264
Merged
Hona added a commit to anomalyco/opencode-rune that referenced this pull request Nov 20, 2026
@Hona
feat(keymap): prompt.stop and file.attach as Desktop's commands (#264)
77cc154
Ports anomalyco/opencode#64394's commands into our one keymap table.

- prompt.stop (was session.stop): Esc and Ctrl+G in one keybind, titled Stop session under
  Session, listed in Settings > Shortcuts and the palette. A change in Settings replaces both
  keys, as Desktop's does; Escape stops only while it is still one of them. A list's Ctrl+G
  still cancels the list and its Escape stays Escape.
- A change saved under session.stop is read as prompt.stop's. Nothing saved is rewritten, so an
  older build keeps reading its own id; a prompt.stop that Desktop saved now applies here.
- file.attach is in the palette while the composer can attach (normal mode).
@BrewTestBot BrewTestBot mentioned this pull request Nov 23, 2026
opencode 2.4.0 Homebrew/homebrew-core#327368
Merged
@amrkmn amrkmn mentioned this pull request Nov 23, 2026
opencode 2.4.0 amrkmn/homebrew-tap#1251
Closed
1 task
@github-actions github-actions Bot mentioned this pull request Nov 23, 2026
feat: opencode release v2.4.0 sprisa/opencode-server#95
Merged
@scottames-github-bot scottames-github-bot Bot mentioned this pull request Nov 27, 2026
chore(deps): update ⬆️ mise-packages scottames/dots#1181
Merged
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@Brendonovich
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.