Files
multica/server
Naiyuan Qing e8575139f3 fix(inbox): drop list invalidate after known-effect mutations
Cursor-paginated useInfiniteQuery refetches every loaded page with its
cached pageParam on invalidate. After a row is archived, page 0 (no
cursor) shifts up to include items previously on page 1, while page 1
still uses a cursor pointing at the now-archived row — so the same
item appears on both pages. The old client-side deduplicateInboxItems
masked this; deleting it surfaced the bug.

Mutations whose effect the client can predict EXACTLY apply
optimistically and skip the list invalidate (only unread-count gets
invalidated, single-query immune to the cross-page issue):
  - markRead / archive / markAllRead / archiveAll / archiveAllRead

archiveCompletedInbox is the lone exception — its server-side filter
on issue.status can't be enumerated client-side, so it still
invalidates the list and inherits the rare cross-page risk on deeply
paginated caches. Same trade-off as timeline today.

Adds optimistic onMutate to archiveAll / archiveAllRead which
previously fell through to invalidate-only.

Also:
- rename filterAllItems → removeMatchingItems with explicit doc; the
  predicate semantics are *removal* (true → drop), opposite of
  Array.filter, easy to invert by mistake.
- 069 migration comment now echoes 068's CONCURRENTLY trade-off and
  sets a "revisit when inbox_item exceeds ~1M rows" threshold rather
  than handwaving "pre-production scale".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 16:46:53 +08:00
..