diff --git a/apps/sim/app/w/[id]/components/control-bar/control-bar.tsx b/apps/sim/app/w/[id]/components/control-bar/control-bar.tsx index d8e8f20555..9dbcd5aeac 100644 --- a/apps/sim/app/w/[id]/components/control-bar/control-bar.tsx +++ b/apps/sim/app/w/[id]/components/control-bar/control-bar.tsx @@ -98,6 +98,7 @@ export function ControlBar() { removeWorkflow, duplicateWorkflow, setDeploymentStatus, + isLoading: isRegistryLoading, } = useWorkflowRegistry() const { isExecuting, handleRunWorkflow } = useWorkflowExecution() const { setActiveTab } = usePanelStore() @@ -257,6 +258,12 @@ export function ControlBar() { return } + if (isRegistryLoading) { + setDeployedState(null) + setIsLoadingDeployedState(false) + return + } + if (isDeployed) { setNeedsRedeploymentFlag(false) fetchDeployedState() @@ -264,7 +271,7 @@ export function ControlBar() { setDeployedState(null) setIsLoadingDeployedState(false) } - }, [activeWorkflowId, isDeployed, setNeedsRedeploymentFlag]) + }, [activeWorkflowId, isDeployed, setNeedsRedeploymentFlag, isRegistryLoading]) // Get current store state for change detection const currentBlocks = useWorkflowStore((state) => state.blocks) @@ -321,7 +328,7 @@ export function ControlBar() { }, [activeWorkflowId, deployedState, currentBlocks, subBlockValues, isLoadingDeployedState]) useEffect(() => { - if (session?.user?.id) { + if (session?.user?.id && !isRegistryLoading) { checkUserUsage(session.user.id).then((usage) => { if (usage) { setUsageExceeded(usage.isExceeded) @@ -329,7 +336,7 @@ export function ControlBar() { } }) } - }, [session?.user?.id, completedRuns]) + }, [session?.user?.id, completedRuns, isRegistryLoading]) /** * Check user usage data with caching to prevent excessive API calls diff --git a/apps/sim/stores/workflows/sync.ts b/apps/sim/stores/workflows/sync.ts index c2fbeb412b..e06ba5de5a 100644 --- a/apps/sim/stores/workflows/sync.ts +++ b/apps/sim/stores/workflows/sync.ts @@ -285,24 +285,6 @@ export async function fetchWorkflowsFromDB(): Promise { }) }) - // Get any additional subblock values that might not be in the state but are in the store - const storedValues = useSubBlockStore.getState().workflowValues[id] || {} - Object.entries(storedValues).forEach(([blockId, blockValues]) => { - if (!subblockValues[blockId]) { - subblockValues[blockId] = {} - } - - Object.entries(blockValues).forEach(([subblockId, value]) => { - // Only update if not already set or if value is null - if ( - subblockValues[blockId][subblockId] === null || - subblockValues[blockId][subblockId] === undefined - ) { - subblockValues[blockId][subblockId] = value - } - }) - }) - // 4. Store the workflow state and subblock values in localStorage // This ensures compatibility with existing code that loads from localStorage localStorage.setItem(`workflow-${id}`, JSON.stringify(workflowState))