Repository navigation
Closed
Labels
Description
Problem
Switching organizations, from the account menu's organization list or a /dashboard/switching link, never checks whether the switch succeeded. A refused or failed switch leaves the person on an endless "Switching organization…" spinner, and is recorded in the audit log as if it happened. The switcher also shows raw role ids and goes silently empty when its list can't load. Paths at main c94f1fd84, under services/platform/.
- A failed
setActiveis treated as success.app/routes/dashboard/switching.tsx:77-79awaitsauthClient.organization.setActive(…)and never reads its result.- The Better Auth client reports a failed request as
{ data: null, error }without throwing. The codebase says so itself (app/features/organization/components/onboarding/steps/workspace-step.tsx:146-147), andlib/auth-client.ts:59-67configures retries but nothrow. - The route then records the switch in the audit log (
recordOrgSwitch,:84-86) and navigates to the target organization (:143-155). Thecatch(:129-131) only covers thrown errors.
- The dashboard then waits forever.
app/routes/dashboard/$id.tsx:160-182retries the switch once (orgSyncRef), ignores that result too and records the switch again (:169-173).orgSyncRefis only reset in itscatch, so a returned error is never retried.- While the session's active organization differs from the URL,
isSwitching(:232-236) renders only a spinner with "Switching organization…" (:384-395). There's no error, no timeout and no way back except a manual reload. - Triggers include a refusal such as a 429, a 5xx that outlasts the client's 4 retries, or a dropped connection.
- Raw role ids. The switcher's second line is
{org.slug ? \@${org.slug} · ` : ''}{org.role}(app/features/organization/components/organization-list-panel.tsx:97-100). Every user sees "@acme · owner" or "member" in English lowercase, in every locale. The localized names exist (useRoleLabel,app/features/settings/organization/components/role-badge.tsx:12;messages/de/roles.yml`: owner → "Inhaber"), and that catalog says these are the role names "everywhere (… the account menu …)". - Empty switcher on a failed list read.
organization-list-panel.tsx:35and:59(const orgs = userOrgs ?? []): when/organizationsfails, the switcher opens empty, apart from Create organization. A member of several organizations can't switch and isn't told why.
Expected
- Check
setActive'serrorin both places, or passfetchOptions: { throw: true }. On failure, stay on, or return to, the current organization and say "Couldn't switch to {name}" with Try again. Don't record the switch. - Bound the
isSwitchingstate: after a failed or timed-out sync, show an error with Try again and a link back. - Render roles through
useRoleLabel. Show a list read error, with Try again, instead of an empty switcher.
Regression
- A switching-route test where
setActiveresolves{ error: { status: 429 } }: norecordOrgSwitchcall, and the person sees an error, not the spinner. Onc94f1fd84the audit call fires and the spinner stays. - A list-panel test renders "Inhaber" for
role: 'owner'in German.
Severity and owner
- Severity: medium. The person is stuck with no explanation, and the audit trail records a switch that didn't happen. The role labels are low.
- Owner: platform (organizations, shell).
- Found by: Review A (TALE-358), 2026-10-12 20:15 Zurich occurrence, oldest-due
org.switchUX-CLARITY slice. This is static reading atc94f1fd84, verified at the cited lines. I didn't run it, because Review A's stack is BLOCKED.
Activity
fix(platform): stop treating a refused organization switch as done