Skip to content

feat(tui): act on clicks on the shown agent, model, IDs, usage, files and todos - #53871

Closed
Nowaker wants to merge 1 commit into
anomalyco:devfrom
Nowaker:tui-click-controls-pr
Closed

Nowaker wants to merge 1 commit into
anomalyco:devfrom
Nowaker:tui-click-controls-pr

Conversation

@Nowaker

@Nowaker Nowaker commented Oct 8, 2026 •

Copy link
Copy Markdown

Note: I'm aware v1 is now the maintenance branch and new features go to v2 only. This PR is here for others to use, and I'll submit the v2 version once I've migrated my whole plugin system to it.

Issue for this PR

Closes #48563

Also covers #40521 (click an MCP row in the sidebar to toggle it) and #13242 (click the sidebar title to rename the session); both were closed by the inactivity bot. Related: #12315, #11881.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Many parts of the TUI show something you can change, copy or open, but nothing happens when you click them, so mouse users have to remember the keybind or slash command. After this PR, clicking each of them runs the same command as its keybind, or copies what it shows:

Element Where Click
Agent name below the prompt agent picker (/agents)
Model and provider below the prompt model picker (/models)
Variant below the prompt variant picker (/variants)
tab agents below the prompt next agent, like tab
ctrl+p commands below the prompt command palette
esc interrupt below the prompt, while the agent works like esc: the first click asks for a second, a second click within 5 s interrupts
Token, context and cost usage below the prompt, sidebar Context status dialog (/status)
Directory below the prompt, sidebar footer, home footer copies the path
Model in a message footer below an answer model picker, with the model that turn ran on highlighted
Session title session sidebar rename (/rename)
Session or message ID (ses_..., msg_...) the sidebar, and text the agent or a tool wrote copies the ID
An MCP server row session sidebar connects or disconnects that server, without opening /mcps; the dot shows ⋯ until the server answers
A modified file sidebar Modified Files diff viewer (/diff) at that file
A todo sidebar Todo copies it and adds it to the end of the prompt
MCP count and /status home footer status dialog (/status)
Connect provider "Getting started" box in the sidebar provider list (/connect)

Where a command exists, the click goes through keymap.dispatchCommand, so it runs the registered command and duplicates none of its logic. The MCP toggle, its status refresh and the guard against a second toggle while one is running move from DialogMcp into local.mcp, so the dialog and the sidebar row share them. DialogModel accepts a model to highlight, and the diff route accepts a file to open at.

An ID is read back from the cells drawn under the pointer, inside the element that was clicked (ui/id-click.ts), so markdown concealment and highlighting don't matter, and the message and tool click handlers stand down when an ID is under the pointer: one click runs one action.

A click counts only when the left button is pressed and released on the same cell and no text ends up selected (ui/click.ts). Dragging across any of these elements still selects and copies text, nothing happens on hover, and the prompt's own caret clicks are unchanged. tui.mdx gets a "Clickable elements" section with the table above.

How did you verify your code works?

  • test/ui/click.test.ts covers the click guard (a same-cell click runs the action; a drag, a right click, a release without a press, or a click that leaves text selected does not). test/ui/id-click.test.ts covers reading an ID from the drawn cells. test/cli/tui/diff-viewer.test.tsx covers opening the diff viewer at a file, and fails without the change. bun typecheck and bun test pass in packages/tui (204 pass, 1 skip).
  • In an isolated TUI (scratch XDG_* dirs, a throwaway tmux socket, a local OpenAI-compatible provider with high/low variants that answers with session and message IDs and makes todo and write tool calls, and two local MCP servers, one disabled), I sent SGR mouse clicks to each element:
    • on dev, none of them did anything;
    • with this PR they opened Select agent, Select model, Select variant, Commands, Status and Rename Session; tab agents switched Build to Plan; spare Disabled showed ⋯ spare and then spare Connected, with no dialog; IDs in the answer and the sidebar copied with "Copied ses_..." / "Copied msg_..."; the directory copied; a todo copied and landed in the prompt; the footer model opened Select model on that turn's model; and the first click on esc interrupt showed "esc again to interrupt", the second ended the turn as "interrupted".
  • Dragging over the model label and over an ID in an answer still showed "Copied to clipboard" and ran nothing, and clicking inside the prompt text still moved the caret.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

This PR is AI generated, but under direct supervision and on request of @Nowaker.

… on click

The prompt's agent, model and variant, its "tab agents" and "ctrl+p
commands" hints, the sidebar session title and the sidebar MCP rows show
something a keybind or slash command acts on, but did nothing when
clicked. Each now dispatches that command through the keymap: the agent,
model and variant pickers, agent.cycle, the command palette and
session.rename. An MCP row connects or disconnects that server without
opening /mcps; the toggle, its status refresh and its in-flight guard
move from DialogMcp into local.mcp so the dialog and the row share them,
and the row's dot shows "⋯" while the server answers. The home footer's
MCP count opens /status and the sidebar's "Connect provider" opens
/connect.

ui/click.ts runs an action only for a left press and release on the
same cell that leaves no text selected, so drag-to-copy keeps working on
these elements.
@opencode-agent opencode-agent Bot closed this Oct 8, 2026
@opencode-agent

opencode-agent Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Thanks for putting this together, @Nowaker, and for the thorough description and testing notes!

v1 (the dev branch) is in maintenance mode now and only takes critical fixes (data loss, security problems, or crashes and breakage with no workaround), so this feature won't be merged there.

Clickable TUI elements still look relevant for v2. When you're ready, please open the change against the v2 branch. v2 is a separate implementation, so the change will probably need to be redone rather than ported over.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Make the model and variant labels in the TUI prompt footer clickable

1 participant