Skip to content

fix(table): show Stop / X-running for edit-triggered auto-runs#4682

Merged
TheodoreSpeaks merged 1 commit into
stagingfrom
fix/table-run-counter-edit-path
May 20, 2026
Merged

fix(table): show Stop / X-running for edit-triggered auto-runs#4682
TheodoreSpeaks merged 1 commit into
stagingfrom
fix/table-run-counter-edit-path

Conversation

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator

Summary

  • The "X running" badge and per-row gutter Stop only updated on manual Run (useRunColumn bumped the run-state counter). Edit-triggered auto-runs (useUpdateTableRow, useBatchUpdateTableRows, useCreateTableRow) stamped cells pending in the rows cache but never bumped runningCellCount / runningByRowId, so Stop stayed hidden even though cells were queued.
  • Extracted countNewlyInFlight + bumpRunState helpers and wired them into all optimistic auto-fire paths with onError rollback; reused them in useRunColumn to dedupe.
  • The counter is already queued-inclusive (countRunningCells server + applyCell SSE both count queued/running/pending), so this makes Stop appear the moment auto-fired cells go queued.

Type of Change

  • Bug fix

Testing

Tested manually on staging; tsc, vitest (lib/table + hooks/queries, 202 passing), lint, and check:api-validation:strict all pass.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…d cells

The "X running" badge + per-row gutter Stop only updated on manual Run
(useRunColumn bumped the run-state counter). Edit-triggered auto-runs
(useUpdateTableRow, useBatchUpdateTableRows, useCreateTableRow) stamped cells
pending in the rows cache but never bumped runningCellCount/runningByRowId, so
Stop stayed hidden even though cells were queued (the counter is already
queued-inclusive). Extracted countNewlyInFlight + bumpRunState helpers and
wired them into all the optimistic auto-fire paths with onError rollback;
reused them in useRunColumn.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped May 20, 2026 9:01pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented May 20, 2026

PR Summary

Medium Risk
Touches optimistic React Query cache updates and run-state counters; incorrect deltas or rollback could briefly misreport running counts in the UI, but changes are localized to client-side state.

Overview
Fixes a UI inconsistency where edit-triggered auto-runs would optimistically mark cells pending but would not update the table run-state cache, leaving the “X running” badge and per-row Stop button stale until refetch.

Adds shared helpers (countNewlyInFlight, bumpRunState) to compute the in-flight delta and bump runningCellCount/runningByRowId, then wires them into optimistic auto-fire paths in useCreateTableRow, useUpdateTableRow, and useBatchUpdateTableRows, with rollback via cached activeDispatches snapshots on mutation error. Also refactors useRunColumn to reuse the same bump/rollback logic (removing duplicated counter-update code).

Reviewed by Cursor Bugbot for commit 6128714. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 20, 2026

Greptile Summary

This PR fixes the "X running" badge and per-row Stop button not appearing for edit-triggered auto-runs (useUpdateTableRow, useBatchUpdateTableRows, useCreateTableRow). Previously only useRunColumn bumped runningCellCount; the edit paths stamped cells pending in the row cache but never updated the run-state counter.

  • Extracts countNewlyInFlight and bumpRunState helpers and wires them into all three edit mutation hooks, with onError rollback for the update mutations.
  • Refactors useRunColumn.onMutate to reuse the same helpers, removing a copy of the bump logic.

Confidence Score: 4/5

Safe to merge — the core fix is correct and well-structured with no data loss or security concerns.

The bumpRunState refactor is sound and rollback wiring in onError is correct. Two minor gaps exist: useCreateTableRow discards the snapshot, and useBatchUpdateTableRows has no onSuccess guard. Neither causes data corruption — just a potentially stale badge until the next refetch.

apps/sim/hooks/queries/tables.ts — the useCreateTableRow onSuccess bump (snapshot discarded) and useBatchUpdateTableRows missing onSuccess guard.

Important Files Changed

Filename Overview
apps/sim/hooks/queries/tables.ts Adds countNewlyInFlight + bumpRunState helpers and wires them into useCreateTableRow, useUpdateTableRow, useBatchUpdateTableRows, and (refactored) useRunColumn to surface Stop/badge state for edit-triggered auto-runs. Rollback on error is implemented for update mutations; useCreateTableRow discards the snapshot and useBatchUpdateTableRows lacks an onSuccess guard similar to useRunColumn's dispatchId check.

Comments Outside Diff (1)

  1. apps/sim/hooks/queries/tables.ts, line 785-786 (link)

    P2 useBatchUpdateTableRows has no onSuccess handler — orphaned optimistic bump

    useRunColumn.onSuccess explicitly rolls back runningCellCount when the response carries no dispatchId, guarding against the case where the server processed the request but created no dispatch. useBatchUpdateTableRows (and useUpdateTableRow) bump the counter in onMutate but have no onSuccess guard. If optimisticallyScheduleNewlyEligibleGroups predicts auto-fire but the server skips it (schema race, server-side eligibility divergence), the counter stays elevated and the Stop button remains visible with nothing running, until the next full activeDispatches refetch.

Reviews (1): Last reviewed commit: "fix(table): bump run counter on edit/aut..." | Re-trigger Greptile

Comment thread apps/sim/hooks/queries/tables.ts
@TheodoreSpeaks TheodoreSpeaks merged commit 4445e31 into staging May 20, 2026
14 checks passed
@TheodoreSpeaks TheodoreSpeaks deleted the fix/table-run-counter-edit-path branch May 20, 2026 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant