From 93879024974953f10f29209a276838798fbf38c3 Mon Sep 17 00:00:00 2001 From: chihlasm Date: Tue, 10 Mar 2026 02:40:13 -0400 Subject: [PATCH] fix: pass treeData directly to startSession to avoid stale state setTree(treeData) hasn't committed when startSession runs immediately after, so tree is still null and getStepsFromTree returns []. This caused the step detail area to render empty on new session start. Co-Authored-By: Claude Opus 4.6 --- frontend/src/pages/ProceduralNavigationPage.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/pages/ProceduralNavigationPage.tsx b/frontend/src/pages/ProceduralNavigationPage.tsx index 0947c890..9184e177 100644 --- a/frontend/src/pages/ProceduralNavigationPage.tsx +++ b/frontend/src/pages/ProceduralNavigationPage.tsx @@ -185,7 +185,7 @@ export function ProceduralNavigationPage() { // Start session immediately — no intake form modal // Variables will be filled inline during execution - await startSession(id, {}) + await startSession(id, {}, treeData) } catch { toast.error('Failed to load flow') navigate('/trees') @@ -194,7 +194,7 @@ export function ProceduralNavigationPage() { } } - const startSession = async (id: string, variables: Record) => { + const startSession = async (id: string, variables: Record, treeData?: Tree) => { try { const newSession = await sessionsApi.create({ tree_id: id, @@ -203,9 +203,9 @@ export function ProceduralNavigationPage() { setSession(newSession) setSessionVariables(variables) - // Initialize step states + // Initialize step states — use passed treeData since `tree` state may not have committed yet const initialStates = new Map() - const allSteps = getStepsFromTree(tree!) + const allSteps = getStepsFromTree(treeData || tree!) for (const step of allSteps) { initialStates.set(step.id, { notes: '', verificationValue: '', completedAt: null }) }