Skip to content

fix(review): IDB-aware invalidation, mark-read rollback + review cleanups - #36

Merged
dPeluChe merged 1 commit into
mainfrom
chore/post-waves-review
Jun 10, 2026
Merged

dPeluChe merged 1 commit into
mainfrom
chore/post-waves-review

Conversation

@dPeluChe

Copy link
Copy Markdown
Owner

High-effort code review over the four audit waves (5d288cc..HEAD): 3 finder agents (line-by-line, removed-behavior + cross-file, cleanup angles), candidates verified against the code. 2 confirmed bug classes fixed + 3 cleanups applied. The refuted candidates (normal TTL semantics, speculative future-change risks) were dropped.

🔴 Confirmed & fixed

1. The IDB pref layer silently defeated react-query invalidation

GitHubIssueModal.refresh() invalidated ['issues','search'] — but the queryFn reads the issueSearch: IDB pref first, which was still fresh → close/comment an issue and the feed resurrects the old state for up to 5 minutes. (Sentry resolve already did this right by dropping its prefix — the pattern existed, it just wasn't shared.)
Fix: new db.clearPrefsByPrefix(), called before invalidating; SentryIssueModal reuses it; the helper's docstring makes the mutations-must-drop-the-pref contract explicit for everything future.

2. Mark-as-read had no rollback

The optimistic removal also persisted to IDB — a failed PATCH showed an error but left local state permanently desynced from GitHub.
Fix: onError drops the notifications: pref and refetches, re-syncing with the server.

🧹 Cleanups (from the review's reuse/efficiency angles)

  • CopyButton now uses the useFlash hook instead of duplicating its timer logic.
  • searchIssues paginates at 100/page (GraphQL search max) — half the requests for the same 200 cap.
  • Notifications grouping computes each group's recency once (first item of the desc-sorted list) instead of a Math.max scan per sort comparison.

Verified clean (no action)

Relay hardening, demo branches, pagination loops (cursor always advances, caps hold), useFlash adoptions, Dexie v4 drop (zero remaining readers).

npm run check green · 29/29 tests.

🤖 Generated with Claude Code

…nups

Post-waves high-effort code review (range 5d288cc..HEAD) — fixes the confirmed
findings:

Correctness
- The IDB pref layer silently defeated react-query invalidation: GitHubIssueModal
  invalidated ['issues','search'] but the queryFn reads the issueSearch: pref
  first, so a closed/commented issue resurrected for up to 5 minutes. New
  db.clearPrefsByPrefix() is now called before invalidating; SentryIssueModal's
  inline equivalent reuses it. The helper's doc makes the contract explicit for
  future mutations.
- Mark-as-read had no rollback: the optimistic removal also persisted to IDB, so
  a failed PATCH left local state permanently out of sync with GitHub. onError
  now drops the notifications pref and refetches to re-sync with the server.

Cleanups (review's reuse/efficiency angles)
- CopyButton now uses the useFlash hook instead of duplicating its timer logic.
- searchIssues paginates at 100/page (GraphQL search max) — half the requests
  for the same 200 cap.
- Notifications grouping computes each group's recency once (first item of the
  desc-sorted list) instead of a Math.max scan per sort comparison.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dPeluChe
dPeluChe merged commit 2bff69e into main Jun 10, 2026
1 check passed
@dPeluChe
dPeluChe deleted the chore/post-waves-review branch June 10, 2026 06:10
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