Repository navigation
Remove leave-convo suppression, use real optimistic update - #10834
Conversation
|
useLeftConvos() filtered convos out of every list based on leave-mutation state, working around a slow backend leaveConvo query. now that the backend is fast, replace it with a working optimistic update: the old onMutate used setQueryData with just the root key, which never matched any real query, so it was a no-op. switch to setQueriesData (prefix match) across both the convo-list and requests caches, with snapshot rollback on error, mirroring useAcceptConversation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
6304647 to
fce5402
Compare
|
@claude please review |
|
Claude finished @mozzius's task in 1m 56s —— View job ReviewThe refactor is clean and the diagnosis is correct: the old A couple of small observations, no blockers: 1. Defensive guard asymmetry — The convo-list updater filters on 2. Pending-refetch race window The old suppression mechanism kept convos hidden even across refetches ( 3. Test plan
4. Nit: backwards-compat type alias
Overall: 👍 — this is a strict improvement: removes a wide-blast-radius workaround, fixes the underlying optimistic-update bug, and updates the requests cache too (which the old code didn't touch). I traced all 9
|
…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) ...
Why
When you leave a chat, we currently suppress it from the frontend in a heavy-handed way:
useLeftConvos()reads React Query mutation state (pending and success) and every list surface (ListConvosProvider,ChatList,Header,Inbox) filters those convo IDs out. This was a workaround for a slow backendleaveConvoquery (30+ seconds, sometimes timing out), where the convo had to stay hidden long after refetches would have clobbered an optimistic cache edit.The backend query is now fast, so this can all go.
The bug the workaround was hiding
useLeaveConvo'sonMutatealready attempted an optimistic update, but it calledsetQueryData([CONVO_LIST_KEY])— an exact key match against just the root'convo-list'. Real queries are keyed['convo-list', 'accepted', ...],['convo-list', 'request', ...], etc., so the update never matched anything and was a no-op. That's why the suppression layer was needed in the first place.What changed
leave-conversation.ts:onMutatenow usessetQueriesData(prefix match) to optimistically remove the convo from all convo-list queries, and also from the requests cache (optimisticDeletefromlist-conversation-requests), which the old code never touchedonError, then invalidates both roots — same pattern asuseAcceptConversationuseLeftConvos()list-conversations.tsx,ChatList.tsx,Inbox.tsx: removed theleftConvosfilteringNo changes needed at the 8
useLeaveConvocall sites — the hook's signature is unchanged.Test plan
pnpm typecheck,pnpm lint,pnpm test🤖 Generated with Claude Code