Repository navigation
Billing & Usage: split Team vs Workspace bonus-credit balance cards - #14807
Conversation
Client counterpart to warp-server #13973, which adds a `scope: BonusGrantScope!` (USER/TEAM/WORKSPACE) field on `BonusGrant` and merges team- and workspace-scoped grants into one flat list on `Workspace.bonusGrantsInfo.grants`. Wire the new `scope` through the client GraphQL -> model -> UI layers so the Billing & Usage Balance section renders distinct Team and Workspace credit cards instead of lumping both into a single "Team credits" card: - graphql: add `BonusGrantScope` cynic enum + `scope` field on the `BonusGrant` fragment, and the enum + field in `schema.graphql`. - model: add a `Team(WorkspaceUid)` variant to the client `BonusGrantScope`, derive the scope from the server field (keeping the workspace uid from the query path), and add a `workspace_uid()` helper so per-workspace totals and the buy-credits banner count both team- and workspace-scoped grants for the current workspace (no behavior change). - ui: `ClassifiedGrants` gains a workspace bucket and `render_balance_section` renders a third "Workspace credits" card. Tests cover grant classification into the three buckets and that per-workspace totals sum team + workspace scopes. Co-Authored-By: Warp Agent <[email protected]>
There was a problem hiding this comment.
Overview
Client counterpart to warp-server #13973: wires the new scope: BonusGrantScope! field through the GraphQL → model → UI layers to split the previously-lumped "Team credits" card into distinct Team and Workspace balance cards. The code change is correct, idiomatic, and well-covered by unit tests; the one blocking gap is that the rendered UI is unverified.
Concerns
scope field and an account seeded with both team- and workspace-scoped grants, neither of which is available. The split logic is fully covered by the new ClassifiedGrants / per-workspace-total unit tests and the new card reuses the already-shipped render_balance_card path (only the label and source bucket differ), but per the visual-proof requirement a user-facing change is not fully verified until a human confirms the rendered Team and Workspace cards once #13973 is deployed. This is an external, human-resolvable block, not an implementation defect — no implementation-addressable findings were identified.
Verdict
Checks: format ✅ · build/tests cargo nextest run -p warp 54 pass, cargo build/cargo clippy -p warp -p warp_graphql --tests -- -D warnings) · CI ✅ · visual proof ❌ (outstanding, blocked on unmerged server PR #13973)
Found: 0 critical, 1 important (human-facing), 0 suggestions
Request changes — code is sound; blocking only on human confirmation of the rendered cards after #13973 deploys.
Review run
Co-Authored-By: Warp Agent <[email protected]>
Co-Authored-By: Warp Agent <[email protected]>
Co-Authored-By: Warp Agent <[email protected]>
…tors Co-Authored-By: Warp Agent <[email protected]>
…rkspace-credits-box
The helpers summing grants via BonusGrantScope::workspace_uid() cover both workspace- and team-scoped credits, so rename the functions and related variables to reflect that. Co-Authored-By: Warp Agent <[email protected]>
Rename workspace_bonus_grants and from_gql_workspace_bonus_grant to reflect that grants fetched under a workspace can be workspace- or team-scoped, and drop a redundant scope-matching comment. Co-Authored-By: Warp Agent <[email protected]>
Summary
Client counterpart to warp-server #13973, which exposes a new
scope: BonusGrantScope!field (USER/TEAM/WORKSPACE) on theBonusGrantGraphQL type and merges team- and workspace-scoped grants into asingle flat list on
Workspace.bonusGrantsInfo.grants.Previously the client derived a grant's scope purely from the query path
(
user.bonusGrants→ personal,workspace.bonusGrantsInfo.grants→ "team"),so the Billing & Usage Balance section lumped every workspace-path grant —
both team- and workspace-scoped — into one Team credits card. This PR
consumes the server's new
scopefield and splits that lumped bucket intodistinct Team and Workspace balance cards, alongside the existing Base
and Personal cards.
Changes, layer by layer:
BonusGrantScopecynic enum and ascopefield to theBonusGrantfragment (crates/graphql/src/api/billing.rs), plus the enum andscope: BonusGrantScope!field incrates/warp_graphql_schema/api/schema.graphql.Team(WorkspaceUid)variant to the client-sideBonusGrantScopeand derive the scope from the server field infrom_gql_bonus_grant(the workspace uid still comes from the query path,since the server enum carries none). A new
BonusGrantScope::workspace_uid()helper keeps per-workspace credit totals and the buy-credits banner counting
both team- and workspace-scoped grants for the current workspace, so those
consumers are unchanged. The grant-notification copy now distinguishes
"team" vs "workspace".
ClassifiedGrantsgains aworkspacebucket andrender_balance_sectionrenders a third Workspace credits card, reusingthe existing
render_balance_card.Verification
cargo nextest run -p warp— 54 run, all pass):settings_view::billing_and_usage_page_v2::tests— grants are classifiedinto personal / team / workspace buckets, grants for a different workspace
are excluded, empty buckets are hidden, and ambient/expired/depleted grants
are excluded.
ai::request_usage_model::tests::test_total_workspace_bonus_credits_counts_team_and_workspace_scopes— the current workspace's pool sums both team- and workspace-scoped grants
(regression guard for the added enum variant).
cargo build -p warp -p warp_graphql,cargo clippy -p warp -p warp_graphql --tests -- -D warnings, and./script/formatall pass.Visual Proof
CHANGELOG-IMPROVEMENT: Billing & Usage now shows separate Team and Workspace credit balances
Originating thread: https://warpdev.slack.com/archives/C0BDQDW8V5E/p1786047703502659
Conversation: https://staging.warp.dev/conversation/3ae72136-5756-48e0-97a9-0de713d85948
Run: https://oz.staging.warp.dev/runs/019fd8c3-c365-7dbe-8bcf-f438ee4c4334
This PR was generated with Oz.