feat: add generateAllBranchDetails and cancelGenerateAll to AI builder store
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -29,6 +29,8 @@ interface AIFlowBuilderState {
|
|||||||
|
|
||||||
// UI state
|
// UI state
|
||||||
isLoading: boolean
|
isLoading: boolean
|
||||||
|
isGeneratingAll: boolean
|
||||||
|
stopGeneratingAll: boolean
|
||||||
error: string | null
|
error: string | null
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
@@ -39,6 +41,8 @@ interface AIFlowBuilderState {
|
|||||||
selectBranches: (branches: AIBranch[]) => void
|
selectBranches: (branches: AIBranch[]) => void
|
||||||
generateBranchDetail: (branchName: string) => Promise<void>
|
generateBranchDetail: (branchName: string) => Promise<void>
|
||||||
assemble: () => Promise<void>
|
assemble: () => Promise<void>
|
||||||
|
generateAllBranchDetails: () => Promise<void>
|
||||||
|
cancelGenerateAll: () => void
|
||||||
reset: () => void
|
reset: () => void
|
||||||
setPhase: (phase: AIWizardPhase) => void
|
setPhase: (phase: AIWizardPhase) => void
|
||||||
setError: (error: string | null) => void
|
setError: (error: string | null) => void
|
||||||
@@ -62,6 +66,8 @@ export const useAIFlowBuilderStore = create<AIFlowBuilderState>()((set, get) =>
|
|||||||
assembledTree: null,
|
assembledTree: null,
|
||||||
quota: null,
|
quota: null,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
|
isGeneratingAll: false,
|
||||||
|
stopGeneratingAll: false,
|
||||||
error: null,
|
error: null,
|
||||||
|
|
||||||
loadQuota: async () => {
|
loadQuota: async () => {
|
||||||
@@ -175,6 +181,30 @@ export const useAIFlowBuilderStore = create<AIFlowBuilderState>()((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: () => {
|
reset: () => {
|
||||||
set({
|
set({
|
||||||
phase: 'foundation',
|
phase: 'foundation',
|
||||||
@@ -185,6 +215,8 @@ export const useAIFlowBuilderStore = create<AIFlowBuilderState>()((set, get) =>
|
|||||||
currentBranchIndex: 0,
|
currentBranchIndex: 0,
|
||||||
assembledTree: null,
|
assembledTree: null,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
|
isGeneratingAll: false,
|
||||||
|
stopGeneratingAll: false,
|
||||||
error: null,
|
error: null,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user