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

Function stripWorkflowDiffMarkers

apps/sim/lib/workflows/diff/diff-engine.ts:788–830  ·  view source on GitHub ↗
(state: WorkflowState)

Source from the content-addressed store, hash-verified

786 * Removes diff metadata from a workflow state so it can be persisted or re-used safely.
787 */
788export function stripWorkflowDiffMarkers(state: WorkflowState): WorkflowState {
789 const cleanBlocks: Record<string, BlockState> = {}
790
791 for (const [blockId, block] of Object.entries(state.blocks || {})) {
792 // Validate block ID at the source - skip invalid IDs
793 if (!isValidKey(blockId)) {
794 logger.error('Invalid blockId detected in stripWorkflowDiffMarkers', {
795 blockId,
796 blockId_type: typeof blockId,
797 blockType: block?.type,
798 blockName: block?.name,
799 })
800 continue
801 }
802
803 const cleanBlock: BlockState = structuredClone(block)
804 const blockWithDiff = cleanBlock as BlockState & BlockWithDiff
805 blockWithDiff.is_diff = undefined
806 blockWithDiff.field_diffs = undefined
807
808 if (cleanBlock.subBlocks) {
809 Object.values(cleanBlock.subBlocks).forEach((subBlock) => {
810 if (subBlock && typeof subBlock === 'object') {
811 ;(subBlock as any).is_diff = undefined
812 }
813 })
814 }
815
816 if (cleanBlock.outputs === undefined || cleanBlock.outputs === null) {
817 cleanBlock.outputs = {}
818 }
819
820 cleanBlocks[blockId] = cleanBlock
821 }
822
823 return {
824 ...state,
825 blocks: cleanBlocks,
826 edges: structuredClone(state.edges || []),
827 loops: structuredClone(state.loops || {}),
828 parallels: structuredClone(state.parallels || {}),
829 }
830}

Callers 4

store.tsFile · 0.90
acceptDiffMethod · 0.85
useUndoRedoFunction · 0.85

Calls 2

isValidKeyFunction · 0.90
errorMethod · 0.80

Tested by

no test coverage detected