fix: wire AI-generated flow structures into editor stores

The useEditorAI hook was ignoring result.working_tree from AI responses,
so generated steps/trees never appeared in the editor. Now:
- useEditorAI calls onFlowUpdate when working_tree is present in response
- ProceduralEditorPage handles steps + intake form updates via replaceSteps
- TreeEditorPage handles tree structure updates via replaceTreeStructure
- Both stores have new bulk-replace methods for AI integration

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
chihlasm
2026-03-07 01:56:24 -05:00
parent a9251a0ee3
commit 1d1ca3f294
5 changed files with 54 additions and 3 deletions

View File

@@ -283,6 +283,9 @@ interface TreeEditorState {
syncMarkdownToTree: () => void
syncTreeToMarkdown: () => void
// Actions - AI Integration
replaceTreeStructure: (structure: TreeStructure) => void
// Actions - State
setLoading: (loading: boolean) => void
setSaving: (saving: boolean) => void
@@ -1015,6 +1018,15 @@ export const useTreeEditorStore = create<TreeEditorState>()(
}
},
// AI Integration
replaceTreeStructure: (structure: TreeStructure) => {
set((state) => {
state.treeStructure = structure
state.selectedNodeId = structure.id
state.isDirty = true
})
},
setLoading: (loading: boolean) => {
set((state) => { state.isLoading = loading })
},