fix(l1): actually wire Tasks 14-15 (prior commit ad9c4c8 was committed broken)

ad9c4c8 committed with TSC_EXIT=2 (I batched the commit with its own failing
verification). Two regressions, now fixed and tsc -b + eslint verified (TSC=0,
ESLINT=0):
- L1WalkTreeVariant.tsx: the ai_build JSX branch referenced isAiBuild/node/
  nodeLoading/nodeError/advanceNode/isTerminalNode that were never declared (the
  import + state Edits had silently failed). Add the import (useEffect/useCallback,
  TreeNode) and the state/effect/advanceNode/isTerminalNode block.
- L1Dashboard.tsx: had reverted to the original (no dispatch). Re-add outcome
  dispatch as minimal edits on the real page (matched/build->walker; suggest->
  use-flow/build-new; out_of_scope->escalate-without-walk).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-30 20:24:44 -04:00
parent c547d2f834
commit 076a9ec98d
2 changed files with 197 additions and 9 deletions

View File

@@ -1,8 +1,8 @@
import { useState } from 'react'
import { useState, useEffect, useCallback } from 'react'
import { ChevronLeft } from 'lucide-react'
import { Link } from 'react-router-dom'
import { l1Api } from '@/api/l1'
import type { WalkSession } from '@/types/l1'
import type { TreeNode, WalkSession } from '@/types/l1'
import { EscalateModal, ResolveModal } from '@/components/l1/WalkModals'
interface Props {
@@ -16,6 +16,59 @@ export function L1WalkTreeVariant({ session, onSessionUpdate, onDone }: Props) {
const [showEscalate, setShowEscalate] = useState(false)
const [note, setNote] = useState('')
// Phase 2A: ai_build sessions are walked node-by-node against /next-node
// (real AI-generated decision tree), not the synthetic stepping below.
const isAiBuild = session.session_kind === 'ai_build'
const [node, setNode] = useState<TreeNode | null>(null)
const [nodeLoading, setNodeLoading] = useState(false)
const [nodeError, setNodeError] = useState<string | null>(null)
useEffect(() => {
if (!isAiBuild || session.status !== 'active') return
let cancelled = false
setNodeLoading(true)
l1Api
.nextNode(session.id, {})
.then((r) => {
if (!cancelled) setNode(r.node)
})
.catch(() => {
if (!cancelled) setNodeError('Could not generate the next step.')
})
.finally(() => {
if (!cancelled) setNodeLoading(false)
})
return () => {
cancelled = true
}
}, [isAiBuild, session.id, session.status])
const advanceNode = useCallback(
async (body: { answer?: 'yes' | 'no'; acknowledged?: boolean }) => {
if (!node) return
setNodeLoading(true)
setNodeError(null)
try {
const r = await l1Api.nextNode(session.id, {
node_id: node.id,
node_text: node.text,
...body,
})
setNode(r.node)
} catch {
setNodeError('Could not generate the next step.')
} finally {
setNodeLoading(false)
}
},
[node, session.id],
)
const isTerminalNode =
node?.node_type === 'resolved' ||
node?.node_type === 'escalate' ||
node?.node_type === 'needs_review'
// Phase 1: we don't have the live flow-tree fetch wired up here yet
// (the tree-navigation pages have their own loader). The walker shows the
// walked-path side panel, advance buttons stubbed for now — Phase 2 wires