Skip to content

Commit aee1374

Browse files
fix(tables): don't emit stale dispatching event after a mid-window halt
If a cell halts the dispatch mid-window (usage limit), re-read the dispatch status after the batch and bail instead of emitting a per-window 'dispatching' event that would arrive after the client dropped the dispatch and re-add it (flickering 'X running' back).
1 parent 8bd4694 commit aee1374

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

apps/sim/lib/table/dispatcher.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,13 @@ export async function dispatcherStep(dispatchId: string): Promise<DispatcherStep
566566
return 'done'
567567
}
568568

569+
// A cell may have halted the dispatch mid-window (e.g. usage limit calls
570+
// completeDispatchIfActive). Re-read before emitting the per-window
571+
// `dispatching` event — otherwise that stale event arrives after the client
572+
// already dropped the dispatch and re-adds it, flickering "X running" back.
573+
const current = await readDispatch(dispatchId)
574+
if (!current || current.status === 'cancelled' || current.status === 'complete') return 'done'
575+
569576
await Promise.all([
570577
advanceCursor(dispatchId, lastPosition),
571578
appendTableEvent({

0 commit comments

Comments
 (0)