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

Method mergeDiff

apps/sim/lib/workflows/diff/diff-engine.ts:690–722  ·  view source on GitHub ↗

* Merge new workflow state into existing diff * Used for cumulative updates within the same message

(jsonContent: string, diffAnalysis?: DiffAnalysis)

Source from the content-addressed store, hash-verified

688 * Used for cumulative updates within the same message
689 */
690 async mergeDiff(jsonContent: string, diffAnalysis?: DiffAnalysis): Promise<DiffResult> {
691 try {
692 logger.info('Merging diff from workflow state')
693
694 // If no existing diff, create a new one
695 if (!this.currentDiff) {
696 logger.info('No existing diff, creating new diff')
697 return this.createDiff(jsonContent, diffAnalysis)
698 }
699
700 const proposedState = parseWorkflowStateJson(jsonContent)
701 const result = await this.createDiffFromWorkflowState(
702 proposedState,
703 diffAnalysis,
704 this.currentDiff.proposedState
705 )
706
707 if (result.success && result.diff) {
708 logger.info('Diff merged successfully', {
709 totalBlocksCount: Object.keys(result.diff.proposedState.blocks).length,
710 totalEdgesCount: result.diff.proposedState.edges.length,
711 })
712 }
713
714 return result
715 } catch (error) {
716 logger.error('Failed to merge diff:', error)
717 return {
718 success: false,
719 errors: [getErrorMessage(error, 'Failed to merge diff')],
720 }
721 }
722 }
723
724 /**
725 * Get the current diff

Callers

nothing calls this directly

Calls 6

createDiffMethod · 0.95
getErrorMessageFunction · 0.90
parseWorkflowStateJsonFunction · 0.85
infoMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected