Description
When a TUI plugin uses api.ui.DialogSelect, pressing Enter does not trigger the onSelect callback. Arrow keys work for navigation, and the visual selection indicator works, but Enter key selection is broken.
Critical Finding
Enter works in all built-in OpenCode dialogs, but NOT in plugin-rendered dialogs. This confirms the bug is specific to the plugin rendering context, not a general keyboard handling issue.
Environment
- OpenCode version: 1.4.3 (via Homebrew)
- Terminal: macOS (various terminals tested)
- Plugin: Custom TUI plugin using
api.ui.DialogSelect
Steps to Reproduce
- Create a TUI plugin that uses
api.ui.DialogSelect with options and onSelect callback
- Load the plugin via
tui.json
- Open the command palette and trigger the plugin
- Press Enter to select an option
Expected Behavior
Enter key should trigger onSelect callback with the selected option.
Actual Behavior
- Enter key does nothing in plugin dialogs
- Arrow keys work for navigation (up/down changes selection)
- Visual selection works (highlighted row is visible)
- Built-in dialogs (model selector, command palette, etc.) work correctly with Enter
Code Example
// Plugin code
api.ui.dialog.replace(() => (
api.ui.DialogSelect({
title: "Select Config File",
options: [
{ title: "Option 1", value: "opt1" },
{ title: "Option 2", value: "opt2" },
],
placeholder: "Choose...",
onSelect: (option) => {
console.log("Selected:", option.title);
// This callback never fires when pressing Enter
},
})
));
Investigation Summary
- The
useKeyboard hook from @opentui/solid is used for key handling
- In built-in dialogs,
useKeyboard handlers receive all key events including Enter
- In plugin dialogs, arrow keys are received but Enter is not
- This suggests the plugin rendering context may be intercepting or blocking Enter key events
Root Cause Hypothesis
The issue appears to be in how the plugin API (api.ui.DialogSelect) renders the component. The keyboard event handling chain may be different for plugin-rendered components compared to internal OpenCode components.
Possible causes:
- Plugin JSX elements are rendered outside the normal SolidJS context
- Event handlers registered via
useKeyboard in plugin context don't receive Enter events
- Focus management differs between internal and plugin dialogs
- The
InternalKeyHandler.emitWithPriority may not properly route Enter events to plugin components
Workaround Status
No working workaround found. Attempts to use DialogPrompt with onConfirm also failed, suggesting the issue affects all keyboard confirmation events in plugin dialogs.
Description
When a TUI plugin uses
api.ui.DialogSelect, pressing Enter does not trigger theonSelectcallback. Arrow keys work for navigation, and the visual selection indicator works, but Enter key selection is broken.Critical Finding
Enter works in all built-in OpenCode dialogs, but NOT in plugin-rendered dialogs. This confirms the bug is specific to the plugin rendering context, not a general keyboard handling issue.
Environment
api.ui.DialogSelectSteps to Reproduce
api.ui.DialogSelectwith options andonSelectcallbacktui.jsonExpected Behavior
Enter key should trigger
onSelectcallback with the selected option.Actual Behavior
Code Example
Investigation Summary
useKeyboardhook from@opentui/solidis used for key handlinguseKeyboardhandlers receive all key events including EnterRoot Cause Hypothesis
The issue appears to be in how the plugin API (
api.ui.DialogSelect) renders the component. The keyboard event handling chain may be different for plugin-rendered components compared to internal OpenCode components.Possible causes:
useKeyboardin plugin context don't receive Enter eventsInternalKeyHandler.emitWithPrioritymay not properly route Enter events to plugin componentsWorkaround Status
No working workaround found. Attempts to use
DialogPromptwithonConfirmalso failed, suggesting the issue affects all keyboard confirmation events in plugin dialogs.