[PR #3942] fix(tui): Revamp keybinds #10813

Closed
opened 2026-02-16 18:15:33 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/3942

State: closed
Merged: No


@thdxr I have revamped the keybinds so that (almost) everything is in a central place and it's difficult to reason about the binding precedence and make changes without introducing regressions.

Most notable features:

(There are some rough edges, I'll refactor the api a bit more e.g. I think it's unnecessary to have keybind.keybinds., keybind. should suffice, things like that)

Exceptions:

  • <Prompt>'s onKeyDown passed to <textarea>. I will investigate if this can (or should) be converted to the universal keybind approach
  • The ErrorComponent in app.tsx - useKeybind is a potential point of failure, and our catch-all ErrorBoundary should have minimal features IMO

A few caveats (will address before merge):

  • Please ignore for now the fact that I separated keybind.tsx and keybind_.ts. I did that because debugging breakpoints don't work in tsx files. I will inline all of keybind_.ts into keybind.tsx before merge.
  • I haven't gotten around to fully testing permission keybind handling
  • Haven't tested those dialogs that are a bit tricky to get to display like the openrouter warning and maybe some others
  • It seems there is a bug in opentui where an <input> inserts <letter> upon receiving ctrl+<letter>. I'll investigate a bit more
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/3942 **State:** closed **Merged:** No --- @thdxr I have revamped the keybinds so that (almost) everything is in a central place and it's difficult to reason about the binding precedence and make changes without introducing regressions. Most notable features: - Centralized registry of all keybindings, which supports setting priorities to carefully control precedence: https://github.com/sst/opencode/blob/3272c849a5c9a17976cf18144512c8291fb4bf3e/packages/opencode/src/cli/cmd/tui/context/keybind.tsx#L61 - Example usage: https://github.com/sst/opencode/blob/3272c849a5c9a17976cf18144512c8291fb4bf3e/packages/opencode/src/cli/cmd/tui/ui/dialog-select.tsx#L125 (There are some rough edges, I'll refactor the api a bit more e.g. I think it's unnecessary to have `keybind.keybinds.`, `keybind.` should suffice, things like that) Exceptions: - `<Prompt>`'s `onKeyDown` passed to `<textarea>`. I will investigate if this can (or should) be converted to the universal keybind approach - The `ErrorComponent` in `app.tsx` - `useKeybind` is a potential point of failure, and our catch-all `ErrorBoundary` should have minimal features IMO A few caveats (will address before merge): - Please ignore for now the fact that I separated `keybind.tsx` and `keybind_.ts`. I did that because debugging breakpoints don't work in `tsx` files. I will inline all of `keybind_.ts` into `keybind.tsx` before merge. - I haven't gotten around to fully testing permission keybind handling - Haven't tested those dialogs that are a bit tricky to get to display like the openrouter warning and maybe some others - It seems there is a bug in opentui where an `<input>` inserts `<letter>` upon receiving `ctrl+<letter>`. I'll investigate a bit more
yindo added the pull-request label 2026-02-16 18:15:33 -05:00
yindo closed this issue 2026-02-16 18:15:33 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#10813