feat: Optimistic UI Updates (JEF-74) - #197
Conversation
- Star toggle: instant flip on detail page and board/list caches - Status change: card moves instantly on Kanban drag-and-drop - Note/Contact/InterviewRound CRUD: create/update/delete reflected immediately - Document delete: removed from list immediately - All mutations snapshot cache in onMutate, rollback on error, invalidate on settled
WalkthroughApplication detail and board mutations now update cached data immediately. Failed mutations restore previous cache values. Settled mutations invalidate related queries to reconcile local state with the server. ChangesApplication cache consistency
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Preview deployments for this PR: |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/web/src/routes/_authenticated/applications/$applicationId/index.tsx (1)
166-204: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick winCancel the board-cache query before the optimistic star update.
setQueriesDatawrites to queries matching['applications'], including['applications', null], butonMutateonly cancels['application', applicationId]. Cancel the same['applications']filter before writing optimistically, then avoid the duplicate['applications']invalidation inonErrorbecauseonSettledinvalidates it afterwards.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/src/routes/_authenticated/applications/`$applicationId/index.tsx around lines 166 - 204, Update toggleStar.onMutate to cancel queries matching the same non-exact ['applications'] filter used by setQueriesData before applying the optimistic board-cache update, including ['applications', null]. Remove the redundant ['applications'] invalidation from onError, relying on onSettled to perform that invalidation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@apps/web/src/routes/_authenticated/applications/`$applicationId/index.tsx:
- Around line 166-204: Update toggleStar.onMutate to cancel queries matching the
same non-exact ['applications'] filter used by setQueriesData before applying
the optimistic board-cache update, including ['applications', null]. Remove the
redundant ['applications'] invalidation from onError, relying on onSettled to
perform that invalidation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f991bbfd-7492-4407-b65e-6d37e9a1a942
📒 Files selected for processing (2)
apps/web/src/routes/_authenticated/applications/$applicationId/index.tsxapps/web/src/routes/_authenticated/applications/-board-page.tsx
Summary
Adds optimistic UI updates for all frequently-used mutations so changes feel instant instead of waiting for a server round-trip.
Changes
Star toggle (highest impact)
Kanban board drag-and-drop
Note / Contact / Interview Round CRUD
Document delete
Pattern
All mutations follow the TanStack Query optimistic update pattern:
Testing
Closes JEF-74
Summary by CodeRabbit