Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
import { getBaseUrl } from '@/lib/core/utils/urls'
import { getInputFormatExample as getInputFormatExampleUtil } from '@/lib/workflows/operations/deployment-utils'
import { useUserPermissionsContext } from '@/app/workspace/[workspaceId]/providers/workspace-permissions-provider'
import { runPreDeployChecks } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/hooks/use-predeploy-checks'
import { CreateApiKeyModal } from '@/app/workspace/[workspaceId]/w/components/sidebar/components/settings-modal/components/api-keys/components'
import { startsWithUuid } from '@/executor/constants'
import { useA2AAgentByWorkflow } from '@/hooks/queries/a2a/agents'
Expand All @@ -38,6 +39,7 @@ import { useWorkspaceSettings } from '@/hooks/queries/workspace'
import { usePermissionConfig } from '@/hooks/use-permission-config'
import { useSettingsModalStore } from '@/stores/modals/settings/store'
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
import { mergeSubblockState } from '@/stores/workflows/utils'
import { useWorkflowStore } from '@/stores/workflows/workflow/store'
import type { WorkflowState } from '@/stores/workflows/workflow/types'
import { A2aDeploy } from './components/a2a/a2a'
Expand Down Expand Up @@ -335,6 +337,20 @@ export function DeployModal({
setDeployError(null)
setDeployWarnings([])

const { blocks, edges, loops, parallels } = useWorkflowStore.getState()
const liveBlocks = mergeSubblockState(blocks, workflowId)
const checkResult = runPreDeployChecks({
blocks: liveBlocks,
edges,
loops,
parallels,
workflowId,
})
if (!checkResult.passed) {
setDeployError(checkResult.error || 'Pre-deploy validation failed')
return
}

try {
const result = await deployMutation.mutateAsync({ workflowId, deployChatEnabled: false })
if (result.warnings && result.warnings.length > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import { useCallback, useState } from 'react'
import { createLogger } from '@sim/logger'
import { useNotificationStore } from '@/stores/notifications'
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
import { mergeSubblockState } from '@/stores/workflows/utils'
import { useWorkflowStore } from '@/stores/workflows/workflow/store'
import { runPreDeployChecks } from './use-predeploy-checks'

const logger = createLogger('useDeployment')

Expand All @@ -25,36 +22,16 @@ export function useDeployment({
const [isDeploying, setIsDeploying] = useState(false)
const setDeploymentStatus = useWorkflowRegistry((state) => state.setDeploymentStatus)
const addNotification = useNotificationStore((state) => state.addNotification)
const blocks = useWorkflowStore((state) => state.blocks)
const edges = useWorkflowStore((state) => state.edges)
const loops = useWorkflowStore((state) => state.loops)
const parallels = useWorkflowStore((state) => state.parallels)

/**
* Handle deploy button click
* First deploy: calls API to deploy, then opens modal on success
* Redeploy: validates client-side, then opens modal if valid
* Already deployed: opens modal directly (validation happens on Update in modal)
*/
const handleDeployClick = useCallback(async () => {
if (!workflowId) return { success: false, shouldOpenModal: false }

if (isDeployed) {
const liveBlocks = mergeSubblockState(blocks, workflowId)
const checkResult = runPreDeployChecks({
blocks: liveBlocks,
edges,
loops,
parallels,
workflowId,
})
if (!checkResult.passed) {
addNotification({
level: 'error',
message: checkResult.error || 'Pre-deploy validation failed',
workflowId,
})
return { success: false, shouldOpenModal: false }
}
return { success: true, shouldOpenModal: true }
}

Expand Down Expand Up @@ -101,17 +78,7 @@ export function useDeployment({
} finally {
setIsDeploying(false)
}
}, [
workflowId,
isDeployed,
blocks,
edges,
loops,
parallels,
refetchDeployedState,
setDeploymentStatus,
addNotification,
])
}, [workflowId, isDeployed, refetchDeployedState, setDeploymentStatus, addNotification])

return {
isDeploying,
Expand Down
34 changes: 34 additions & 0 deletions apps/sim/stores/terminal/console/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,40 @@ export const useTerminalConsoleStore = create<ConsoleStore>()(

return { entries: updatedEntries }
})

if (typeof update === 'object' && update.error) {
const settings = getQueryClient().getQueryData<GeneralSettings>(
generalSettingsKeys.settings()
Comment thread
waleedlatif1 marked this conversation as resolved.
Outdated
)
Comment thread
waleedlatif1 marked this conversation as resolved.
Comment thread
waleedlatif1 marked this conversation as resolved.
const isErrorNotificationsEnabled = settings?.errorNotificationsEnabled ?? true

if (isErrorNotificationsEnabled) {
try {
const matchingEntry = get().entries.find(
(e) => e.blockId === blockId && e.executionId === executionId
)
const errorMessage = String(update.error)
const blockName = matchingEntry?.blockName || 'Unknown Block'
const displayMessage = `${blockName}: ${errorMessage}`
const copilotMessage = `${errorMessage}\n\nError in ${blockName}.\n\nPlease fix this.`

useNotificationStore.getState().addNotification({
level: 'error',
message: displayMessage,
workflowId: matchingEntry?.workflowId,
action: {
type: 'copilot',
message: copilotMessage,
},
})
} catch (notificationError) {
logger.error('Failed to create block error notification', {
blockId,
error: notificationError,
})
}
}
}
Comment thread
waleedlatif1 marked this conversation as resolved.
},

cancelRunningEntries: (workflowId: string) => {
Expand Down