mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-10 07:27:57 -05:00
Added max iterations update to state for loop
This commit is contained in:
@@ -114,6 +114,7 @@ export const useWorkflowStore = create<WorkflowStoreWithHistory>()(
|
||||
},
|
||||
}
|
||||
})
|
||||
get().updateLastSaved()
|
||||
},
|
||||
|
||||
addBlock: (id: string, type: string, name: string, position: Position) => {
|
||||
@@ -229,6 +230,7 @@ export const useWorkflowStore = create<WorkflowStoreWithHistory>()(
|
||||
newLoops[loopId] = {
|
||||
id: loopId,
|
||||
nodes: path,
|
||||
maxIterations: 5,
|
||||
}
|
||||
processedPaths.add(canonicalPath)
|
||||
}
|
||||
@@ -265,6 +267,7 @@ export const useWorkflowStore = create<WorkflowStoreWithHistory>()(
|
||||
newLoops[loopId] = {
|
||||
id: loopId,
|
||||
nodes: path,
|
||||
maxIterations: 5,
|
||||
}
|
||||
processedPaths.add(canonicalPath)
|
||||
}
|
||||
@@ -414,6 +417,7 @@ export const useWorkflowStore = create<WorkflowStoreWithHistory>()(
|
||||
edges: [...state.edges],
|
||||
loops: { ...get().loops },
|
||||
}))
|
||||
get().updateLastSaved()
|
||||
},
|
||||
|
||||
updateBlockHeight: (id: string, height: number) => {
|
||||
@@ -427,6 +431,25 @@ export const useWorkflowStore = create<WorkflowStoreWithHistory>()(
|
||||
},
|
||||
edges: [...state.edges],
|
||||
}))
|
||||
get().updateLastSaved()
|
||||
},
|
||||
|
||||
updateLoopMaxIterations: (loopId: string, maxIterations: number) => {
|
||||
const newState = {
|
||||
blocks: { ...get().blocks },
|
||||
edges: [...get().edges],
|
||||
loops: {
|
||||
...get().loops,
|
||||
[loopId]: {
|
||||
...get().loops[loopId],
|
||||
maxIterations: Math.max(1, Math.min(50, maxIterations)), // Clamp between 1-50
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
set(newState)
|
||||
pushHistory(set, get, newState, 'Update loop max iterations')
|
||||
get().updateLastSaved()
|
||||
},
|
||||
})),
|
||||
{ name: 'workflow-store' }
|
||||
|
||||
@@ -28,6 +28,7 @@ export interface SubBlockState {
|
||||
export interface Loop {
|
||||
id: string
|
||||
nodes: string[]
|
||||
maxIterations: number
|
||||
}
|
||||
|
||||
export interface WorkflowState {
|
||||
@@ -52,6 +53,7 @@ export interface WorkflowActions {
|
||||
updateBlockName: (id: string, name: string) => void
|
||||
toggleBlockWide: (id: string) => void
|
||||
updateBlockHeight: (id: string, height: number) => void
|
||||
updateLoopMaxIterations: (loopId: string, maxIterations: number) => void
|
||||
}
|
||||
|
||||
export type WorkflowStore = WorkflowState & WorkflowActions
|
||||
|
||||
Reference in New Issue
Block a user