You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds metrics display to the TUI sidebar, similar pattern of showing additional information in the sidebar
These PRs may already address or partially address the cache hit rate display feature. PR #33933 in particular seems to have overlapping functionality for showing cache metrics in the UI.
heimoshuiyu
changed the title
feat(tui): show cache hit rate in sidebar
feat(tui): [v2] show cache hit rate in sidebar
Aug 14, 2026
Thanks for the PR! The cacheRate memo is a nice addition and the zero-division guard (totalInput === 0 → undefined) is handled correctly.
A couple of suggestions:
Defensive access to tokens: cacheRate() assumes current.tokens (and current.tokens.cache) always exist once a session is present. If older/persisted sessions can lack this field, this would throw inside the memo — consider current.tokens?.cache.read ?? 0 style access for safety.
Label vs. title: the PR says "cache hit rate" but the UI renders "N% cache ratio". Worth aligning on one term so docs/UI stay consistent.
Test coverage: the fixture was extended with tokens, but there's no assertion that the new "% cache ratio" text actually renders — a small test case (session with non-zero cache.read → line visible; all-zero input → hidden) would lock in the behavior.
Otherwise looks good — the <Show> gating keeps the sidebar clean when there's nothing to display.
AI code review - automated review for reference; please use your judgment.
packages/tui/src/feature-plugins/sidebar/context.tsx:19-24 - current.tokens is dereferenced without a guard (only current is checked); if older sessions or providers report no token block this throws during render. Add current.tokens?. or confirm the schema makes it required.
packages/tui/src/feature-plugins/sidebar/context.tsx:21 - denominator excludes cache.write; that is a defensible "read hit rate" definition, but the label just says "cache ratio" - consider naming it more precisely or documenting the formula since users may expect write inclusion.
Test updated for the new shape but does not assert the rendered percentage; add an assertion for e.g. input=25/read=75 -> 75% to lock the formula.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #
Type of change
What does this PR do?
Adds a cache hit rate to the sidebar so people can see how good OpenCode V2's caching really is.
How did you verify your code works?
It simply works.
Screenshots / recordings
Checklist