Skip to content

fix(ui): improve cache page header sizing and context - #835

Merged
diegosouzapw merged 2 commits into
cheaper-inference:mainfrom
tombii:fix/cache-page-ui-polish
Mar 30, 2026
Merged

diegosouzapw merged 2 commits into
cheaper-inference:mainfrom
tombii:fix/cache-page-ui-polish

Conversation

@tombii

@tombii tombii commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Match CacheStatsCard header size with other card headers (text-sm instead of text-lg)
  • Show request counts in cache hit rate label (e.g., 32.3% (116/359)) for clarity
  • Add CacheStatsCard component to cache page for cumulative prompt cache metrics

Context

Follow-up to #822. After merging, noticed the CacheStatsCard header was larger than other section headers, and the cache hit rate percentage lacked context about the total requests.

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

- Match CacheStatsCard header size with other card headers (text-sm)
- Show request counts in cache hit rate label (116/359) for clarity
- Add CacheStatsCard component to cache page for cumulative metrics

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@kilo-code-bot

kilo-code-bot Bot commented Mar 30, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • src/app/(dashboard)/dashboard/settings/components/CacheStatsCard.tsx - No issues
  • src/i18n/messages/en.json - No issues

Changes Verified

  1. useCallback optimization - fetchMetrics wrapped in useCallback for stable reference in useEffect dependency array
  2. Translation namespace - Changed from "settings" to "cache" to align with existing cache translations
  3. Auto-refresh feature - Added 10-second interval to automatically refresh cache metrics:
    • Constants: REFRESH_INTERVAL_MS = 10_000 and REFRESH_INTERVAL_SECONDS = 10
    • Proper cleanup via clearInterval in useEffect return
  4. i18n keys - All 14 new translation keys properly added to cache section:
    • cacheMetrics, withCacheControl, cachedTokensRead, cacheCreationWrite
    • cacheReuseRatio, cacheReuseRatioDesc, estCostSaved, requestsShort
    • inputShort, cachedShort, writeShort, resetting, resetMetrics, autoRefresh
  5. UI improvements - Added auto-refresh indicator and restructured header with button alongside refresh info

All changes implement the PR description correctly with no security, logic, or runtime issues detected.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request integrates the CacheStatsCard component into the cache dashboard and updates the display of cache hit rates to include request counts. Review feedback indicates that the addition of CacheStatsCard creates UI redundancy and state inconsistency because the dashboard already tracks similar metrics on a different refresh schedule. Furthermore, the component should be updated to use the translation system instead of hardcoded English strings to maintain internationalization standards.

)}

{/* Prompt Cache Metrics (cumulative with reset) */}
<CacheStatsCard />

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.

medium

Adding <CacheStatsCard /> here introduces redundant UI and inconsistent state management. The page already contains a 'Prompt Cache' section (lines 351-436) that displays similar metrics (requests, tokens, provider breakdown).

Furthermore, CacheStatsCard performs its own API fetch on mount and does not participate in the 10-second auto-refresh cycle defined in CachePage (line 163), which will lead to diverging data being displayed between the two sections over time.

Consider refactoring CacheStatsCard to accept metrics as an optional prop. If provided, it should use those metrics instead of fetching its own, allowing it to stay in sync with the page's refresh logic. You could then replace the existing inline prompt cache section with this unified component.

- Add 10s auto-refresh interval matching cache page pattern
- Replace all hardcoded English strings with translation keys
- Add 13 new i18n keys to cache namespace for metrics display
- Reorganize header layout with auto-refresh indicator and reset button

Addresses Gemini Code Assist feedback on PR cheaper-inference#835:
- Fixed internationalization (all text now uses t())
- Maintains distinct metrics (cumulative/resettable vs real-time rolling)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@diegosouzapw
diegosouzapw merged commit 397b13e into cheaper-inference:main Mar 30, 2026
11 checks passed
@tombii
tombii deleted the fix/cache-page-ui-polish branch March 31, 2026 05:57
@diegosouzapw diegosouzapw mentioned this pull request Apr 22, 2026
Poid-ZA pushed a commit to Poid-ZA/OmniRoute that referenced this pull request Aug 5, 2026
- Add 10s auto-refresh interval matching cache page pattern
- Replace all hardcoded English strings with translation keys
- Add 13 new i18n keys to cache namespace for metrics display
- Reorganize header layout with auto-refresh indicator and reset button

Addresses Gemini Code Assist feedback on PR cheaper-inference#835:
- Fixed internationalization (all text now uses t())
- Maintains distinct metrics (cumulative/resettable vs real-time rolling)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Poid-ZA pushed a commit to Poid-ZA/OmniRoute that referenced this pull request Aug 5, 2026
…i-polish

fix(ui): improve cache page header sizing and context
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
- Add 10s auto-refresh interval matching cache page pattern
- Replace all hardcoded English strings with translation keys
- Add 13 new i18n keys to cache namespace for metrics display
- Reorganize header layout with auto-refresh indicator and reset button

Addresses Gemini Code Assist feedback on PR cheaper-inference#835:
- Fixed internationalization (all text now uses t())
- Maintains distinct metrics (cumulative/resettable vs real-time rolling)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
…i-polish

fix(ui): improve cache page header sizing and context
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants