diff --git a/frontend/src/pages/TreeNavigationPage.tsx b/frontend/src/pages/TreeNavigationPage.tsx
index 1acf1f4c..ff389130 100644
--- a/frontend/src/pages/TreeNavigationPage.tsx
+++ b/frontend/src/pages/TreeNavigationPage.tsx
@@ -39,8 +39,8 @@ export function TreeNavigationPage() {
const [tree, setTree] = useState(null)
const [session, setSession] = useState(null)
- const [currentNodeId, setCurrentNodeId] = useState('root')
- const [pathTaken, setPathTaken] = useState(['root'])
+ const [currentNodeId, setCurrentNodeId] = useState('')
+ const [pathTaken, setPathTaken] = useState([])
const [decisions, setDecisions] = useState([])
const [currentStepEnteredAt, setCurrentStepEnteredAt] = useState(new Date().toISOString())
const [notes, setNotes] = useState('')
@@ -294,7 +294,7 @@ export function TreeNavigationPage() {
const sessionData = await sessionsApi.get(locationState.sessionId)
setSession(sessionData)
setPathTaken(sessionData.path_taken)
- setCurrentNodeId(sessionData.path_taken[sessionData.path_taken.length - 1] || 'root')
+ setCurrentNodeId(sessionData.path_taken[sessionData.path_taken.length - 1] || treeData.tree_structure?.id || 'root')
setDecisions(sessionData.decisions as DecisionRecord[])
setCurrentStepEnteredAt(deriveCurrentStepEnteredAt(sessionData))
customStepFlow.initCustomSteps(sessionData.custom_steps || [])
@@ -320,6 +320,10 @@ export function TreeNavigationPage() {
client_name: clientName || undefined,
})
setSession(newSession)
+ // Initialize currentNodeId to the tree's actual root (may not be 'root')
+ const rootId = tree.tree_structure?.id || 'root'
+ setCurrentNodeId(rootId)
+ setPathTaken([rootId])
setCurrentStepEnteredAt(newSession.started_at || new Date().toISOString())
setShowMetadataForm(false)
// Save for "Repeat Last Session"