Skip to content

Commit 9f30cb7

Browse files
fix(table): seed dispatch overlay on Run; surface batch-enqueue failures as error
- useRunColumn.onSuccess invalidates activeDispatches so the resolveCellExec queued overlay populates immediately for ahead-of-cursor rows instead of waiting for the first dispatch SSE. Rows cache stays owned by SSE. - On batchEnqueueAndWait failure, dispatcherStep flips orphan pre-stamps to a terminal error state (+ cell SSE) instead of deleting them, so the dropped window is visible (Error pill) rather than silently empty and re-runs on the next manual run.
1 parent 655269e commit 9f30cb7

2 files changed

Lines changed: 4 additions & 17 deletions

File tree

apps/sim/hooks/queries/tables.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,14 +1378,8 @@ export function useRunColumn({ workspaceId, tableId }: RowMutationContext) {
13781378
if (context?.snapshots) restoreCachedWorkflowCells(queryClient, context.snapshots)
13791379
},
13801380
onSuccess: () => {
1381-
// Seed the active-dispatch overlay from the server. `runWorkflowColumn`
1382-
// inserts the dispatch row synchronously before responding, so the
1383-
// refetch picks it up immediately — this drives `resolveCellExec`'s
1384-
// queued overlay for rows ahead of the cursor (scrolled-in / refetched
1385-
// rows that have no real exec yet) without waiting for the first
1386-
// `kind: 'dispatch'` SSE. Targeted at activeDispatches only — NOT the
1387-
// rows cache, which `useTableEventStream` owns (a rows refetch would
1388-
// race its incremental patches).
1381+
// Seed the active-dispatch overlay immediately (insertDispatch ran
1382+
// server-side before responding); rows cache stays owned by SSE.
13891383
void queryClient.invalidateQueries({ queryKey: tableKeys.activeDispatches(tableId) })
13901384
},
13911385
})

apps/sim/lib/table/dispatcher.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -399,15 +399,8 @@ export async function dispatcherStep(dispatchId: string): Promise<DispatcherStep
399399
logger.error(`[${dispatchId}] batch dispatch failed`, {
400400
error: toError(err).message,
401401
})
402-
// The enqueue failed (e.g. trigger.dev API down) — these cells never
403-
// ran. The cursor still advances past this window below, so they won't
404-
// be retried in this dispatch. Flip the orphan pre-stamps to a terminal
405-
// `error` state (with an SSE event) instead of deleting them: the
406-
// failure stays visible to the user (Error pill, not a silently-empty
407-
// cell), the cells aren't stuck `pending` forever, and `error` cells
408-
// re-run on the next manual run (classifyEligibility treats error as
409-
// eligible for manual / incomplete). Guarded on `pending + null
410-
// executionId` so we only touch our own un-claimed pre-stamps.
402+
// Cursor advances past this window, so flip the un-claimed pre-stamps to
403+
// terminal `error` (+ SSE) — visible, not stuck pending, re-runnable.
411404
const failedAt = new Date()
412405
await Promise.allSettled(
413406
pendingRuns.map(async (p) => {

0 commit comments

Comments
 (0)