Skip to content

feat(tui): show tokens per second in assistant message footer#14493

Closed
thdxr wants to merge 4 commits into
devfrom
feature/tui-assistant-tokens-per-second
Closed

feat(tui): show tokens per second in assistant message footer#14493
thdxr wants to merge 4 commits into
devfrom
feature/tui-assistant-tokens-per-second

Conversation

@thdxr
Copy link
Copy Markdown
Member

@thdxr thdxr commented Feb 20, 2026

This PR adds tokens per second (tok/s) display to the TUI assistant message footer.

Changes

  • Added index prop to AssistantMessage component to enable efficient backwards iteration through message list
  • Modified duration memo to stats memo that returns both duration and total output tokens
  • Tokens are accumulated from all assistant messages since the parent user message
  • Display format: {duration} · {tps} tok/s

Implementation

  • Single backward loop starting from current message index
  • Accumulates tokens from assistant messages between user message and current message
  • Exits immediately when parent user message is found
  • Only shows tok/s when output tokens > 0

…nses

Previously, users only saw tok/s metrics after a message completed. Now

the TUI displays live streaming speed that updates throughout the response,

giving immediate feedback on model performance.
@thdxr thdxr force-pushed the feature/tui-assistant-tokens-per-second branch from a72ec51 to 2d89c22 Compare February 21, 2026 19:13
@bxb1337
Copy link
Copy Markdown

bxb1337 commented Mar 18, 2026

this will be great. why its not merged yet?

@andrewdunndev
Copy link
Copy Markdown

Clean implementation. The backward loop from the current message index is efficient.

One edge case I hit when building something similar: the first few tokens of a response produce unstable tok/s values (small elapsed time, large variance). A minimum output token threshold before displaying (e.g., skip if output < 10 tokens) avoids showing misleading rates like "2,000 tok/s" from a single token arriving quickly.

Also, for cumulative session-level token visibility (total in/out across all turns), would that fit as a separate footer element or is per-message the intended scope?

@0serna
Copy link
Copy Markdown

0serna commented Apr 9, 2026

This would be great. are there any plans to merge these changes?

@rekram1-node
Copy link
Copy Markdown
Collaborator

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.

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.

5 participants