Skip to content

Commit 414ca52

Browse files
committed
fix(tables): run-all selection sends all rows to server, not just loaded pages
When rowSelection.kind === 'all', selectedRunScope now flags allRows: true. The action-bar run handlers pass rowIds: undefined to the server when allRows is set, matching the server contract (missing rowIds = run all eligible rows). Stop likewise routes through scope: 'all' instead of per-row cancels. Previously, selecting all rows and clicking Run would silently only run the rows loaded in the current infinite-query cache (potentially one page of 1000 on a 5000-row table).
1 parent adbf9dd commit 414ca52

2 files changed

Lines changed: 29 additions & 17 deletions

File tree

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/table-grid.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export interface SelectionSnapshot {
9797
hasWorkflowColumns: boolean
9898
/** Cells the Play / Refresh / Stop buttons act on. Null when the selection
9999
* contains no workflow output cells. */
100-
selectedRunScope: { groupIds: string[]; rowIds: string[] } | null
100+
selectedRunScope: { groupIds: string[]; rowIds: string[]; allRows: boolean } | null
101101
/** Drives Play (`hasIncompleteOrFailed`) / Refresh (`hasCompleted`) /
102102
* Stop (`hasInFlight`) visibility on the action bar. */
103103
selectionStats: ExecStatusMix
@@ -2804,12 +2804,12 @@ export function TableGrid({
28042804
const selectedRunScope = useMemo<SelectionSnapshot['selectedRunScope']>(() => {
28052805
if (tableWorkflowGroupIds.length === 0) return null
28062806
if (!rowSelectionIsEmpty(rowSelection)) {
2807-
const rowIds: string[] = []
2808-
for (const row of rows) {
2809-
if (rowSelectionIncludes(rowSelection, row.id)) rowIds.push(row.id)
2807+
if (rowSelection.kind === 'all') {
2808+
return { groupIds: tableWorkflowGroupIds, rowIds: rows.map((r) => r.id), allRows: true }
28102809
}
2810+
const rowIds = rows.filter((r) => rowSelectionIncludes(rowSelection, r.id)).map((r) => r.id)
28112811
if (rowIds.length === 0) return null
2812-
return { groupIds: tableWorkflowGroupIds, rowIds }
2812+
return { groupIds: tableWorkflowGroupIds, rowIds, allRows: false }
28132813
}
28142814
const sel = normalizedSelection
28152815
if (!sel) return null
@@ -2827,7 +2827,7 @@ export function TableGrid({
28272827
if (row) rowIds.push(row.id)
28282828
}
28292829
if (rowIds.length === 0) return null
2830-
return { groupIds: [...groupIdsInRect], rowIds }
2830+
return { groupIds: [...groupIdsInRect], rowIds, allRows: false }
28312831
}, [rowSelection, normalizedSelection, rows, displayColumns, tableWorkflowGroupIds])
28322832

28332833
const selectionStats = useMemo<SelectionSnapshot['selectionStats']>(() => {

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/table.tsx

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -513,17 +513,29 @@ export function Table({
513513
hasWorkflowColumns={selection.hasWorkflowColumns}
514514
showPlay={selection.selectionStats.hasIncompleteOrFailed}
515515
showRefresh={selection.selectionStats.hasCompleted}
516-
onPlay={() =>
517-
selection.selectedRunScope &&
518-
runScope({ ...selection.selectedRunScope, runMode: 'incomplete' })
519-
}
520-
onRefresh={() =>
521-
selection.selectedRunScope &&
522-
runScope({ ...selection.selectedRunScope, runMode: 'all' })
523-
}
524-
onStopWorkflows={() =>
525-
selection.selectedRunScope && onStopRows(selection.selectedRunScope.rowIds)
526-
}
516+
onPlay={() => {
517+
const scope = selection.selectedRunScope
518+
if (!scope) return
519+
runScope({
520+
groupIds: scope.groupIds,
521+
rowIds: scope.allRows ? undefined : scope.rowIds,
522+
runMode: 'incomplete',
523+
})
524+
}}
525+
onRefresh={() => {
526+
const scope = selection.selectedRunScope
527+
if (!scope) return
528+
runScope({
529+
groupIds: scope.groupIds,
530+
rowIds: scope.allRows ? undefined : scope.rowIds,
531+
runMode: 'all',
532+
})
533+
}}
534+
onStopWorkflows={() => {
535+
const scope = selection.selectedRunScope
536+
if (!scope) return
537+
scope.allRows ? onStopAll() : onStopRows(scope.rowIds)
538+
}}
527539
onViewExecution={
528540
selection.singleWorkflowCell?.canViewExecution &&
529541
selection.singleWorkflowCell.executionId

0 commit comments

Comments
 (0)