Skip to content

Show TypeSafe spend and balance as a pay-as-you-go card - #1033

Merged
Finesssee merged 5 commits into
mainfrom
fix/typesafe-balance
Oct 26, 2026
Merged

Finesssee merged 5 commits into
mainfrom
fix/typesafe-balance

Conversation

@Finesssee

@Finesssee Finesssee commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

TypeSafe's card dropped the prepaid balance. Its cost was always_visible with no limit, which renders the "API spend" branch, and that branch has no balance line. Upstream shows TypeSafe with the .payAsYouGoSpend card style, the same as Soniox.

  • TypeSafe's CostSnapshot now sets .pay_as_you_go(). The card shows "Pay-as-you-go", the cycle spend (for example "September: $4.50") and "Balance: $10.00", with no bar, under every cost summary style.
  • The separate "Spent (cycle)" detail row is removed. The card already shows that spend, and upstream drops the same row (replacedDetailRows). The plan and credit rows are unchanged.
  • New test billing_is_a_pay_as_you_go_card_with_spend_and_balance.

Depends on #1030

This branch contains #1030 (fix/soniox-balance), which adds CostSnapshot.pay_as_you_go and the frontend pay-as-you-go card. Until #1030 merges, the diff here includes its changes. Merge #1030 first; this PR then reduces to the single rust/src/providers/typesafe.rs commit.

Checks

  • cargo fmt --all -- --check: clean.
  • cargo build --manifest-path rust/Cargo.toml --examples: ok.
  • cargo test --manifest-path rust/Cargo.toml --lib: 5483 passed, 0 failed, 2 ignored.
  • cargo test --manifest-path apps/desktop-tauri/src-tauri/Cargo.toml: 832 passed, 0 failed.
  • cargo clippy --all-targets -- -D warnings on both manifests: clean.

UI proof

No new desktop proof for this PR. The frontend pay-as-you-go card is unchanged from #1030, which has a desktop proof against a fake Soniox API. This PR only sets the same flag on TypeSafe's cost, and the new Rust test covers that. A TypeSafe desktop proof would need a fake of its cookie-authenticated Next.js server-action flow.

Summary by CodeRabbit

  • New Features
    • Pay-as-you-go costs now appear with a billing-period spend and, when available, a balance—without a usage bar. These costs remain visible in hidden card styles.
    • Soniox and TypeSafe usage cards now use the pay-as-you-go display, with balance details shown when available.
    • Added localized billing labels across supported languages.

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 98a3ca7 and 6c0bd98.

Files selected for processing: 22
  • apps/desktop-tauri/src-tauri/src/commands/bridge.rs
  • apps/desktop-tauri/src-tauri/src/tray_presentation_tests.rs
  • apps/desktop-tauri/src-tauri/src/usage_metric/tests.rs
  • apps/desktop-tauri/src/i18n/keyGroups/core.ts
  • apps/desktop-tauri/src/lib/cardCost.test.ts
  • apps/desktop-tauri/src/lib/cardCost.ts
  • apps/desktop-tauri/src/types/bridge/usage.ts
  • rust/src/core/usage_snapshot.rs
  • rust/src/locale.rs
  • rust/src/locale/en-US.ftl
  • rust/src/locale/es-MX.ftl
  • rust/src/locale/ja-JP.ftl
  • rust/src/locale/ko-KR.ftl
  • rust/src/locale/pt-BR.ftl
  • rust/src/locale/ru-RU.ftl
  • rust/src/locale/tr-TR.ftl
  • rust/src/locale/uk-UA.ftl
  • rust/src/locale/zh-CN.ftl
  • rust/src/locale/zh-TW.ftl
  • rust/src/providers/soniox/mod.rs
  • rust/src/providers/soniox/tests.rs
  • rust/src/providers/typesafe.rs

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

Walkthrough

Pay-as-you-go cost snapshots now carry a presentation flag through the bridge. The frontend uses the flag to render a localized period and spend, plus an optional balance. Soniox and TypeSafe snapshots set the flag.

Changes: Pay-as-you-go cost display

Layer / File(s) Summary
Provider snapshot behavior
rust/src/core/usage_snapshot.rs, rust/src/providers/soniox/*, rust/src/providers/typesafe.rs, apps/desktop-tauri/src-tauri/src/tray_presentation_tests.rs, apps/desktop-tauri/src-tauri/src/usage_metric/tests.rs
CostSnapshot adds a default-false presentation flag. Soniox and TypeSafe set the flag on their cost snapshots. Tests cover the flag and related snapshot values.
Bridge flag transport
apps/desktop-tauri/src-tauri/src/commands/bridge.rs, apps/desktop-tauri/src/types/bridge/usage.ts
The Rust bridge copies the flag from provider cost data and omits it from serialization when false. The TypeScript bridge type adds an optional payAsYouGo property.
Pay-as-you-go card rendering
apps/desktop-tauri/src/lib/cardCost.ts, apps/desktop-tauri/src/lib/cardCost.test.ts, apps/desktop-tauri/src/i18n/keyGroups/core.ts, rust/src/locale.rs, rust/src/locale/*.ftl
The frontend renders the localized period and spend, with an optional balance and no percentage bar. Locale keys and translations are added. Tests cover display styles and the missing-balance case.

Priority: Normal

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

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Soniox
  participant TypeSafe
  participant CostSnapshot
  participant ProviderUsageSnapshot
  participant CostSnapshotBridge
  participant cardCostSection
  Soniox->>CostSnapshot: marks cost snapshot pay_as_you_go
  TypeSafe->>CostSnapshot: marks cost snapshot pay_as_you_go
  CostSnapshot->>ProviderUsageSnapshot: supplies provider cost data
  ProviderUsageSnapshot->>CostSnapshotBridge: copies pay_as_you_go
  CostSnapshotBridge->>cardCostSection: provides payAsYouGo for card rendering
Loading

Possibly related PRs

Suggested reviewers: pasharm

Merge Risk: Minimal · up to 6c0bd

The pay-as-you-go display change is ready to merge after normal checks.

Pre-merge checks: Passed 7 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Ui Changes Include Windows Proof Warning The PR changes visible UI behavior in apps/desktop-tauri/src/lib/cardCost.ts: pay-as-you-go cards now show a title, spend, and balance and remain visible in hidden style. The PR description states, … Add screenshots or a proof note from a fresh Windows build to the PR description. The proof must show the changed pay-as-you-go card, including its title, spend, balance, and no usage bar.
Passed Passed checks: 7 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title is a concise imperative summary that accurately describes the main change: displaying TypeSafe spend and balance as a pay-as-you-go card.
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 PASS. The diff adds only a provider-owned pay_as_you_go presentation flag, maps each provider's own CostSnapshot into its bridge snapshot, and renders that snapshot in the same MenuCard provider…
Secrets Handled Safely Passed The reviewed diff adds only a pay-as-you-go presentation flag, UI rendering, localization, and test fixtures. Added provider code carries spend and balance values, not tokens, cookies, API keys, OAuth…
No Unapproved Dependencies Passed The authoritative PR diff changes only Rust source/locales and desktop TypeScript source/tests. It does not change any Cargo.toml or package.json, add an npm or yarn lockfile, or change a pinned pnpm …
Full details: Provider Data Stays Siloed

Explanation

PASS. The diff adds only a provider-owned pay_as_you_go presentation flag, maps each provider's own CostSnapshot into its bridge snapshot, and renders that snapshot in the same MenuCard provider context. TypeSafe and Soniox set the flag only in their provider modules. No changed addition transfers identity, plan, account label, or email, and no new shared-code branch matches a specific ProviderId.

Full details: Secrets Handled Safely

Explanation

The reviewed diff adds only a pay-as-you-go presentation flag, UI rendering, localization, and test fixtures. Added provider code carries spend and balance values, not tokens, cookies, API keys, OAuth credentials, or authorization headers. No added tracing/println/console/error logging, credential persistence, plain-text credential output, or credential-file/keyring deletion appears in the diff. The new Rust flag is explicitly skipped during core snapshot serialization, and the bridge serializes only the boolean flag.

Full details: No Unapproved Dependencies

Explanation

The authoritative PR diff changes only Rust source/locales and desktop TypeScript source/tests. It does not change any Cargo.toml or package.json, add an npm or yarn lockfile, or change a pinned pnpm packageManager version. No dependency approval is required.

Full details: Ui Changes Include Windows Proof

Explanation

The PR changes visible UI behavior in apps/desktop-tauri/src/lib/cardCost.ts: pay-as-you-go cards now show a title, spend, and balance and remain visible in hidden style. The PR description states, “No new desktop proof for this PR,” and only refers to earlier desktop proof against a fake Soniox API. It includes no screenshot or proof note from a fresh Windows build.

Resolution

Add screenshots or a proof note from a fresh Windows build to the PR description. The proof must show the changed pay-as-you-go card, including its title, spend, balance, and no usage bar.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@Finesssee

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Finesssee
Finesssee merged commit 31b10ce into main Oct 26, 2026
3 checks passed
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