diff --git a/frontend/src/components/ai-builder/AIFlowBuilderModal.tsx b/frontend/src/components/ai-builder/AIFlowBuilderModal.tsx
index ba4d2e0a..49013055 100644
--- a/frontend/src/components/ai-builder/AIFlowBuilderModal.tsx
+++ b/frontend/src/components/ai-builder/AIFlowBuilderModal.tsx
@@ -53,27 +53,48 @@ export function AIFlowBuilderModal({ isOpen, onClose }: AIFlowBuilderModalProps)
onClose()
}
- const handleOpenInEditor = async () => {
- if (!assembledTree) return
+ const createTree = async () => {
+ if (!assembledTree) return null
try {
- const tree = await treesApi.create({
+ return await treesApi.create({
name: assembledTree.suggested_name,
description: assembledTree.suggested_description,
tree_structure: assembledTree.tree_structure,
tree_type: metadata.flow_type,
status: 'draft',
})
- handleClose()
- const editorPath =
- metadata.flow_type === 'procedural'
- ? `/flows/${tree.id}/edit`
- : `/trees/${tree.id}/edit`
- navigate(editorPath)
} catch {
toast.error('Failed to create flow. Please try again.')
+ return null
}
}
+ const handleOpenInEditor = async () => {
+ const tree = await createTree()
+ if (!tree) return
+ handleClose()
+ const editorPath =
+ metadata.flow_type === 'procedural'
+ ? `/flows/${tree.id}/edit`
+ : `/trees/${tree.id}/edit`
+ navigate(editorPath)
+ }
+
+ const handleStartFlow = async () => {
+ const tree = await createTree()
+ if (!tree) return
+ handleClose()
+ const navigatePath =
+ metadata.flow_type === 'procedural'
+ ? `/flows/${tree.id}/navigate`
+ : `/trees/${tree.id}/navigate`
+ navigate(navigatePath)
+ }
+
+ const handleBuildAnother = () => {
+ reset()
+ }
+
const getTitle = () => {
switch (phase) {
case 'foundation':
@@ -107,7 +128,11 @@ export function AIFlowBuilderModal({ isOpen, onClose }: AIFlowBuilderModalProps)
{phase === 'generating' &&
Generate AI detail for this branch
+ + {/* Generate All — primary action, shown when multiple branches remain */} + {selectedBranches.filter((b) => !b.steps).length > 1 && ( + isGeneratingAll ? ( + + ) : ( + + ) + )} + + {/* Divider + secondary actions */} + {selectedBranches.filter((b) => !b.steps).length > 1 && ( +AI suggested {suggestedBranches.length} branches. Select, reorder, rename, or add your own.
+- Branch {branchContext.current} of {branchContext.total} -
+ {branchContext ? ( + <> ++ Branch {branchContext.current} of {branchContext.total} +
+Generating branch detail...
+ > + ) : ( +Generating...
)} - - {/* Rotating message */} -- {MESSAGES[messageIndex]} -