diff --git a/frontend/src/components/ai-builder/BranchDetailView.tsx b/frontend/src/components/ai-builder/BranchDetailView.tsx index 25baba07..0727f070 100644 --- a/frontend/src/components/ai-builder/BranchDetailView.tsx +++ b/frontend/src/components/ai-builder/BranchDetailView.tsx @@ -1,4 +1,4 @@ -import { useState } from 'react' +import { useState, useEffect, useRef } from 'react' import { Check, RefreshCw, SkipForward, ChevronRight, ChevronLeft } from 'lucide-react' import { useAIFlowBuilderStore } from '@/store/aiFlowBuilderStore' import { GeneratingAnimation } from './GeneratingAnimation' @@ -21,6 +21,18 @@ export function BranchDetailView() { const allBranchesHaveDetail = selectedBranches.every((b) => b.steps) const branchesWithDetail = selectedBranches.filter((b) => b.steps).length + // Auto-advance to next branch without detail after generation completes + const prevDetailCount = useRef(branchesWithDetail) + useEffect(() => { + if (branchesWithDetail > prevDetailCount.current) { + prevDetailCount.current = branchesWithDetail + const nextIndex = selectedBranches.findIndex((b) => !b.steps) + if (nextIndex !== -1) { + setViewingIndex(nextIndex) + } + } + }, [branchesWithDetail, selectedBranches]) + const handleGenerate = async (branchName: string) => { setError(null) await generateBranchDetail(branchName) @@ -35,103 +47,106 @@ export function BranchDetailView() { } return ( -
- {/* Branch tabs */} -
- {selectedBranches.map((branch, i) => ( - + ))} +
+ + {/* Current branch detail */} + {currentBranch && ( +
+
+
+

{currentBranch.name}

+

{currentBranch.description}

+
+
+ + {currentBranch.steps ? ( +
+ {/* Mini tree preview */} +
+ +
+ +
+ +
+
+ ) : ( +
+

+ Generate AI detail for this branch +

+
+ + +
+
)} - > - {branch.name} - {branch.steps && ( - - )} - - ))} +
+ )} + + {/* Error */} + {error && ( +
+ {error} +
+ )}
- {/* Current branch detail */} - {currentBranch && ( -
-
-
-

{currentBranch.name}

-

{currentBranch.description}

-
-
- - {currentBranch.steps ? ( -
- {/* Mini tree preview */} -
- -
- -
- -
-
- ) : ( -
-

- Generate AI detail for this branch -

-
- - -
-
- )} -
- )} - - {/* Error */} - {error && ( -
- {error} -
- )} - - {/* Navigation */} -
+ {/* Navigation — sticky so it's always visible */} +