Skip to content

feat: Add switch to org button on plan usage screen#2366

Open
charlesvien wants to merge 4 commits into
05-25-auth_org_keyed_mapfrom
05-25-billing_switch_org_button
Open

feat: Add switch to org button on plan usage screen#2366
charlesvien wants to merge 4 commits into
05-25-auth_org_keyed_mapfrom
05-25-billing_switch_org_button

Conversation

@charlesvien
Copy link
Copy Markdown
Member

@charlesvien charlesvien commented May 25, 2026

Problem

PlanUsageSettings detected hasBetterPlanElsewhere and showed a callout but offered no way to actually switch to the org with the better plan. The page also called client.switchOrganization directly from the renderer, bypassing the main-process auth service.

Changes

  1. Add a "Switch to {org}" button to the hasBetterPlanElsewhere callout
  2. Route every renderer org switch through useSwitchOrgMutation so AuthService.switchOrg is the single canonical path
  3. Refetch the seat with autoProvision: true after the switch so the Pro card reflects the new active org
  4. Show a red error callout when the switch fails, with a ?? "Pro org" fallback when the API omits the org name

How did you test this?

manually

Publish to changelog?

no

Copy link
Copy Markdown
Member Author

charlesvien commented May 25, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@charlesvien charlesvien changed the title add switch to org button on plan usage screen feat: Add switch to org button on plan usage screen May 25, 2026
@charlesvien charlesvien marked this pull request as ready for review May 26, 2026 01:08
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 26, 2026

T-Rex T-Rex Logs

What T-Rex did

  • Reviewed the changed plan usage flow around organization switching and billing links.
  • Verified that same-org billing links skip the switch path before opening billing.
  • Verified that a successful callout switch refetches the seat with autoProvision: true.
  • Checked the switch mutation state shared by the callout and billing buttons.
Artifacts

Plan usage switch-org analysis

  • The notes analyze plan usage flow, organization switching, and billing link behavior.

T-Rex Ran code and verified through T-Rex

Comments Outside Diff (1)

  1. apps/code/src/renderer/features/settings/components/sections/PlanUsageSettings.tsx, line 380 (link)

    P1 Block duplicate switches

    The billing Open button is disabled only when billingUrl is missing, so it can still be clicked while an organization switch is already in flight. That starts another switchOrg mutation while the first one is resetting session state and refreshing auth-scoped queries. Disable the billing buttons while switchOrgMutation.isPending, matching the guard used by the existing project switcher, to avoid concurrent session resets.

    Artifacts

    Concurrent switch analysis

    • Contains supporting evidence from the run (text/markdown; charset=utf-8).

    T-Rex Ran code and verified through T-Rex

Reviews (1): Last reviewed commit: "use scoped billing url and surface switc..." | Re-trigger Greptile

@charlesvien charlesvien force-pushed the 05-25-billing_switch_org_button branch from 446682a to 89b8708 Compare May 26, 2026 01:48
@charlesvien charlesvien force-pushed the 05-25-org_switcher_submenu branch 2 times, most recently from 6670280 to 9dfa96d Compare May 26, 2026 03:08
@charlesvien charlesvien force-pushed the 05-25-billing_switch_org_button branch 2 times, most recently from 3cf4284 to 10ef24e Compare May 26, 2026 05:01
@charlesvien charlesvien force-pushed the 05-25-org_switcher_submenu branch from 9df0de6 to 7ae6bef Compare May 26, 2026 16:14
@charlesvien charlesvien force-pushed the 05-25-billing_switch_org_button branch from 10ef24e to 00f8d97 Compare May 26, 2026 16:14
@charlesvien charlesvien force-pushed the 05-25-org_switcher_submenu branch from 7ae6bef to a341041 Compare May 27, 2026 02:00
@charlesvien charlesvien force-pushed the 05-25-billing_switch_org_button branch from bbe83b1 to cf0e2a9 Compare May 27, 2026 02:00
@charlesvien charlesvien changed the base branch from 05-25-org_switcher_submenu to graphite-base/2366 May 27, 2026 02:18
@charlesvien charlesvien force-pushed the graphite-base/2366 branch from a341041 to 19f1fcb Compare May 27, 2026 02:18
@charlesvien charlesvien force-pushed the 05-25-billing_switch_org_button branch from cf0e2a9 to 16da428 Compare May 27, 2026 02:18
@charlesvien charlesvien changed the base branch from graphite-base/2366 to 05-25-auth_org_keyed_map May 27, 2026 02:18
@charlesvien charlesvien force-pushed the 05-25-billing_switch_org_button branch from 16da428 to ae6c12a Compare May 28, 2026 01:48
@charlesvien charlesvien force-pushed the 05-25-auth_org_keyed_map branch from 19f1fcb to b18b14b Compare May 28, 2026 01:48
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