File tree Expand file tree Collapse file tree 5 files changed +20
-5
lines changed
app/workspace/[workspaceId]/w
[workflowId]/components/panel/components/editor/components/sub-block/components/workflow-selector
components/preview/components
preview-workflow/components/block Expand file tree Collapse file tree 5 files changed +20
-5
lines changed Original file line number Diff line number Diff line change 11'use client'
22
33import { useMemo } from 'react'
4+ import { DELETED_WORKFLOW_LABEL } from '@/app/workspace/[workspaceId]/logs/utils'
45import { SelectorCombobox } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/selector-combobox/selector-combobox'
56import type { SubBlockConfig } from '@/blocks/types'
67import type { SelectorContext } from '@/hooks/selectors/types'
@@ -40,7 +41,7 @@ export function WorkflowSelectorInput({
4041 isPreview = { isPreview }
4142 previewValue = { previewValue }
4243 placeholder = { subBlock . placeholder || 'Select workflow...' }
43- missingOptionLabel = 'Deleted Workflow'
44+ missingOptionLabel = { DELETED_WORKFLOW_LABEL }
4445 />
4546 )
4647}
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ import {
3434 isSubBlockFeatureEnabled ,
3535 isSubBlockVisibleForMode ,
3636} from '@/lib/workflows/subblocks/visibility'
37+ import { DELETED_WORKFLOW_LABEL } from '@/app/workspace/[workspaceId]/logs/utils'
3738import { SubBlock } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components'
3839import { PreviewContextMenu } from '@/app/workspace/[workspaceId]/w/components/preview/components/preview-context-menu'
3940import { PreviewWorkflow } from '@/app/workspace/[workspaceId]/w/components/preview/components/preview-workflow'
@@ -1327,7 +1328,9 @@ function PreviewEditorContent({
13271328 ) : (
13281329 < div className = 'flex h-full items-center justify-center bg-[var(--surface-3)]' >
13291330 < span className = 'text-[13px] text-[var(--text-tertiary)]' >
1330- { isMissingChildWorkflow ? 'Deleted Workflow' : 'Unable to load preview' }
1331+ { isMissingChildWorkflow
1332+ ? DELETED_WORKFLOW_LABEL
1333+ : 'Unable to load preview' }
13311334 </ span >
13321335 </ div >
13331336 ) }
Original file line number Diff line number Diff line change 99 isSubBlockFeatureEnabled ,
1010 isSubBlockVisibleForMode ,
1111} from '@/lib/workflows/subblocks/visibility'
12+ import { DELETED_WORKFLOW_LABEL } from '@/app/workspace/[workspaceId]/logs/utils'
1213import { getDisplayValue } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/workflow-block'
1314import { getBlock } from '@/blocks'
1415import { SELECTOR_TYPES_HYDRATION_REQUIRED , type SubBlockConfig } from '@/blocks/types'
@@ -112,7 +113,7 @@ function resolveWorkflowName(
112113 if ( ! rawValue || typeof rawValue !== 'string' ) return null
113114
114115 const workflowMap = useWorkflowRegistry . getState ( ) . workflows
115- return workflowMap [ rawValue ] ?. name ?? 'Deleted Workflow'
116+ return workflowMap [ rawValue ] ?. name ?? DELETED_WORKFLOW_LABEL
116117}
117118
118119/**
Original file line number Diff line number Diff line change @@ -50,6 +50,8 @@ function prepareLogData(
5050
5151export async function emitWorkflowExecutionCompleted ( log : WorkflowExecutionLog ) : Promise < void > {
5252 try {
53+ if ( ! log . workflowId ) return
54+
5355 const workflowData = await db
5456 . select ( { workspaceId : workflow . workspaceId } )
5557 . from ( workflow )
Original file line number Diff line number Diff line change @@ -293,7 +293,10 @@ export class ExecutionLogger implements IExecutionLoggerService {
293293 }
294294
295295 try {
296- const [ wf ] = await db . select ( ) . from ( workflow ) . where ( eq ( workflow . id , updatedLog . workflowId ) )
296+ // Skip workflow lookup if workflow was deleted
297+ const wf = updatedLog . workflowId
298+ ? ( await db . select ( ) . from ( workflow ) . where ( eq ( workflow . id , updatedLog . workflowId ) ) ) [ 0 ]
299+ : undefined
297300 if ( wf ) {
298301 const [ usr ] = await db
299302 . select ( { id : userTable . id , email : userTable . email , name : userTable . name } )
@@ -461,7 +464,7 @@ export class ExecutionLogger implements IExecutionLoggerService {
461464 * Maintains same logic as original execution logger for billing consistency
462465 */
463466 private async updateUserStats (
464- workflowId : string ,
467+ workflowId : string | null ,
465468 costSummary : {
466469 totalCost : number
467470 totalInputCost : number
@@ -494,6 +497,11 @@ export class ExecutionLogger implements IExecutionLoggerService {
494497 return
495498 }
496499
500+ if ( ! workflowId ) {
501+ logger . debug ( 'Workflow was deleted, skipping user stats update' )
502+ return
503+ }
504+
497505 try {
498506 // Get the workflow record to get the userId
499507 const [ workflowRecord ] = await db
You can’t perform that action at this time.
0 commit comments