Skip to content

feat(tui): make the assistant-message footer a replaceable plugin - #46562

Closed
cavokz wants to merge 4 commits into
anomalyco:devfrom
cavokz:assistant-footer-slot
Closed

cavokz wants to merge 4 commits into
anomalyco:devfrom
cavokz:assistant-footer-slot

Conversation

@cavokz

@cavokz cavokz commented Sep 1, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #46268

Type of change

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

What does this PR do?

This PR turns the per-assistant-message footer — the ▣ mode · model · duration line under each assistant message — from a hard-coded part of the session route into a plugin slot, so plugins can extend or fully replace it.

1. assistant_message_footer host slot (plugin API)
A new host slot forwards the assistant message and its parts plus two flags plugins need to render a live footer: terminal (no more content will be produced — finished, or interrupted) and last (the newest assistant message, may still be streaming).

2. Default footer shipped as the builtin plugin internal:assistant-message-footer
The hard-coded footer moves into a builtin plugin that registers at slot order: 0 and renders whenever last || terminal, preserving today's exact rendering while making it modular.

Usage
Plugins can now register their own footer (default or positive order) to stack below the default, use a negative order to stack above it, or replace the default entirely by disabling the builtin via plugin_enabled: { "internal:assistant-message-footer": false } or api.plugins.deactivate("internal:assistant-message-footer").

How did you verify your code works?

  • bun typecheck passes in packages/plugin, packages/tui, and packages/opencode.
  • bun test passes in packages/tui (197 tests), including the plugin/slots and builtin footer tests.
  • Verified manually with a local scratch footer plugin that renders live token/cache counts via api.state, stacking below the default and fully replacing it.

Screenshots / recordings

If this is a UI change, please include a screenshot or recording.

Checklist

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

Lets plugins render the per-message footer; also exposes agents on TuiState.
…ugin

Replaces the hard-coded footer with a builtin plugin that can be stacked or replaced.
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Sep 1, 2026
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@cavokz
cavokz marked this pull request as ready for review September 1, 2026 07:47
@cavokz
cavokz marked this pull request as draft September 1, 2026 08:06
@cavokz
cavokz marked this pull request as ready for review September 15, 2026 11:38

@holny holny left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read the whole thing against the current footer and ran the affected suites locally at 883499d: the footer/slots/wrap tests 21/21 and plugin-toggle 6/6 pass, tui typecheck clean.

Behavior looks preserved, which is the thing I was checking for given this moves a rendered line behind a slot: the gate is the same (last || final || aborted), duration still only computes once finish is set and not tool-calls/unknown, the model name resolves through the same provider list (the old ctx.providers() was Model.index(sync.data.provider), and Model.name takes either form), and alwaysSeparate still gets stamped on the footer box. Reusing the existing slot registry also means no new render-path machinery. The spec note on order 0 plus the plugin_enabled/deactivate takeover path is a nice touch — that's usually the part people get wrong.

Three things:

  1. state.agent doesn't seem to be used by this change — the builtin footer gets the agent color through useLocal, not the plugin api, and specs/tui-plugins.md doesn't mention the new field. It's fine if it's there for footer plugins to look up agent info, but the public TuiState is a permanent commitment, so either drop it from this PR or document it (with what a plugin is supposed to use it for).

  2. Sequencing: #46108 and #12721 (tokens per second in the response footer) and #43246 (timestamps on assistant messages) all add to this exact line. After this lands they either become footer plugins or fold into the builtin, so it's worth picking a merge order deliberately rather than letting all three rebase against a moving target.

  3. Minor: src/util/separate.ts and test/feature-plugins/assistant-message-footer.test.tsx both miss the trailing newline; a formatter run will pick that up.

On the tests: the builtin's own file stops at order + the not-last/not-terminal guard. The guard is the part that matters most, but if you want the duration and interrupted variants pinned, the captureSlot harness you already have can render them without much ceremony.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

@cavokz

cavokz commented Oct 5, 2026

Copy link
Copy Markdown
Author

I understand that the team is busy, waiting is not a problem, however getting a PR closed after one month makes one feel that it's very unlikely that any contribution can be actually be accepted.

When I chose OpenCode I thought I could contribute to it, this was the major choice factor, but if this is not true then I need to reconsider.

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.

tui: Add a per-assistant-message footer slot to the TUI plugin API

2 participants