-
Notifications
You must be signed in to change notification settings - Fork 1
feat(tui): wire usePlanTree to DB indexer for live plan state #149
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Problem
src/tui/hooks/usePlanTree.ts has a stub implementation that always returns an empty plan array. The TUI Plans pane shows "No plans loaded" regardless of what's indexed.
Current behavior
export function usePlanTree(pollIntervalMs = 3000): PlanNode[] {
const [plans, setPlans] = useState<PlanNode[]>([]);
useEffect(() => {
setPlans([]);
const interval = setInterval(() => {
// TODO: integrate with DB indexer
}, pollIntervalMs);
return () => clearInterval(interval);
}, [pollIntervalMs]);
return plans;
}Expected behavior
The hook polls the DB indexer (or subscribes to file-watcher events) and returns a live tree of PlanNode[]. Each PlanNode contains id, name, status, and agents[] with real statuses from the agent frontmatter.
Acceptance criteria
- Hook fetches plans + agents from the SQLite DB on mount and on each poll interval
-
PlanNode.agentsreflects current agent statuses (GAP,WIP,PASS,BLOCKED) - Updates are reflected within the
pollIntervalMswindow (default 3s) - ACP
update_statuscalls trigger a re-poll (viaAcpSessionManagerstatus_updatedevent) - Hook cleans up interval on unmount (no memory leaks)
- Tests cover: empty workspace, multiple plans, status updates
Files to modify
src/tui/hooks/usePlanTree.ts— implement DB pollingsrc/tui/app.tsx— pass DB context or config to the hooktests/tui/hooks.test.ts— add tests with temp DB fixture
Related
src/indexer.ts—listPlans,listAgentsquery functionssrc/acp/session-manager.ts—status_updatedevent to trigger re-poll
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request