MCPcopy Create free account
hub / github.com/ShipSecAI/studio / loadWorkflow

Function loadWorkflow

frontend/src/features/workflow-builder/WorkflowBuilder.tsx:529–708  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

527 }
528
529 const loadWorkflow = async () => {
530 // Reset execution state if switching workflows to prevent leaks
531 // This ensures we don't show status/logs from a previous workflow
532 const executionStore = useExecutionStore.getState();
533 if (id && executionStore.workflowId !== id) {
534 executionStore.reset();
535 // Timeline store already reset synchronously above
536 }
537
538 if (isNewWorkflow) {
539 if (designNodesRef.current.length === 0) {
540 resetWorkflow();
541 const entryNode = createEntryPointNode();
542 // Initialize both design and execution states with the same initial state
543 setDesignNodes([entryNode]);
544 setDesignEdges([]);
545 setExecutionNodes([entryNode]);
546 setExecutionEdges([]);
547 resetHistoricalTracking();
548
549 // Initialize saved snapshot for new workflow
550 designSavedSnapshotRef.current = {
551 nodes: cloneNodes([entryNode]),
552 edges: cloneEdges([]),
553 };
554 executionLoadedSnapshotRef.current = {
555 nodes: cloneNodes([entryNode]),
556 edges: cloneEdges([]),
557 };
558
559 const baseMetadata = useWorkflowStore.getState().metadata;
560 setLastSavedGraphSignature(computeGraphSignature([entryNode], []));
561 setLastSavedMetadata({
562 name: baseMetadata.name,
563 description: baseMetadata.description ?? '',
564 });
565
566 // Initialize undo/redo history with the initial state
567 initializeHistory([entryNode], []);
568 }
569 track(Events.WorkflowBuilderLoaded, { is_new: true });
570 return;
571 }
572
573 if (!id) return;
574
575 setIsLoading(true);
576 try {
577 const workflow = await api.workflows.get(id);
578
579 // Update workflow store
580 setMetadata({
581 id: workflow.id,
582 name: workflow.name,
583 description: workflow.description ?? '',
584 currentVersionId: workflow.currentVersionId ?? null,
585 currentVersion: workflow.currentVersion ?? null,
586 });

Callers 1

WorkflowBuilderContentFunction · 0.85

Calls 10

cloneNodesFunction · 0.90
cloneEdgesFunction · 0.90
trackFunction · 0.90
deserializeEdgesFunction · 0.90
deserializeNodesFunction · 0.90
computeGraphSignatureFunction · 0.85
resetMethod · 0.80
errorMethod · 0.80
getMethod · 0.65
listRunsMethod · 0.45

Tested by

no test coverage detected