Skip to content

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

Open
charlesvien wants to merge 3 commits into
05-25-org_switcher_submenufrom
05-25-billing_switch_org_button
Open

feat: Add switch to org button on plan usage screen#2366
charlesvien wants to merge 3 commits into
05-25-org_switcher_submenufrom
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 from 6cc0d57 to 3cf4284 Compare May 26, 2026 03:08
@charlesvien charlesvien force-pushed the 05-25-billing_switch_org_button branch from 3cf4284 to 10ef24e Compare May 26, 2026 05:01
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