1- import type { WorkflowState } from '@/stores/workflows/workflow/types'
1+ import type { BlockState , WorkflowState } from '@/stores/workflows/workflow/types'
22import { SYSTEM_SUBBLOCK_IDS , TRIGGER_RUNTIME_SUBBLOCK_IDS } from '@/triggers/constants'
33import {
44 normalizedStringify ,
@@ -13,6 +13,20 @@ import {
1313 sortEdges ,
1414} from './normalize'
1515
16+ /** Block with optional diff markers added by copilot */
17+ type BlockWithDiffMarkers = BlockState & {
18+ is_diff ?: string
19+ field_diffs ?: Record < string , unknown >
20+ }
21+
22+ /** SubBlock with optional diff marker */
23+ type SubBlockWithDiffMarker = {
24+ id : string
25+ type : string
26+ value : unknown
27+ is_diff ?: string
28+ }
29+
1630/**
1731 * Compare the current workflow state with the deployed state to detect meaningful changes
1832 * @param currentState - The current workflow state
@@ -63,21 +77,32 @@ export function hasWorkflowChanged(
6377 // - subBlocks: handled separately below
6478 // - layout: contains measuredWidth/measuredHeight from autolayout
6579 // - height: block height measurement from autolayout
80+ // - outputs: derived from subBlocks (e.g., inputFormat), already compared via subBlocks
81+ // - is_diff, field_diffs: diff markers from copilot edits
82+ const currentBlockWithDiff = currentBlock as BlockWithDiffMarkers
83+ const deployedBlockWithDiff = deployedBlock as BlockWithDiffMarkers
84+
6685 const {
6786 position : _currentPos ,
6887 subBlocks : currentSubBlocks = { } ,
6988 layout : _currentLayout ,
7089 height : _currentHeight ,
90+ outputs : _currentOutputs ,
91+ is_diff : _currentIsDiff ,
92+ field_diffs : _currentFieldDiffs ,
7193 ...currentRest
72- } = currentBlock
94+ } = currentBlockWithDiff
7395
7496 const {
7597 position : _deployedPos ,
7698 subBlocks : deployedSubBlocks = { } ,
7799 layout : _deployedLayout ,
78100 height : _deployedHeight ,
101+ outputs : _deployedOutputs ,
102+ is_diff : _deployedIsDiff ,
103+ field_diffs : _deployedFieldDiffs ,
79104 ...deployedRest
80- } = deployedBlock
105+ } = deployedBlockWithDiff
81106
82107 // Also exclude width/height from data object (container dimensions from autolayout)
83108 const {
@@ -156,14 +181,13 @@ export function hasWorkflowChanged(
156181 }
157182 }
158183
159- // Compare type and other properties
160- const currentSubBlockWithoutValue = { ...currentSubBlocks [ subBlockId ] , value : undefined }
161- const deployedSubBlockWithoutValue = { ...deployedSubBlocks [ subBlockId ] , value : undefined }
184+ // Compare type and other properties (excluding diff markers and value)
185+ const currentSubBlockWithDiff = currentSubBlocks [ subBlockId ] as SubBlockWithDiffMarker
186+ const deployedSubBlockWithDiff = deployedSubBlocks [ subBlockId ] as SubBlockWithDiffMarker
187+ const { value : _cv , is_diff : _cd , ...currentSubBlockRest } = currentSubBlockWithDiff
188+ const { value : _dv , is_diff : _dd , ...deployedSubBlockRest } = deployedSubBlockWithDiff
162189
163- if (
164- normalizedStringify ( currentSubBlockWithoutValue ) !==
165- normalizedStringify ( deployedSubBlockWithoutValue )
166- ) {
190+ if ( normalizedStringify ( currentSubBlockRest ) !== normalizedStringify ( deployedSubBlockRest ) ) {
167191 return true
168192 }
169193 }
0 commit comments