Skip to content

feat: Add switch organization to project switcher#2365

Open
charlesvien wants to merge 3 commits into
05-25-auth_org_keyed_mapfrom
05-25-org_switcher_submenu
Open

feat: Add switch organization to project switcher#2365
charlesvien wants to merge 3 commits into
05-25-auth_org_keyed_mapfrom
05-25-org_switcher_submenu

Conversation

@charlesvien
Copy link
Copy Markdown
Member

@charlesvien charlesvien commented May 25, 2026

Problem

After #2364 the renderer knows every org the user belongs to, but there is no in-app way to switch between them. Users would have to log out or change orgs in the PostHog web app.

Changes

  1. Add a "Switch organization" submenu to the bottom-left ProjectSwitcher dropdown
  2. List every org from orgProjectsMap, mark the current one, hide the submenu when there is only one org
  3. Fire useSwitchOrgMutation on click and navigate to task input on success
  4. Short-circuit when a switch is already pending or the user clicks the active org

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 organization submenu feat: add switch organization submenu May 25, 2026
@charlesvien charlesvien changed the title feat: add switch organization submenu feat: Add switch organization to project switcher 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

  • Ran the existing ProjectSwitcher organization switcher tests after the UI change; all five tests passed.
  • Added focused component-level checks for no-current-project rendering, rapid org selection, success-callback navigation ordering, and post-switch project fallback behavior.
  • Observed a wrong-org fallback in the generated checks: with currentOrgId='org-2', a stale current project, and projects from both orgs still present, the project hook selected project '1' from org-1.
  • Noted that the happy-path manual flow still works, but the stale project scenario could leave the app in the wrong organization.
Artifacts

Verbose vitest output for generated org switcher checks

  • Provides the full test run results and timing details for the generated org switcher checks.

Generated targeted org switcher tests

  • Holds the new targeted tests exercising no-current-project rendering, rapid org selection, and post-switch navigation paths.

T-Rex Ran code and verified through T-Rex

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
apps/code/src/renderer/features/sidebar/components/ProjectSwitcher.tsx:146-149
**Prevent wrong-org fallback**

When this switches orgs and navigates straight back to task input, `useProjects()` can run its fallback project selection while auth state is still settling. That hook flattens `orgProjectsMap` across every organization, so if the current project is stale or missing after switching to `org-2`, it can call `selectProject` for the first project from `org-1`. The main auth service then moves `currentOrgId` back to the org that owns that project, leaving the user in the wrong organization. Please constrain the fallback to the selected org, or wait/gate navigation until the switched org's project state is settled.

Reviews (1): Last reviewed commit: "navigate after org switch and guard doub..." | Re-trigger Greptile

@charlesvien charlesvien force-pushed the 05-25-auth_org_keyed_map branch from c8e3d0e to 1382e6f Compare May 26, 2026 01:48
@charlesvien charlesvien force-pushed the 05-25-org_switcher_submenu branch from 70022a3 to 6670280 Compare May 26, 2026 01:48
@charlesvien charlesvien force-pushed the 05-25-org_switcher_submenu branch from 6670280 to 9dfa96d Compare May 26, 2026 03:08
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