Skip to content

fix(tables): eliminate checkbox flicker on rapid cell toggle#4592

Merged
waleedlatif1 merged 3 commits into
stagingfrom
waleedlatif1/table-fast-select-jitter
May 14, 2026
Merged

fix(tables): eliminate checkbox flicker on rapid cell toggle#4592
waleedlatif1 merged 3 commits into
stagingfrom
waleedlatif1/table-fast-select-jitter

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • Patch row cache from the PATCH response in useUpdateTableRow instead of blanket-invalidating, so rapid keyboard toggles no longer get clobbered by a stale refetch
  • Guard useBatchUpdateTableRows invalidation with isMutating({ mutationKey }) === 1 so only the final mutation in a burst refetches
  • Add tableKeys.rowWrites mutation key + await cancelQueries in onMutate

Type of Change

  • Bug fix

Testing

Tested manually — rapid Enter+ArrowUp toggling no longer flashes previously-checked rows.

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)

@vercel
Copy link
Copy Markdown

vercel Bot commented May 14, 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 14, 2026 2:41am

Request Review

@gitguardian
Copy link
Copy Markdown

gitguardian Bot commented May 14, 2026

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them.
While these secrets were previously flagged, we no longer have a reference to the
specific commits where they were detected. Once a secret has been leaked into a git
repository, you should consider it compromised, even if it was deleted immediately.
Find here more information about risks.


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@cursor
Copy link
Copy Markdown

cursor Bot commented May 14, 2026

PR Summary

Medium Risk
Changes React Query mutation behavior and cache reconciliation for table row updates; mistakes could leave stale row data or missed invalidations under concurrent/burst edits.

Overview
Eliminates row checkbox flicker during rapid edits by making row-write mutations more deterministic.

Row update hooks now use a dedicated tableKeys.rowWrites(tableId) mutationKey, await query cancellation in onMutate, and reconcile the cache from the PATCH response in useUpdateTableRow (updating only the mutated fields and server-provided metadata) instead of relying solely on blanket invalidation.

Row data invalidation in both useUpdateTableRow and useBatchUpdateTableRows is now guarded so only the final mutation in a burst triggers a refetch.

Reviewed by Cursor Bugbot for commit 944d7dd. Configure here.

@waleedlatif1 waleedlatif1 force-pushed the waleedlatif1/table-fast-select-jitter branch from 5bc1350 to 10ec81d Compare May 14, 2026 01:59
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 14, 2026

Greptile Summary

This PR fixes checkbox flicker on rapid cell toggles by switching from blanket query invalidation on every mutation settlement to a targeted cache-patch strategy. It introduces a shared mutationKey (tableKeys.rowWrites) across both single-row and batch mutations, adds onSuccess cache patching for single-row updates using the server response, and guards the final invalidateRowData call so only the last in-flight mutation triggers a reconciliation refetch.

  • useUpdateTableRow: onMutate is now correctly async/await, a new onSuccess merges only the mutated keys from the server response into the cached row (preserving concurrent optimistic updates like executions), and onSettled invalidates only when this is the last pending rowWrites mutation.
  • useBatchUpdateTableRows: Same await cancelQueries fix and guarded onSettled, but no onSuccess cache patch — the batch path still relies solely on the guarded invalidation for server reconciliation.

Confidence Score: 5/5

Safe to merge — the change correctly narrows cache invalidation and adds server-confirmed patching without breaking the rollback or reconciliation paths.

The await cancelQueries fix prevents in-flight refetches from clobbering optimistic updates. The onSuccess merge only touches the keys that were mutated in the request, so concurrent optimistic updates are preserved. The shared mutationKey plus isMutating === 1 guard correctly defers the reconciliation refetch until the burst completes, and onSettled still fires on error so rollback plus eventual refetch both work.

No files require special attention; the only file changed is apps/sim/hooks/queries/tables.ts.

Important Files Changed

Filename Overview
apps/sim/hooks/queries/tables.ts Core mutation hooks updated with shared mutationKey, awaited cancelQueries, onSuccess cache patch for single-row writes, and guarded onSettled invalidation; batch path lacks an onSuccess equivalent.

Reviews (4): Last reviewed commit: "fix(tables): merge only mutated keys in ..." | Re-trigger Greptile

Comment thread apps/sim/hooks/queries/tables.ts
Comment thread apps/sim/hooks/queries/tables.ts
Comment thread apps/sim/hooks/queries/tables.ts Outdated
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/hooks/queries/tables.ts
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread apps/sim/hooks/queries/tables.ts
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 944d7dd. Configure here.

@waleedlatif1 waleedlatif1 merged commit 104949b into staging May 14, 2026
14 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/table-fast-select-jitter branch May 14, 2026 02:52
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