From 679653c11842f1fcb5c0f6b42cf7a6164f456d4b Mon Sep 17 00:00:00 2001 From: kcar Date: Thu, 21 May 2026 17:43:38 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20workspace=20spinner=20=E2=80=94=20use=20?= =?UTF-8?q?profile=20(not=20null=20user)=20and=20add=208s=20context=20time?= =?UTF-8?q?outs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit singlePlayerPage was using useUser().user which is always null (no setter in UserContext). This caused the redirect effect to always fire, making the workspace completely inaccessible. Fixed by destructuring profile as user, which IS properly set from the Supabase profiles query. Also added 8s timeout to NeoUserContext.switchContext call to match the NeoInstituteContext timeout fix, preventing infinite spinner if the navigation API call hangs. Co-Authored-By: Claude Sonnet 4.6 --- src/contexts/NeoUserContext.tsx | 18 ++++++++++++------ src/pages/tldraw/singlePlayerPage.tsx | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/contexts/NeoUserContext.tsx b/src/contexts/NeoUserContext.tsx index 2c92d19..ffb6ce5 100644 --- a/src/contexts/NeoUserContext.tsx +++ b/src/contexts/NeoUserContext.tsx @@ -226,13 +226,19 @@ export const NeoUserProvider: React.FC<{ children: ReactNode }> = ({ children }) // Initialize user node in profile context logger.debug('neo-user-context', '🔄 Starting context initialization'); - // Initialize user node + // Initialize user node — race against 8s timeout so spinner never hangs + const switchTimeout = new Promise((_, reject) => + setTimeout(() => reject(new Error('switchContext timed out after 8000ms')), 8000) + ) try { - await navigationStore.switchContext({ - main: 'profile', - base: 'profile', - extended: 'overview' - }, userDb, profile.school_db_name); + await Promise.race([ + navigationStore.switchContext({ + main: 'profile', + base: 'profile', + extended: 'overview' + }, userDb, profile.school_db_name), + switchTimeout + ]); const userNavigationNode = navigationStore.context.node; if (userNavigationNode?.id && userNavigationNode?.data) { diff --git a/src/pages/tldraw/singlePlayerPage.tsx b/src/pages/tldraw/singlePlayerPage.tsx index 989de8d..569269a 100644 --- a/src/pages/tldraw/singlePlayerPage.tsx +++ b/src/pages/tldraw/singlePlayerPage.tsx @@ -45,7 +45,7 @@ interface LoadingState { export default function SinglePlayerPage() { // Context hooks with initialization states - const { user, loading: userLoading } = useUser(); + const { profile: user, loading: userLoading } = useUser(); const { tldrawPreferences, initializePreferences,