@@ -6,17 +6,18 @@ import type { V2AddWorkflowGroupBody } from '@/lib/api/contracts/v2/tables'
66import { OrchestrationError } from '@/lib/core/orchestration/types'
77import { runDetached } from '@/lib/core/utils/background'
88import { generateRequestId } from '@/lib/core/utils/request'
9- import type {
10- ColumnDefinition ,
11- DeleteWorkflowGroupData ,
12- TableDefinition ,
13- TableSchema ,
14- UpdateWorkflowGroupData ,
15- WorkflowGroup ,
16- WorkflowGroupDependencies ,
17- WorkflowGroupDeploymentMode ,
18- WorkflowGroupInputMapping ,
19- WorkflowGroupOutput ,
9+ import {
10+ type ColumnDefinition ,
11+ type DeleteWorkflowGroupData ,
12+ getColumnId ,
13+ type TableDefinition ,
14+ type TableSchema ,
15+ type UpdateWorkflowGroupData ,
16+ type WorkflowGroup ,
17+ type WorkflowGroupDependencies ,
18+ type WorkflowGroupDeploymentMode ,
19+ type WorkflowGroupInputMapping ,
20+ type WorkflowGroupOutput ,
2021} from '@/lib/table'
2122import { defineAuthorizedTableUseCase } from '@/lib/table/application/authorized-table-use-case'
2223import { resolveActiveTableContext } from '@/lib/table/application/context'
@@ -298,6 +299,7 @@ export const createWorkflowTableGroup = defineAuthorizedTableUseCase({
298299 ...( input . name ? { name : input . name } : { } ) ,
299300 ...( input . dependencies ? { dependencies : input . dependencies } : { } ) ,
300301 ...( input . deploymentMode ? { deploymentMode : input . deploymentMode } : { } ) ,
302+ autoRun : input . autoRun ?? false ,
301303 outputs,
302304 }
303305 const actorUserId = attributedUserId ( principal , context . billedAccountUserId )
@@ -678,7 +680,19 @@ export const updateWorkflowTableGroup = defineAuthorizedTableUseCase({
678680 const existingByKey = new Map (
679681 previousGroup . outputs . map ( ( output ) => [ `${ output . blockId } ::${ output . path } ` , output ] )
680682 )
681- const taken = new Set ( context . table . schema . columns . map ( ( column ) => column . name ) )
683+ const requestedKeys = new Set (
684+ input . outputs . map ( ( output ) => `${ output . blockId } ::${ output . path } ` )
685+ )
686+ const releasedColumnIds = new Set (
687+ previousGroup . outputs
688+ . filter ( ( output ) => ! requestedKeys . has ( `${ output . blockId } ::${ output . path } ` ) )
689+ . map ( ( output ) => output . columnName )
690+ )
691+ const taken = new Set (
692+ context . table . schema . columns
693+ . filter ( ( column ) => ! releasedColumnIds . has ( getColumnId ( column ) ) )
694+ . map ( ( column ) => column . name )
695+ )
682696 outputs = [ ]
683697 newOutputColumns = [ ]
684698 for ( const requested of input . outputs ) {
0 commit comments