Skip to content

Commit 7c97335

Browse files
fix(table): scope post-clear schedule to targeted groups, forward mode
Multi-group manual runs (Run row, gutter Play, action-bar Play across mixed completed + cancelled cells) re-fired completed-and-filled siblings. runWorkflowGroupsInternal cleared only the groups it filtered, then called scheduleRunsForRows with isManualRun: true and no group / mode filter — so the post-clear pass walked every group on the table with default mode 'all', and any autoRun=true completed sibling whose deps were satisfied got queued again. Scope the post-clear call to targetGroups and forward mode.
1 parent c1aa02c commit 7c97335

1 file changed

Lines changed: 18 additions & 7 deletions

File tree

apps/sim/lib/table/workflow-columns.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,15 @@ export function isGroupEligible(
7373
}
7474

7575
/**
76-
* Shared options for the three `scheduleRuns*` entry points. `groupId` scopes
77-
* to one workflow group; auto-fire callers omit it. `isManualRun` flips two
78-
* gates in the eligibility predicate so a manual click can re-run terminal
79-
* states and bypass the autoRun=false skip.
76+
* Shared options for the three `scheduleRuns*` entry points. `isManualRun`
77+
* flips two gates in the eligibility predicate so a manual click can re-run
78+
* terminal states and bypass the autoRun=false skip.
8079
*/
8180
export interface ScheduleOpts {
8281
groupId?: string
82+
groupIds?: string[]
8383
isManualRun?: boolean
84+
mode?: 'all' | 'incomplete'
8485
}
8586

8687
/**
@@ -98,7 +99,12 @@ export async function scheduleRunsForRows(
9899
if (allGroups.length === 0) return { triggered: 0 }
99100
if (rows.length === 0) return { triggered: 0 }
100101

101-
const groups = opts?.groupId ? allGroups.filter((g) => g.id === opts.groupId) : allGroups
102+
const groupIdFilter = opts?.groupIds
103+
? new Set(opts.groupIds)
104+
: opts?.groupId
105+
? new Set([opts.groupId])
106+
: null
107+
const groups = groupIdFilter ? allGroups.filter((g) => groupIdFilter.has(g.id)) : allGroups
102108
if (groups.length === 0) return { triggered: 0 }
103109

104110
const orderedRows = rows.length <= 1 ? rows : [...rows].sort((a, b) => a.position - b.position)
@@ -107,7 +113,8 @@ export async function scheduleRunsForRows(
107113

108114
for (const row of orderedRows) {
109115
for (const group of groups) {
110-
if (!isGroupEligible(group, row, { isManualRun: opts?.isManualRun })) continue
116+
if (!isGroupEligible(group, row, { isManualRun: opts?.isManualRun, mode: opts?.mode }))
117+
continue
111118
pendingRuns.push({
112119
tableId: table.id,
113120
tableName: table.name,
@@ -469,7 +476,11 @@ async function runWorkflowGroupsInternal(opts: {
469476
// satisfied would race the manual call.
470477
await batchUpdateRows({ tableId, updates, workspaceId, skipScheduler: true }, table, requestId)
471478

472-
return scheduleRunsForRows(table, clearedRows, { isManualRun: true })
479+
return scheduleRunsForRows(table, clearedRows, {
480+
isManualRun: true,
481+
groupIds: targetGroups.map((g) => g.id),
482+
mode,
483+
})
473484
}
474485

475486
/**

0 commit comments

Comments
 (0)