diff --git a/apps/sim/app/w/[id]/components/control-bar/components/deploy-modal/components/deployment-info/deployment-info.tsx b/apps/sim/app/w/[id]/components/control-bar/components/deploy-modal/components/deployment-info/deployment-info.tsx index 6c1ad43fe8..a85f81d7a6 100644 --- a/apps/sim/app/w/[id]/components/control-bar/components/deploy-modal/components/deployment-info/deployment-info.tsx +++ b/apps/sim/app/w/[id]/components/control-bar/components/deploy-modal/components/deployment-info/deployment-info.tsx @@ -163,6 +163,7 @@ export function DeploymentInfo({ setIsViewingDeployed(false)} + needsRedeployment={deploymentInfo.needsRedeployment} deployedWorkflowState={deployedState} /> )} diff --git a/apps/sim/app/w/[id]/components/control-bar/components/deployment-controls/components/deployed-workflow-modal.tsx b/apps/sim/app/w/[id]/components/control-bar/components/deployment-controls/components/deployed-workflow-modal.tsx index 8ebd1a883a..d6f9a1b41b 100644 --- a/apps/sim/app/w/[id]/components/control-bar/components/deployment-controls/components/deployed-workflow-modal.tsx +++ b/apps/sim/app/w/[id]/components/control-bar/components/deployment-controls/components/deployed-workflow-modal.tsx @@ -31,6 +31,7 @@ const logger = createLogger('DeployedWorkflowModal') interface DeployedWorkflowModalProps { isOpen: boolean onClose: () => void + needsRedeployment: boolean deployedWorkflowState: { blocks: Record edges: Array @@ -48,6 +49,7 @@ interface DeployedWorkflowModalProps { export function DeployedWorkflowModal({ isOpen, onClose, + needsRedeployment, deployedWorkflowState, }: DeployedWorkflowModalProps) { const [showRevertDialog, setShowRevertDialog] = useState(false) @@ -63,6 +65,7 @@ export function DeployedWorkflowModal({ const initialDeployedStateRef = useRef(null); useEffect(() => { + console.log('needsRedeployment', needsRedeployment) if (isOpen) { modalOpenCount.current += 1; @@ -199,32 +202,34 @@ export function DeployedWorkflowModal({ /> )} -
- - - - - - - Revert to Deployed Version? - - This will replace your current workflow with the deployed version. Any unsaved - changes will be lost. This action cannot be undone. - - - - Cancel - - Revert - - - - +
+ {needsRedeployment && ( + + + + + + + Revert to Deployed Version? + + This will replace your current workflow with the deployed version. Any unsaved + changes will be lost. This action cannot be undone. + + + + Cancel + + Revert + + + + + )} -
diff --git a/apps/sim/app/w/[id]/hooks/use-deployment-change-detection.ts b/apps/sim/app/w/[id]/hooks/use-deployment-change-detection.ts index a440d8fb12..c38297be9f 100644 --- a/apps/sim/app/w/[id]/hooks/use-deployment-change-detection.ts +++ b/apps/sim/app/w/[id]/hooks/use-deployment-change-detection.ts @@ -48,22 +48,12 @@ export function useDeploymentChangeDetection(activeWorkflowId: string | null, is // Verify the active workflow hasn't changed while fetching if (requestedWorkflowId !== activeWorkflowId) { - logger.debug( - `Ignoring changes response for ${requestedWorkflowId} - no longer the active workflow` - ) return } - logger.debug( - `API needsRedeployment response for workflow ${requestedWorkflowId}: ${data.needsRedeployment}` - ) - // Always update the needsRedeployment flag based on API response to handle both true and false // This ensures it's updated when changes are detected and when changes are no longer detected if (data.needsRedeployment) { - logger.info( - `Setting needsRedeployment flag to TRUE for workflow ${requestedWorkflowId}` - ) // Update local state setNeedsRedeployment(true) @@ -76,9 +66,6 @@ export function useDeploymentChangeDetection(activeWorkflowId: string | null, is .getState() .getWorkflowDeploymentStatus(requestedWorkflowId) if (currentStatus?.needsRedeployment) { - logger.info( - `Setting needsRedeployment flag to FALSE for workflow ${requestedWorkflowId}` - ) // Update local state setNeedsRedeployment(false) @@ -153,34 +140,10 @@ export function useDeploymentChangeDetection(activeWorkflowId: string | null, is } }) - // Set up a periodic check when needsRedeployment is true to ensure it gets set back to false - // when changes are reverted - let periodicCheckTimer: NodeJS.Timeout | null = null - - if (needsRedeployment) { - // Check every 5 seconds when needsRedeployment is true to catch reverted changes - const PERIODIC_CHECK_INTERVAL = 5000 // 5 seconds - - periodicCheckTimer = setInterval(() => { - // Only perform the check if this is still the active workflow - if (effectWorkflowId === activeWorkflowId) { - checkForChanges() - } else { - // Clear the interval if the workflow has changed - if (periodicCheckTimer) { - clearInterval(periodicCheckTimer) - } - } - }, PERIODIC_CHECK_INTERVAL) - } - return () => { if (debounceTimer) { clearTimeout(debounceTimer) } - if (periodicCheckTimer) { - clearInterval(periodicCheckTimer) - } workflowUnsubscribe() subBlockUnsubscribe() }