From da5342496b5eb3af3c3343f4ff280f50c7ce7cc3 Mon Sep 17 00:00:00 2001 From: chihlasm Date: Tue, 24 Feb 2026 00:48:58 -0500 Subject: [PATCH] feat: add generateAllBranchDetails and cancelGenerateAll to AI builder store Co-Authored-By: Claude Opus 4.6 --- frontend/src/store/aiFlowBuilderStore.ts | 32 ++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/frontend/src/store/aiFlowBuilderStore.ts b/frontend/src/store/aiFlowBuilderStore.ts index e8045810..3649aff9 100644 --- a/frontend/src/store/aiFlowBuilderStore.ts +++ b/frontend/src/store/aiFlowBuilderStore.ts @@ -29,6 +29,8 @@ interface AIFlowBuilderState { // UI state isLoading: boolean + isGeneratingAll: boolean + stopGeneratingAll: boolean error: string | null // Actions @@ -39,6 +41,8 @@ interface AIFlowBuilderState { selectBranches: (branches: AIBranch[]) => void generateBranchDetail: (branchName: string) => Promise assemble: () => Promise + generateAllBranchDetails: () => Promise + cancelGenerateAll: () => void reset: () => void setPhase: (phase: AIWizardPhase) => void setError: (error: string | null) => void @@ -62,6 +66,8 @@ export const useAIFlowBuilderStore = create()((set, get) => assembledTree: null, quota: null, isLoading: false, + isGeneratingAll: false, + stopGeneratingAll: false, error: null, loadQuota: async () => { @@ -175,6 +181,30 @@ export const useAIFlowBuilderStore = create()((set, get) => } }, + generateAllBranchDetails: async () => { + const { selectedBranches, generateBranchDetail } = get() + const undetailed = selectedBranches.filter((b) => !b.steps) + if (undetailed.length === 0) return + + set({ isGeneratingAll: true, stopGeneratingAll: false, error: null }) + + for (const branch of undetailed) { + if (get().stopGeneratingAll) break + // Set currentBranchIndex so tabs show the active branch + const idx = get().selectedBranches.findIndex((b) => b.name === branch.name) + if (idx !== -1) set({ currentBranchIndex: idx }) + await generateBranchDetail(branch.name) + // If generateBranchDetail set phase to 'error', stop + if (get().phase === 'error') break + } + + set({ isGeneratingAll: false }) + }, + + cancelGenerateAll: () => { + set({ stopGeneratingAll: true }) + }, + reset: () => { set({ phase: 'foundation', @@ -185,6 +215,8 @@ export const useAIFlowBuilderStore = create()((set, get) => currentBranchIndex: 0, assembledTree: null, isLoading: false, + isGeneratingAll: false, + stopGeneratingAll: false, error: null, }) },