Skip to content

feat: logs cache field - #2920

Merged
Calcium-Ion merged 4 commits into
QuantumNous:mainfrom
seefs001:feature/cache-field
Feb 11, 2026
Merged

feat: logs cache field#2920
Calcium-Ion merged 4 commits into
QuantumNous:mainfrom
seefs001:feature/cache-field

Conversation

@seefs001

@seefs001 seefs001 commented Feb 11, 2026

Copy link
Copy Markdown
Collaborator
image

Summary by CodeRabbit

  • New Features
    • Usage logs now display cache read and write token breakdowns for improved transparency into token consumption.
    • Added informational tooltip explaining that input tokens are counted excluding cached tokens, following Anthropic conventions.
    • Expanded language support with new translations across English, French, Japanese, Russian, Vietnamese, and Chinese.

@coderabbitai

coderabbitai Bot commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

This PR enhances the usage logs display to show prompt cache token metrics (cache read/write) alongside input tokens. The main component receives helper functions to compute and format cache summaries from log data, with conditional rendering for specific log types. Corresponding translation entries are added across six locale files.

Changes

Cohort / File(s) Summary
Usage Logs Component Enhancement
web/src/components/table/usage-logs/UsageLogsColumnDefs.jsx
Added internal token helper functions (toTokenNumber, formatTokenCount) and getPromptCacheSummary to extract and compute cache read/write tokens from log data. Enhanced PROMPT column with tooltip explaining non-cache input token counting and conditional rendering logic to display cache metrics for log row types 0, 2, and 5.
Internationalization Additions
web/src/i18n/locales/en.json, web/src/i18n/locales/fr.json, web/src/i18n/locales/ja.json, web/src/i18n/locales/ru.json, web/src/i18n/locales/vi.json, web/src/i18n/locales/zh-CN.json
Added four consistent translation keys across all locale files: cache read/write operation terms and an Anthropic convention note clarifying that /v1/messages input tokens exclude cached token metrics.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • feat: claude 1h cache #2155: Modifies usage-logs UI to surface cache-related token data through cache-creation fields and rendering paths in the same component structure.

Suggested reviewers

  • Calcium-Ion

Poem

🐰 Hop! The cache counts now dance in light,
Read and write tokens shimmer so bright,
Six tongues sing translations true,
Users see what flows right through!
With Anthropic's truth displayed,
No more cache doubts will fade! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: logs cache field' directly and specifically describes the main change: adding cache-related fields to usage logs display with new cache token visualization and translations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
web/src/i18n/locales/en.json (1)

2849-2852: New cache-related translation entries look correct.

Format is compliant: flat JSON with Chinese source-string keys. Translations are reasonable.

One minor concern: the key "写" ("Write") is very generic. If any other UI surface reuses the same Chinese string "写" in a non-cache context, they'll share this translation. Consider whether a more specific key (e.g., "缓存写入") would be safer — though this depends on how the rendering code in UsageLogsColumnDefs.jsx references it.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Calcium-Ion
Calcium-Ion merged commit c01bbd0 into QuantumNous:main Feb 11, 2026
1 check was pending
hardingCheng pushed a commit to hardingCheng/new-api that referenced this pull request Feb 14, 2026
* main: (21 commits)
  fix: normalize search pagination params to avoid [object Object]
  fix: ignore header passthrough during channel tests
  fix(token-search): use TrimPrefix for sk- token normalization
  fix: rename bulk test action to skip manually disabled channels
  fix: support numeric status code mapping in ResetStatusCode
  优化: 任务日志查询速度并显示用户详情 (QuantumNous#2905)
  Merge pull request QuantumNous#2916 from worryzyy/feature/add-quota-amount-input
  feat: Improve backend multilingual support
  feat: add OpenRouter pricing support to upstream ratio sync
  feat: refactor request body handling to use BodyStorage for improved efficiency
  feat(xai): 为xAI渠道添加/v1/responses支持 (QuantumNous#2897)
  chore: remove deprecated Docker badge from README
  feat: refactor extra_body handling for improved configuration parsing
  Update README
  feat: logs cache field (QuantumNous#2920)
  feat(localization): added zh_TW (QuantumNous#2913)
  fix: update README files to improve link formatting and readability
  feat: add Aion UI link to README files
  chore(deps): bump axios from 1.12.0 to 1.13.5 in /web
  simplify language selector display to use text-only labels
  ...

# Conflicts:
#	web/src/components/layout/headerbar/LanguageSelector.jsx
dreamlx pushed a commit to dreamlx/new-api that referenced this pull request Mar 3, 2026
* feat: logs cache field

* feat: logs cache field

* feat: logs cache field
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
* feat: logs cache field

* feat: logs cache field

* feat: logs cache field
@coderabbitai coderabbitai Bot mentioned this pull request Jun 21, 2026
11 tasks
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