feat(plugin): ui components api #6033
Draft
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.
Summary
This PR introduces a declarative UI system for plugins, allowing them to render rich, interactive components directly in the TUI.
Capabilities
Render custom UI in chat
Plugins can display styled text, layout containers, and interactive elements inline within the conversation — useful for status indicators, summaries, or custom workflows.
Interactive checklists
Users can navigate with ↑/↓/j/k and toggle items with Space, or use the mouse to select list items. Plugins receive events when items are toggled, enabling things like task selection, feature toggles, or multi-select confirmations.
Buttons with shortcuts and hover states
Clickable buttons with optional keyboard shortcuts and hover state. Buttons can emit events back to the plugin or trigger modals for additional context.
Collapsible sections
Expandable/collapsible regions for progressive disclosure — show a summary by default, expand for details.
Modals
foreground dialogs triggered by buttons, useful for settings panels, detailed views, or focused interactions that need more space.
Input replacement
Components can temporarily take over the input area for focused interactions like confirmations or selections, then restore normal input when dismissed.
Theme-aware styling
All components use semantic color tokens (text, textMuted, warning, success, etc.) that automatically adapt to the user's chosen theme.
Few examples
Replace input component with a checklist

Collapsible list (rendered inline for the example)

Inline component (not replaceInput)

Modal

Current shortcomings
Future consideration
A fluent builder API (e.g., ui.box().row().gap(1).children(...)) could make authoring plugin UIs more ergonomic than the current JSON template format. Keeping that out of scope for this PR since it's already substantial, but worth exploring as a follow-up.