Skip to content

feat(app): show session prompt cache hit rate in context stats - #50154

Closed
skyzhao1223 wants to merge 1 commit into
anomalyco:devfrom
skyzhao1223:feat/cache-hit-rate
Closed

skyzhao1223 wants to merge 1 commit into
anomalyco:devfrom
skyzhao1223:feat/cache-hit-rate

Conversation

@skyzhao1223

Copy link
Copy Markdown
Contributor

Issue for this PR

Part of #42295 — the session context panel shows raw cache read/write tokens, but nothing that tells you how well prompt caching is actually working.

Type of change

  • New feature

What does this PR do?

Adds a "Cache Hit Rate (session)" row to the session context stats (desktop/web context panel). It is computed across every assistant message in the session as cache.read / (cache.read + input) rounded to a percent, and renders "—" when the session has no input-side tokens yet. The math lives in a small pure helper next to the existing session-context formatter so it can be unit tested; the panel just renders it through the existing percent formatter. Other locales fall back to English until translated.

How did you verify your code works?

  • bun test src/session/files/session-context-format.test.ts in packages/app: 5 pass (empty session, full hit, zero hit, rounding, negative totals); the whole src/session/files suite (46 tests) passes.
  • bun run typecheck (tsgo -b) in packages/app is clean.
  • Ran the app (vite dev) against a local server with real sessions and opened the context panel; the new row shows 99% for a long cached session.

Screenshots / recordings

context panel with cache hit rate

Checklist

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

@github-actions

Copy link
Copy Markdown
Contributor

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

@thdxr
thdxr changed the base branch from v2 to dev October 10, 2026 19:12
@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