feat: flexible intake — deferred variables + prepared sessions #103

Merged
chihlasm merged 3 commits from feat/flexible-intake into main 2026-03-10 13:49:51 +00:00
Showing only changes of commit 9387902497 - Show all commits

View File

@@ -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<string, string>) => {
const startSession = async (id: string, variables: Record<string, string>, 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<string, StepState>()
const allSteps = getStepsFromTree(tree!)
const allSteps = getStepsFromTree(treeData || tree!)
for (const step of allSteps) {
initialStates.set(step.id, { notes: '', verificationValue: '', completedAt: null })
}