From 1b42bd585daabcc00d0af5905f8c8ae7d39e0063 Mon Sep 17 00:00:00 2001 From: hsiegeln <37154749+hsiegeln@users.noreply.github.com> Date: Sun, 5 Apr 2026 10:29:03 +0200 Subject: [PATCH] fix: re-resolve tenantId when org list is enriched by OrgResolver TokenSync sets currentOrgId from fetchUserInfo (no tenantId). OrgResolver later calls setOrganizations with enriched data including tenantId. Now setOrganizations auto-resolves currentTenantId when the org is already selected. Co-Authored-By: Claude Opus 4.6 (1M context) --- ui/src/auth/useOrganization.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ui/src/auth/useOrganization.ts b/ui/src/auth/useOrganization.ts index 2b8e50f..94c2030 100644 --- a/ui/src/auth/useOrganization.ts +++ b/ui/src/auth/useOrganization.ts @@ -26,6 +26,14 @@ export const useOrgStore = create((set, get) => ({ const org = get().organizations.find((o) => o.id === orgId); set({ currentOrgId: orgId, currentTenantId: org?.tenantId ?? null }); }, - setOrganizations: (orgs) => set({ organizations: orgs }), + setOrganizations: (orgs) => { + const { currentOrgId } = get(); + const match = currentOrgId ? orgs.find((o) => o.id === currentOrgId) : null; + set({ + organizations: orgs, + // Re-resolve tenantId when org list is enriched (e.g., OrgResolver adds tenantId) + currentTenantId: match?.tenantId ?? get().currentTenantId, + }); + }, setIsPlatformAdmin: (value) => set({ isPlatformAdmin: value }), }));