@@ -274,9 +274,31 @@ export function ControlBar() {
274274 activeWorkflowId ? state . workflowValues [ activeWorkflowId ] : null
275275 )
276276
277+ /**
278+ * Normalize blocks for semantic comparison - only compare what matters functionally
279+ * Ignores: IDs, positions, dimensions, metadata that don't affect workflow logic
280+ * Compares: type, name, subBlock values
281+ */
282+ const normalizeBlocksForComparison = ( blocks : Record < string , any > ) => {
283+ if ( ! blocks ) return [ ]
284+
285+ return Object . values ( blocks )
286+ . map ( ( block : any ) => ( {
287+ type : block . type ,
288+ name : block . name ,
289+ subBlocks : block . subBlocks || { } ,
290+ } ) )
291+ . sort ( ( a , b ) => {
292+ // Sort by type first, then by name for consistent comparison
293+ const typeA = a . type || ''
294+ const typeB = b . type || ''
295+ if ( typeA !== typeB ) return typeA . localeCompare ( typeB )
296+ return ( a . name || '' ) . localeCompare ( b . name || '' )
297+ } )
298+ }
299+
277300 // Subscribe to workflow and subblock changes to detect differences from deployed state
278301 useEffect ( ( ) => {
279- console . log ( 'changing subblocks values' )
280302 // Early exit: No workflow or nothing deployed = no changes possible
281303 if ( ! activeWorkflowId || ! deployedState ) {
282304 setChangeDetected ( false )
@@ -293,19 +315,18 @@ export function ControlBar() {
293315
294316 // Compare current state vs deployed state
295317 const deployedBlocks = deployedState ?. blocks
296- console . log ( 'deployedBlocks' , deployedBlocks )
297- console . log ( 'currentMergedState' , currentMergedState )
298318 if ( ! deployedBlocks ) {
299- console . log ( 'current state should be same as deployed state' )
300319 setChangeDetected ( false )
301320 return
302321 }
303322
304- // Simple JSON comparison - if different, changes detected
305- const hasChanges = JSON . stringify ( currentMergedState ) !== JSON . stringify ( deployedBlocks )
306- console . log ( 'hasChanges' , hasChanges )
307- setChangeDetected ( hasChanges )
323+ // Normalize blocks for semantic comparison
324+ const normalizedCurrentBlocks = normalizeBlocksForComparison ( currentMergedState )
325+ const normalizedDeployedBlocks = normalizeBlocksForComparison ( deployedBlocks )
308326
327+ // Compare normalized states
328+ const hasChanges = JSON . stringify ( normalizedCurrentBlocks ) !== JSON . stringify ( normalizedDeployedBlocks )
329+ setChangeDetected ( hasChanges )
309330 } , [ activeWorkflowId , deployedState , currentBlocks , subBlockValues , isLoadingDeployedState ] )
310331
311332 // Check usage limits when component mounts and when user executes a workflow
@@ -625,7 +646,6 @@ export function ControlBar() {
625646 /**
626647 * Render deploy button with tooltip
627648 */
628- console . log ( 'needs redeployment BEOFRE DEPLOYMENT CONTROLS' , changeDetected )
629649 const renderDeployButton = ( ) => (
630650 < DeploymentControls
631651 activeWorkflowId = { activeWorkflowId }
0 commit comments