fix(tables): scope optimistic stop-cancel to the active filtered view#4996
fix(tables): scope optimistic stop-cancel to the active filtered view#4996TheodoreSpeaks wants to merge 1 commit into
Conversation
A filtered select-all Stop only cancels matching rows server-side, but the optimistic update flipped in-flight cells across every cached rows query — stale unfiltered views showed workflows as cancelled until the refetch. snapshotAndMutateRows gains an onlyKey option; the cancel mutation passes the active view's exact cache key (filter + sort) when a filter is present, and onSettled's invalidation reconciles other views. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview
Reviewed by Cursor Bugbot for commit afc9fbc. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryThis PR fixes a stale-state bug where an optimistic "Stop All" with an active filter was flipping
Confidence Score: 5/5Safe to merge — the change is a targeted, well-scoped fix that reduces collateral cache mutation without altering the server-side behaviour or the onSettled reconciliation path. The fix is self-contained: onlyKey narrows an optimistic update that was previously too broad, and the fallback to rowsRoot prefix-match preserves all existing non-filtered code paths. The key construction uses the same TABLE_LIMITS.MAX_QUERY_LIMIT and tableRowsParamsKey serialisation that the cache was originally populated with (confirmed in use-table.ts), so the exact-match lookup is reliable. onSettled still invalidates all row views, keeping consistency as a safety net. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant UI as table.tsx / table-grid.tsx
participant Hook as useCancelTableRuns
participant QC as React Query Cache
participant Server as API /cancel-runs
UI->>Hook: onStopAllRows(filter, sort, excludeRowIds)
Note over Hook: filter present → build onlyKey
Hook->>QC: "cancelQueries({ queryKey: onlyKey, exact: true })"
Note over QC: Only cancels in-flight fetch for active filtered view
Hook->>QC: "getQueriesData({ queryKey: onlyKey, exact: true })"
Note over QC: Snapshot only the active view
Hook->>QC: setQueryData(onlyKey, optimisticCancel)
Note over QC: Other cached views unchanged
Hook->>Server: "POST /cancel-runs { scope: all, filter, excludeRowIds }"
Server-->>Hook: 200 OK
Hook->>QC: invalidateQueries(rowsRoot) — reconciles all views
Reviews (1): Last reviewed commit: "fix(tables): scope optimistic stop-cance..." | Re-trigger Greptile |
Follow-up to #4915 (raced the merge by minutes — Bugbot finding on the final review pass).
A filtered select-all Stop only cancels matching rows server-side, but the optimistic update flipped in-flight cells across every cached rows query — stale unfiltered views showed workflows as cancelled until the next refetch.
snapshotAndMutateRowsgains anonlyKeyoption (exact-key scoping)onSettled's invalidation reconciles other views as beforeTest plan
bunx vitest run hooks/queries lib/table app/api/table(380 tests)🤖 Generated with Claude Code