Skip to content

fix(tui): prioritize composer keybinds - #42384

Merged
kitlangton merged 1 commit into
v2from
contextual-keybinds
Aug 13, 2026
Merged

kitlangton merged 1 commit into
v2from
contextual-keybinds

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

What

Replace the Shell tab's hard-coded Ctrl+D interceptor with OpenTUI keymap layer priority for the full composer.

Closes #42377.

Before / After

Before: #42366 restored the default Shell kill shortcut with a raw event interceptor that recognized only literal Ctrl+D. Custom bindings and the adjacent composer navigation/Subagents layers still depended on equal-priority registration order against focused-editor bindings.

After: Composer navigation and active tab actions use contextual priority. Their configured bindings win while the composer is active, including custom bindings, without matching physical keys manually.

How

  • Give the composer navigation layer contextual priority: 1.
  • Give Shell and Subagents action layers the same priority.
  • Remove the Shell-specific raw event interceptor.
  • Extend the composer keymap test to exercise tab navigation and a custom Shell kill binding while a textarea remains focused.

Investigation

Focused rendered-component tests showed permission rejection, textual forms, autocomplete destructive actions, and ordinary non-default editor collisions already behave correctly. Lowering app.exit priority did not fix the real TUI. Applying priority to the active composer layers did.

Testing

  • bun run test test/cli/tui/composer-keymap.test.tsx from packages/tui: 3 passed
  • bun typecheck from packages/tui: passed
  • Push hook repository typecheck: 34 packages passed
  • Live PTY with termctrl against the elected service: opened composer, switched Subagents → Shell, pressed Ctrl+D, observed the shell disappear, and confirmed its ID was absent from /api/shell

Flow

flowchart LR
    Key[Configured keypress] --> Mode{Composer active?}
    Mode -- no --> Editor[Normal global/editor binding]
    Mode -- yes --> Priority[Priority 1 composer layer]
    Priority --> Action[Navigation or active-tab action]
Loading

@kitlangton
kitlangton enabled auto-merge (squash) August 13, 2026 18:01
@kitlangton
kitlangton merged commit 9fff6e2 into v2 Aug 13, 2026
10 checks passed
@kitlangton
kitlangton deleted the contextual-keybinds branch August 13, 2026 18:12
jinhuang712 pushed a commit to jinhuang712/opencode that referenced this pull request Sep 26, 2026
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.

1 participant