@@ -214,15 +214,13 @@ export function ControlBar() {
214214
215215 const response = await fetch ( `/api/workflows/${ requestWorkflowId } /deployed` )
216216
217- // Check if the workflow ID changed during the request (user navigated away)
218217 if ( requestWorkflowId !== useWorkflowRegistry . getState ( ) . activeWorkflowId ) {
219218 logger . debug ( 'Workflow changed during deployed state fetch, ignoring response' )
220219 return
221220 }
222221
223222 if ( ! response . ok ) {
224223 if ( response . status === 404 ) {
225- // No deployed state found
226224 setDeployedState ( null )
227225 return
228226 }
@@ -231,7 +229,6 @@ export function ControlBar() {
231229
232230 const data = await response . json ( )
233231
234- // Final check to ensure we're still on the same workflow
235232 if ( requestWorkflowId === useWorkflowRegistry . getState ( ) . activeWorkflowId ) {
236233 setDeployedState ( data . deployedState || null )
237234 } else {
@@ -244,14 +241,12 @@ export function ControlBar() {
244241 setDeployedState ( null )
245242 }
246243 } finally {
247- // Only clear loading state if we're still on the same workflow
248244 if ( requestWorkflowId === useWorkflowRegistry . getState ( ) . activeWorkflowId ) {
249245 setIsLoadingDeployedState ( false )
250246 }
251247 }
252248 }
253249
254- // Fetch deployed state when workflow ID or deployment status changes
255250 useEffect ( ( ) => {
256251 if ( ! activeWorkflowId ) {
257252 setDeployedState ( null )
@@ -263,7 +258,6 @@ export function ControlBar() {
263258 setNeedsRedeploymentFlag ( false )
264259 fetchDeployedState ( )
265260 } else {
266- // When not deployed - clear the deployed state
267261 setDeployedState ( null )
268262 setIsLoadingDeployedState ( false )
269263 }
@@ -290,48 +284,39 @@ export function ControlBar() {
290284 subBlocks : block . subBlocks || { } ,
291285 } ) )
292286 . sort ( ( a , b ) => {
293- // Sort by type first, then by name for consistent comparison
294287 const typeA = a . type || ''
295288 const typeB = b . type || ''
296289 if ( typeA !== typeB ) return typeA . localeCompare ( typeB )
297290 return ( a . name || '' ) . localeCompare ( b . name || '' )
298291 } )
299292 }
300293
301- // Subscribe to workflow and subblock changes to detect differences from deployed state
302294 useEffect ( ( ) => {
303- // Early exit: No workflow or nothing deployed = no changes possible
304295 if ( ! activeWorkflowId || ! deployedState ) {
305296 setChangeDetected ( false )
306297 return
307298 }
308299
309- // Wait for deployed state to finish loading to avoid race conditions
310300 if ( isLoadingDeployedState ) {
311301 return
312302 }
313303
314- // Get current workflow state merged with user inputs
315304 const currentMergedState = mergeSubblockState ( currentBlocks , activeWorkflowId )
316305
317- // Compare current state vs deployed state
318306 const deployedBlocks = deployedState ?. blocks
319307 if ( ! deployedBlocks ) {
320308 setChangeDetected ( false )
321309 return
322310 }
323311
324- // Normalize blocks for semantic comparison
325312 const normalizedCurrentBlocks = normalizeBlocksForComparison ( currentMergedState )
326313 const normalizedDeployedBlocks = normalizeBlocksForComparison ( deployedBlocks )
327314
328- // Compare normalized states
329315 const hasChanges =
330316 JSON . stringify ( normalizedCurrentBlocks ) !== JSON . stringify ( normalizedDeployedBlocks )
331317 setChangeDetected ( hasChanges )
332318 } , [ activeWorkflowId , deployedState , currentBlocks , subBlockValues , isLoadingDeployedState ] )
333319
334- // Check usage limits when component mounts and when user executes a workflow
335320 useEffect ( ( ) => {
336321 if ( session ?. user ?. id ) {
337322 checkUserUsage ( session . user . id ) . then ( ( usage ) => {
0 commit comments