Skip to content

Billing & Usage: split Team vs Workspace bonus-credit balance cards - #14807

Merged
tylerlam-warp merged 8 commits into
masterfrom
factory/rev-1978-workspace-credits-box
Aug 7, 2026
Merged

tylerlam-warp merged 8 commits into
masterfrom
factory/rev-1978-workspace-credits-box

Conversation

@warp-agent-staging

@warp-agent-staging warp-agent-staging Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Client counterpart to warp-server #13973, which exposes a new
scope: BonusGrantScope! field (USER / TEAM / WORKSPACE) on the
BonusGrant GraphQL type and merges team- and workspace-scoped grants into a
single 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 scope field and splits that lumped bucket into
distinct Team and Workspace balance cards, alongside the existing Base
and Personal cards.

Changes, layer by layer:

  • GraphQL — add a BonusGrantScope cynic enum and a scope field to the
    BonusGrant fragment (crates/graphql/src/api/billing.rs), plus the enum and
    scope: BonusGrantScope! field in crates/warp_graphql_schema/api/schema.graphql.
  • Model — add a Team(WorkspaceUid) variant to the client-side
    BonusGrantScope and derive the scope from the server field in
    from_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".
  • UI — ClassifiedGrants gains a workspace bucket and
    render_balance_section renders a third Workspace credits card, reusing
    the existing render_balance_card.

Verification

  • New tests (cargo nextest run -p warp — 54 run, all pass):
    • settings_view::billing_and_usage_page_v2::tests — grants are classified
      into 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).
  • Checks: cargo build -p warp -p warp_graphql, cargo clippy -p warp -p warp_graphql --tests -- -D warnings, and ./script/format all pass.

Visual Proof

image

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.

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]>
@cla-bot cla-bot Bot added the cla-signed label Aug 6, 2026
@warp-agent-staging warp-agent-staging Bot added the warpy-factory Label associated to the "Wob the Wuilder" factory on staging, also known as Warpy Factory. label Aug 6, 2026
@warp-agent-staging
warp-agent-staging Bot marked this pull request as ready for review August 6, 2026 20:56

@warp-agent-staging warp-agent-staging Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

⚠️ [IMPORTANT] Visual proof of the Team/Workspace card split is outstanding. This is a user-facing change, but the rendered split cannot be demonstrated in this environment — it depends on the counterpart server PR #13973 (still unmerged) returning the new 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 ⚠️ (warp test build OOMs in this sandbox; leaning on green CI + author-reported 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

https://oz.staging.warp.dev/runs/019fd8de-d628-7509-8988-2fadf0ae01cd

tylerlam-warp and others added 7 commits August 6, 2026 19:02
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]>
@tylerlam-warp
tylerlam-warp merged commit e62ec07 into master Aug 7, 2026
31 checks passed
@tylerlam-warp
tylerlam-warp deleted the factory/rev-1978-workspace-credits-box branch August 7, 2026 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed warpy-factory Label associated to the "Wob the Wuilder" factory on staging, also known as Warpy Factory.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants