mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-06 03:00:16 -04:00
saving checkpoint
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import { useState, useMemo } from 'react'
|
||||
import { useState, useMemo, useEffect } from 'react'
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
@@ -13,9 +13,6 @@ import {
|
||||
AlertDialogTrigger,
|
||||
} from '@/components/ui/alert-dialog'
|
||||
import { Button } from '@/components/ui/button'
|
||||
<<<<<<< HEAD
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog'
|
||||
=======
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
@@ -24,7 +21,6 @@ import {
|
||||
DialogTitle,
|
||||
} from '@/components/ui/dialog'
|
||||
import { createLogger } from '@/lib/logs/console-logger'
|
||||
>>>>>>> 2e4f4a91 (fix: good except for subblocks)
|
||||
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
|
||||
import { mergeSubblockState } from '@/stores/workflows/utils'
|
||||
import { useWorkflowStore } from '@/stores/workflows/workflow/store'
|
||||
@@ -65,7 +61,12 @@ export function DeployedWorkflowModal({
|
||||
const sanitizedCurrentState = useMemo(() => {
|
||||
if (!currentWorkflowState) return undefined;
|
||||
|
||||
return {
|
||||
logger.info('Before current state sanitization', {
|
||||
workflowId: activeWorkflowId,
|
||||
blockCount: Object.keys(currentWorkflowState.blocks || {}).length
|
||||
});
|
||||
|
||||
const result = {
|
||||
blocks: Object.fromEntries(
|
||||
Object.entries(currentWorkflowState.blocks || {})
|
||||
.filter(([_, block]) => block && block.type)
|
||||
@@ -77,7 +78,14 @@ export function DeployedWorkflowModal({
|
||||
edges: currentWorkflowState.edges ? [...currentWorkflowState.edges] : [],
|
||||
loops: currentWorkflowState.loops ? {...currentWorkflowState.loops} : {}
|
||||
};
|
||||
}, [currentWorkflowState]);
|
||||
|
||||
logger.info('After current state sanitization', {
|
||||
workflowId: activeWorkflowId,
|
||||
blockCount: Object.keys(result.blocks).length
|
||||
});
|
||||
|
||||
return result;
|
||||
}, [currentWorkflowState, activeWorkflowId]);
|
||||
|
||||
const sanitizedDeployedState = useMemo(() => {
|
||||
if (!deployedWorkflowState) return {
|
||||
@@ -116,6 +124,27 @@ export function DeployedWorkflowModal({
|
||||
>>>>>>> 9594f7db (fix: good except for subblocks)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (isOpen && activeWorkflowId) {
|
||||
logger.info('DeployedWorkflowModal opened', {
|
||||
workflowId: activeWorkflowId,
|
||||
deployedStateBlockCount: Object.keys(deployedWorkflowState?.blocks || {}).length,
|
||||
currentStateBlockCount: Object.keys(currentWorkflowState?.blocks || {}).length,
|
||||
deployedStateChecksum: JSON.stringify(deployedWorkflowState).length,
|
||||
currentStateChecksum: JSON.stringify(currentWorkflowState).length
|
||||
});
|
||||
|
||||
// Log a sample of block IDs to verify they match expected workflow
|
||||
const deployedBlockIds = Object.keys(deployedWorkflowState?.blocks || {}).slice(0, 2);
|
||||
const currentBlockIds = Object.keys(currentWorkflowState?.blocks || {}).slice(0, 2);
|
||||
|
||||
logger.info('State block samples', {
|
||||
deployedBlockIds,
|
||||
currentBlockIds
|
||||
});
|
||||
}
|
||||
}, [isOpen, activeWorkflowId, deployedWorkflowState, currentWorkflowState]);
|
||||
|
||||
return (
|
||||
<Dialog open={isOpen} onOpenChange={onClose}>
|
||||
<DialogContent
|
||||
|
||||
@@ -56,6 +56,7 @@ import { DeploymentControls } from './components/deployment-controls/deployment-
|
||||
import { HistoryDropdownItem } from './components/history-dropdown-item/history-dropdown-item'
|
||||
import { MarketplaceModal } from './components/marketplace-modal/marketplace-modal'
|
||||
import { NotificationDropdownItem } from './components/notification-dropdown-item/notification-dropdown-item'
|
||||
import { useSubBlockStore } from '@/stores/workflows/subblock/store'
|
||||
|
||||
const logger = createLogger('ControlBar')
|
||||
|
||||
@@ -86,7 +87,7 @@ export function ControlBar() {
|
||||
showNotification,
|
||||
removeNotification,
|
||||
} = useNotificationStore()
|
||||
const { history, revertToHistoryState, lastSaved } = useWorkflowStore()
|
||||
const { history, revertToHistoryState, lastSaved } = useWorkflowStore()
|
||||
const {
|
||||
workflows,
|
||||
updateWorkflow,
|
||||
@@ -293,42 +294,6 @@ export function ControlBar() {
|
||||
}
|
||||
}, [activeWorkflowId, isDeployed, needsRedeployment])
|
||||
|
||||
// Check deployment and publication status on mount or when activeWorkflowId changes
|
||||
useEffect(() => {
|
||||
async function checkStatus() {
|
||||
if (!activeWorkflowId) return
|
||||
|
||||
// Skip API call in localStorage mode
|
||||
if (
|
||||
typeof window !== 'undefined' &&
|
||||
(localStorage.getItem('USE_LOCAL_STORAGE') === 'true' ||
|
||||
process.env.NEXT_PUBLIC_USE_LOCAL_STORAGE === 'true' ||
|
||||
process.env.NEXT_PUBLIC_DISABLE_DB_SYNC === 'true')
|
||||
) {
|
||||
// For localStorage mode, we already have the status in the workflow store
|
||||
// Nothing more to do as the useWorkflowStore already has this information
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/workflows/${activeWorkflowId}/status`)
|
||||
if (response.ok) {
|
||||
const data = await response.json()
|
||||
// Update the store with the status from the API
|
||||
setDeploymentStatus(
|
||||
data.isDeployed,
|
||||
data.deployedAt ? new Date(data.deployedAt) : undefined
|
||||
)
|
||||
setNeedsRedeployment(data.needsRedeployment)
|
||||
useWorkflowStore.getState().setNeedsRedeploymentFlag(data.needsRedeployment)
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error('Failed to check workflow status:', { error })
|
||||
}
|
||||
}
|
||||
checkStatus()
|
||||
}, [activeWorkflowId, setDeploymentStatus])
|
||||
|
||||
/**
|
||||
* Fetches the deployed state of the workflow from the server
|
||||
* This is the single source of truth for deployed workflow state
|
||||
@@ -423,13 +388,6 @@ export function ControlBar() {
|
||||
return () => unsubscribe()
|
||||
}, [])
|
||||
|
||||
// Add a manual method to update the deployment status and clear the needsRedeployment flag
|
||||
const updateDeploymentStatusAndClearFlag = (isDeployed: boolean, deployedAt?: Date) => {
|
||||
setDeploymentStatus(isDeployed, deployedAt)
|
||||
setNeedsRedeployment(false)
|
||||
useWorkflowStore.getState().setNeedsRedeploymentFlag(false)
|
||||
}
|
||||
|
||||
// Update existing API notifications when needsRedeployment changes
|
||||
useEffect(() => {
|
||||
if (!activeWorkflowId) return
|
||||
|
||||
@@ -275,12 +275,6 @@ export function WorkflowBlock({ id, data }: NodeProps<WorkflowBlockProps>) {
|
||||
const visibleSubBlocks = subBlocks.filter((block) => {
|
||||
if (block.hidden) return false
|
||||
|
||||
// Filter by mode if specified
|
||||
if (block.mode) {
|
||||
if (block.mode === 'basic' && isAdvancedMode) return false
|
||||
if (block.mode === 'advanced' && !isAdvancedMode) return false
|
||||
}
|
||||
|
||||
// If there's no condition, the block should be shown
|
||||
if (!block.condition) return true
|
||||
|
||||
|
||||
Reference in New Issue
Block a user