Skip to content

[Chat] revalidate join links on leave - #10833

Merged
mozzius merged 2 commits into
mainfrom
samuel/revaldate-join-links
Jun 10, 2026
Merged

mozzius merged 2 commits into
mainfrom
samuel/revaldate-join-links

Conversation

@mozzius

@mozzius mozzius commented Jun 10, 2026 •

Copy link
Copy Markdown
Member

## Test plan

  • Have a join link pointing to a convo you're in
  • Leave the convo
  • Confirm card updates state immediately

@github-actions

github-actions Bot commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor
Old size New size Diff
7.73 MB 7.73 MB 522 B (0.01%)

@mozzius

mozzius commented Jun 10, 2026

Copy link
Copy Markdown
Member Author

@claude please review

@claude

claude Bot commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @mozzius's task in 1m 26s —— View job


Review

  • Load PR context
  • Read changed files
  • Analyze changes
  • Post review

The PR cleanly addresses the stale-preview problem after leaving a convo, with both the imperative (leave mutation) and reactive (event log) paths covered. Code is well-documented and follows codebase patterns. A few small notes:

src/state/queries/join-links.ts

The new invalidateJoinLinkPreviewsForConvo predicate short-circuits on the root key first (good — keeps the scan cheap across unrelated queries), then narrows preview entries via the type guard. The cast on query.state.data is unavoidable here since TanStack types query data as unknown — the runtime guard inside .some(...) keeps it safe.

One small thought: invalidateJoinLinkPreviewsForCode reads the query args to match, while this one reads the query data. That asymmetry is fine and well-explained in the docstring ("the code isn't always known to the viewer"), but it does mean previews that are still pending/errored (no data yet) won't be matched. In practice that's a non-issue — there's nothing to invalidate if there's no data — just worth knowing.

src/state/queries/messages/leave-conversation.ts:76-78

if (convoId) {
  void invalidateJoinLinkPreviewsForConvo(queryClient, convoId)
}

The if (convoId) guard is defensive — mutationFn already throws when convoId is undefined, so onSuccess is unreachable without one. But TypeScript needs the narrow, so this is reasonable as-is. No change needed.

Note that this will fire alongside the logLeaveConvo invalidation that arrives via the event bus shortly after — React Query coalesces, so it just means one extra predicate scan. Not worth optimizing.

src/state/queries/messages/list-conversations.tsx:259-265

Nice catch on the "removed members receive logLeaveConvo, not logRemoveMember" subtlety — the comment is the kind of WHY-comment that pays for itself.

Possible follow-up (out of scope)

The symmetric case isn't covered: when the viewer joins a convo (via isLogMemberJoin for themselves, or isLogBeginConvo), any cached preview pointing at that convo still shows the pre-join state until it goes stale. Probably fine to leave for a follow-up — the leave case is the one users actually report, since they're staring at a preview card after the action. Worth flagging in case it bites later.

Verdict

LGTM. The implementation is correct, scoped tight, and the test plan is the right way to verify it.
• samuel/revaldate-join-links

@arcalinea
arcalinea temporarily deployed to samuel/revaldate-join-links - social-app PR #10833 June 10, 2026 08:30 — with Render Destroyed
@mozzius
mozzius merged commit d6a14ad into main Jun 10, 2026
19 checks passed
estrattonbailey added a commit that referenced this pull request Jun 10, 2026
…uttons

* origin/main: (149 commits)
  Tweak spacing in invite link dialog (#10829)
  [Chat] Fix source of truth for group size limit (#10845)
  [Chat] Sync convo agent with shadow cache (#10827)
  [Chat] Some tweaks (#10840)
  [Chat] Fix optimistic updates by using partial keys (#10838)
  Remove leave-convo suppression, use real optimistic update (#10834)
  use opus 4.8 in github claude (#10837)
  [Chat] revalidate join links on leave (#10833)
  Clear search term after adding chat member (#10831)
  Support dim theme on join request landing page (#10832)
  Nightly source-language update
  bskyweb: meta noindex tag for non-indexable pages (#10803)
  Hide domain if matches handle, new Standard Site icon treatment (#10767)
  Fix image collapse in FF (#10826)
  Change Ignore to Reject for chat invites (#10825)
  [Chat] add lil gap between chats on web (#10821)
  Add list of mutual chats to block dialog (#10727)
  Address chat design nits (#10823)
  Fix link to profile from chat invite embed (#10822)
  [Chat] Show invite link label in chat list preview (#10811)
  ...

This branch was successfully deployed

No deployments
samuel/revaldate-join-links - social-app PR #10833 — bcceee50 Deployed Jun 10, 2026 by arcalinea
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.

2 participants