MCPcopy Index your code
hub / github.com/simstudioai/sim / getWorkflowWithValues

Function getWorkflowWithValues

apps/sim/stores/workflows/index.ts:17–53  ·  view source on GitHub ↗
(workflowId: string, workspaceId: string)

Source from the content-addressed store, hash-verified

15 * @returns The workflow with merged state values or null if not found/not active
16 */
17export function getWorkflowWithValues(workflowId: string, workspaceId: string) {
18 const workflows = getWorkflows(workspaceId)
19 const activeWorkflowId = useWorkflowRegistry.getState().activeWorkflowId
20
21 const metadata = workflows.find((w) => w.id === workflowId)
22 if (!metadata) {
23 logger.warn(`Workflow ${workflowId} not found`)
24 return null
25 }
26
27 // Since localStorage persistence has been removed, only return data for active workflow
28 if (workflowId !== activeWorkflowId) {
29 logger.warn(`Cannot get state for non-active workflow ${workflowId} - localStorage removed`)
30 return null
31 }
32
33 // Use the current state from the store (only available for active workflow)
34 const workflowState: WorkflowState = useWorkflowStore.getState().getWorkflowState()
35
36 // Merge the subblock values for this specific workflow
37 const mergedBlocks = mergeSubblockState(workflowState.blocks, workflowId)
38
39 return {
40 id: workflowId,
41 name: metadata.name,
42 description: metadata.description,
43 workspaceId: metadata.workspaceId,
44 folderId: metadata.folderId,
45 state: {
46 blocks: mergedBlocks,
47 edges: workflowState.edges,
48 loops: workflowState.loops,
49 parallels: workflowState.parallels,
50 lastSaved: workflowState.lastSaved,
51 },
52 }
53}
54
55export type { WorkflowState } from '@/stores/workflows/workflow/types'

Callers 1

panel.tsxFile · 0.90

Calls 3

getWorkflowsFunction · 0.90
mergeSubblockStateFunction · 0.90
warnMethod · 0.65

Tested by

no test coverage detected