diff --git a/apps/mana/apps/web/src/lib/data/scope/active-space.svelte.ts b/apps/mana/apps/web/src/lib/data/scope/active-space.svelte.ts index 41aeaff68..351171069 100644 --- a/apps/mana/apps/web/src/lib/data/scope/active-space.svelte.ts +++ b/apps/mana/apps/web/src/lib/data/scope/active-space.svelte.ts @@ -186,13 +186,22 @@ export function writeActiveSpaceHint(id: string | null): void { /** * Resolve the user's active space. Order of truth: - * 1. Server-side active member (get-active-member) — trustworthy when - * Better Auth's activeOrganizationId landed in the session. - * 2. Client-side hint from localStorage — survives cookie drops across - * page reloads in dev. If present, we call set-active to re-sync - * the server to match. + * 1. **Localstorage hint present** — we've already gone through the + * list+set-active flow on this device, so `get-active-member` is + * certain to return 200 (Better Auth's session has an + * activeOrganizationId). Call it as the source of truth (reflects + * cross-tab switches the user may have made elsewhere). + * 2. **No hint** — fresh session. `get-active-member` would return + * 400 ("active organization not found") because nothing has been + * set yet. Skip the call entirely so the network panel stays clean, + * and go straight to list + activate-Personal-or-localStorage-hint. * 3. Personal space fallback — brand-new session, no previous choice. * + * The skip-on-fresh-session optimisation eliminates the noisy 400 the + * webapp used to log on every fresh inkognito login. Functionally + * equivalent — `fetchActiveMember()` returned `null` on 400 anyway and + * we fell through to the same auto-activate path. + * * Errors captured in `lastError`; status flips to 'error'. Callers can * retry via `loadActiveSpace({ force: true })`. */ @@ -203,20 +212,25 @@ export async function loadActiveSpace(opts: { force?: boolean } = {}): Promise o.id === hintId) : null; const chosen = hinted ?? orgs.find((o) => o.type === 'personal') ?? null; diff --git a/apps/mana/apps/web/src/routes/(app)/onboarding/name/+page.svelte b/apps/mana/apps/web/src/routes/(app)/onboarding/name/+page.svelte index 748b700b8..515126aa3 100644 --- a/apps/mana/apps/web/src/routes/(app)/onboarding/name/+page.svelte +++ b/apps/mana/apps/web/src/routes/(app)/onboarding/name/+page.svelte @@ -6,6 +6,7 @@ -->