Skip to content

Show DeepSeek balance in tray status and float bar - #1071

Open
aaron-he-zhu wants to merge 1 commit into
nesszer:mainfrom
aaron-he-zhu:fix/deepseek-balance-text
Open

aaron-he-zhu wants to merge 1 commit into
nesszer:mainfrom
aaron-he-zhu:fix/deepseek-balance-text

Conversation

@aaron-he-zhu

@aaron-he-zhu aaron-he-zhu commented Nov 8, 2026 •

Copy link
Copy Markdown

Summary

DeepSeek is a balance-only provider: it reports an account balance, not a quota meter. The port already labels its lanes Balance/Balance, but the balance leaked into percent surfaces as a meaningless 0 % used / 100 % used meter (seen in the float bar and tray status). This ports upstream's balanceOnly metadata and shows the reported balance text where those surfaces would otherwise render a percentage.

Before: DeepSeek: 100% left in the tray status / float-bar pill.
After: DeepSeek: ¥231.01 in the tray status and ¥231.01 in the float-bar pill.

What changed

  • ProviderId / spec: new balance_only flag (upstream ProviderMetadata.balanceOnly), set for DeepSeek, exposed as ProviderId::is_balance_only().
  • DeepSeek provider: the primary window description is now the short balance text (¥231.01, $3.50, $0.00 - add credits, or the unavailable wording). Paid/Granted move to Paid/Granted display details so the card keeps that breakdown.
  • Tray status: new balance_only_status_text helper in tray_presentation; metric_status_label prefers it. It applies only when the provider declares balance_only and its headline window has no quota length or reset (a real metered window keeps its percentage).
  • Float bar: the bridge snapshot gains an optional balanceText (computed with the same helper); the float-bar pill shows it instead of the fake percentage and keeps the neutral tone. Pill title reads DeepSeek: ¥231.01.
  • Proof: new floatbar-deepseek-balance browser-proof scenario and synthetic deepseek-balance fixture; screenshot committed at docs/proof/deepseek-balance/floatbar.png.
  • CHANGELOG: entry under ## [Windows] Unreleased.

The tray icon keeps its availability meter (a pixel icon cannot render text); only the tray status text and the float bar show the balance. A provider that reports a real quota length or reset keeps its percentage.

CircleCI does not run for fork PRs (see CONTRIBUTING); the checks below were run locally on the fork head.

Tests

Commands run on Windows 11 26300 (zh-CN), Rust 1.98.0, Node v24.22.1, pnpm 11.25.0, MSVC 14.44:

cargo fmt --all --check                                   # pass
cargo clippy --workspace --all-targets -- -D warnings     # pass
cargo test --workspace                                    # 5563 passed, 4 failed (see note)
cargo test -p codexbar --lib providers::deepseek          # 43 passed
pnpm --dir apps/desktop-tauri run lint                    # pass (16 pre-existing warnings, 0 errors)
pnpm --dir apps/desktop-tauri run build                   # pass
pnpm --dir apps/desktop-tauri exec vitest run src/floatbar/FloatBar.display.test.tsx src/floatbar/FloatBar.test.tsx src/types/bridge.test.ts   # 67 passed
pnpm --dir apps/desktop-tauri test                        # 1719 passed, 11 failed (see note)

Notes on the failures, none in files touched by this change:

  • The 4 cargo test --workspace failures are all cost_scanner::codex::tests::codex_auto_review::* (pricing-completeness expectations in the cost scanner). They reproduce in this environment independent of this diff.
  • The 11 Vitest failures are locale/currency-formatting assertions (currency.test.ts, UsageSpendTrendPanel, QuotaBurndownChart, TrayPanel spend totals) that assume an en-US host; this Windows host reports zh-CN, so Intl renders US$4.25 / Chinese dates. All 67 tests covering the changed code pass.
  • pnpm proof:check --only floatbar could not complete in this environment: its headless Edge CDP run reports surface never became ready for both floatbar scenarios (the same page and fixture render fine when loaded directly in headless Chromium, and the proof build type-checks). Equivalent manual proof was captured instead (below).

Proof

docs/proof/deepseek-balance/floatbar.png — Chromium (headless Edge, mocked IPC) at 520×120 for ?window=floatbar&fixture=deepseek-balance, showing the pill ¥231.01 instead of a percentage.

Float bar shows ¥231.01 instead of a percentage

CUA/native tray proof was not captured: no CUA driver is installed in this environment, and floatbar is not a CODEXBAR_PROOF_MODE surface (the harness supports main, settings:*, flyout). The real tray/float-bar rendering should still be spot-checked on a native Windows desktop before merge; the change is webview content (pill label) plus provider data, and the browser proof above exercises the same React component and bridge payload.

Links

  • Upstream balance-only metadata and menu-bar balance display: Sources/CodexBarCore/Providers/DeepSeek/DeepSeekProviderDescriptor.swift (balanceOnly, usesDetailBackedWindow) and Sources/CodexBar/Menu/MenuBarLayout.swift (MenuBarDisplayText.deepSeekBalanceText).

Summary by CodeRabbit

  • New Features
    • DeepSeek balances now appear as currency amounts in the tray status and float bar instead of usage percentages.
    • Paid and granted credit amounts remain available as separate details.
    • When no balance is available, the status shows a brief balance-unavailable message.

DeepSeek is a balance-only provider, but the port rendered its balance as a
fake 0%/100% quota meter in the tray status and float bar. Port upstream's
balanceOnly metadata, keep the short balance text in the headline window
description, move Paid/Granted to display details, and let the tray status and
float bar show the balance text instead of a percentage.

Adds a browser-proof fixture/scenario for the float bar.
@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

DeepSeek balance data now includes display text and separate Paid and Granted details. The bridge exposes eligible balance text to the tray and float bar. The float bar displays balance text instead of a percentage for single-metric providers.

Changes: DeepSeek Balance Display

Layer / File(s) Summary
DeepSeek balance data
rust/src/providers/deepseek/*
DeepSeek results now provide Paid and Granted as separate display details. The balance description shows the total balance or a short zero-balance or unavailable message. Tests verify the updated descriptions and details.
Balance-only provider status
rust/src/core/provider/*, apps/desktop-tauri/src-tauri/src/commands/bridge.rs, apps/desktop-tauri/src-tauri/src/tray_presentation*
The provider registry marks DeepSeek as balance-only. The bridge derives balance text for eligible snapshots. Tray presentation uses the reset description when the headline has no duration or reset timestamp.
Float bar balance display
apps/desktop-tauri/src/types/bridge/usage.ts, apps/desktop-tauri/src/floatbar/FloatBar*, apps/desktop-tauri/src/test/floatBarHarness.tsx
The usage snapshot type and test helper support optional balance text. A single-metric float bar pill shows balance text in place of a percentage and uses it in the tooltip.
Proof scenario and changelog
apps/desktop-tauri/src/proof/fixtures/scenarios.ts, apps/desktop-tauri/scripts/proof-scenarios.json, CHANGELOG.md
The proof scenario checks the DeepSeek balance pill and captures a screenshot. The changelog describes the balance display and retained Paid/Granted details.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant DeepSeekProvider
  participant Bridge
  participant TrayPresentation
  participant FloatBar
  DeepSeekProvider->>Bridge: Balance snapshot and Paid/Granted details
  Bridge->>TrayPresentation: Snapshot with derived balance text
  Bridge->>FloatBar: Usage snapshot with balanceText
  TrayPresentation->>TrayPresentation: Select balance text for eligible headline
  FloatBar->>FloatBar: Display balance text for a single metric
Loading

Suggested reviewers: finesssee

Merge Risk: Minimal · up to f5ce4

The DeepSeek balance display is mergeable after normal checks. A Windows visual spot-check remains useful, but no specific failure is established.

Pre-merge checks: Passed 8

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "Show DeepSeek balance in tray status and float bar" matches the main change. The diff adds balance_only metadata for DeepSeek, shows its balance text in the tray status and float-bar pill i…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Provider Data Stays Siloed Passed The change derives balance text from the same provider snapshot and displays it in that provider's pill. The shared runtime code uses provider metadata rather than branching on specific ProviderId v…
Secrets Handled Safely Passed The changed balance text uses numeric balance values and fixed currency symbols. The proof fixture uses synthetic values. The diff does not add credential logging, plaintext credential storage, or cre…
No Unapproved Dependencies Passed The PR changes no Cargo.toml or package.json files and adds no npm or yarn lockfiles. It does not change the pinned pnpm packageManager version.
Ui Changes Include Windows Proof Passed The PR changes visible float-bar and tray status text. The description reports a Windows build and includes a screenshot and browser proof note for the float bar. It also states that native tray proof…
Full details: Title check

Explanation

The title "Show DeepSeek balance in tray status and float bar" matches the main change. The diff adds balance_only metadata for DeepSeek, shows its balance text in the tray status and float-bar pill instead of a percentage, and moves Paid/Granted into display details. The title does not follow the configured requirement for a short imperative summary with a prefix-style example, but the requirement is an example style and the title is an imperative phrase. It is specific and accurate.

Full details: Provider Data Stays Siloed

Explanation

The change derives balance text from the same provider snapshot and displays it in that provider's pill. The shared runtime code uses provider metadata rather than branching on specific ProviderId values. The new ProviderId::DeepSeek comparison is in a registry unit test, not shared runtime code.

Full details: Secrets Handled Safely

Explanation

The changed balance text uses numeric balance values and fixed currency symbols. The proof fixture uses synthetic values. The diff does not add credential logging, plaintext credential storage, or credential deletion.

Full details: Ui Changes Include Windows Proof

Explanation

The PR changes visible float-bar and tray status text. The description reports a Windows build and includes a screenshot and browser proof note for the float bar. It also states that native tray proof was not captured.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Tip

🎯 Customize your risk assessments

Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.

✅ Automatic approvals, with your rules

Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between fd06294 and f5ce494.

Files ignored due to path filters: 1

  • docs/proof/deepseek-balance/floatbar.png is excluded by !**/*.png
Files selected for processing: 15

  • CHANGELOG.md
  • apps/desktop-tauri/scripts/proof-scenarios.json
  • apps/desktop-tauri/src-tauri/src/commands/bridge.rs
  • apps/desktop-tauri/src-tauri/src/tray_presentation.rs
  • apps/desktop-tauri/src-tauri/src/tray_presentation_tests.rs
  • apps/desktop-tauri/src/floatbar/FloatBar.display.test.tsx
  • apps/desktop-tauri/src/floatbar/FloatBar.tsx
  • apps/desktop-tauri/src/proof/fixtures/scenarios.ts
  • apps/desktop-tauri/src/test/floatBarHarness.tsx
  • apps/desktop-tauri/src/types/bridge/usage.ts
  • rust/src/core/provider/id.rs
  • rust/src/core/provider/spec.rs
  • rust/src/providers/deepseek/mod.rs
  • rust/src/providers/deepseek/platform_balance_tests.rs
  • rust/src/providers/deepseek/tests.rs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

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.

1 participant