Skip to content

feat(app): show tokens-per-second in context usage indicator - #42372

Closed
894864 wants to merge 1 commit into
anomalyco:devfrom
894864:feat/context-tps
Closed

894864 wants to merge 1 commit into
anomalyco:devfrom
894864:feat/context-tps

Conversation

@894864

@894864 894864 commented Aug 13, 2026 •

Copy link
Copy Markdown

Issue for this PR

No issue filed; small UX addition to the existing context usage indicator.

Type of change

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

What does this PR do?

The context usage indicator (progress circle shown in the session header and message timeline) already shows cost, context usage % and total tokens on hover. This PR adds a tokens-per-second metric:

  • \getSessionContext\ now also computes \ ps\ for the last assistant message: output tokens divided by turn duration (\ ime.completed - time.created). It stays \undefined\ when the turn has no completion time or no output tokens, and the UI renders \–\ in that case.
  • The hover tooltip gains a \TPS\ row next to the existing cost / usage / tokens rows.
  • A small TPS number is rendered beside the circle.

I chose message-level timing (the whole assistant turn) over text-part timing because the component only has message data; this keeps the metric consistent with the other per-message rows and needs no extra data fetching.

How did you verify your code works?

  • Added 2 unit tests for \getSessionContext\ (6 pass total), covering the TPS math and the undefined fallbacks.
  • Built the desktop app locally (v1.18.5) and smoke-tested: server sidecar boots and the renderer loads with the change.

Screenshots / recordings

None — no screenshot tooling on my machine. Verified by unit tests and a local desktop build.

Checklist

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

@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 Aug 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions

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.

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.

1 participant