Fix realtime updates for sidebar EmailsList and thread Conversations#32
Draft
Copilot wants to merge 3 commits into
Draft
Fix realtime updates for sidebar EmailsList and thread Conversations#32Copilot wants to merge 3 commits into
Copilot wants to merge 3 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…view Co-authored-by: harshithpabbati <43822585+harshithpabbati@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix realtime updates for emails list and threads
Fix broken realtime updates in sidebar EmailsList and thread Conversations
Mar 1, 2026
…mail insert Co-authored-by: harshithpabbati <43822585+harshithpabbati@users.noreply.github.com>
Copilot
AI
changed the title
Fix broken realtime updates in sidebar EmailsList and thread Conversations
Fix realtime updates for sidebar EmailsList and thread Conversations
Mar 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Realtime was effectively broken in two places: the sidebar never reflected new threads or replies, and the open conversation view never showed incoming messages without a manual refresh.
Root causes
threadrecord when a new email arrived (unless it was reopening a closed thread). With no UPDATE event, theUPDATE_THREADrealtime handler had nothing to catch. For new threads, this also meantpostgres_changesINSERT delivery was the only mechanism, which is unreliable without Realtime explicitly enabled per-table in Supabase.Conversations— the thread detail view was fully static after SSR; new emails only appeared after a full page reload.UPDATElistener inEmailsList— onlyINSERTwas subscribed, so status changes andlast_message_created_atbumps were ignored.Changes
app/api/webhooks/inbound-email/route.tsAlways update
thread.last_message_created_at(and optionallystatus) in a single call after every email insert — new thread or reply:This fires a reliable thread
UPDATEevent on every inbound email, making theUPDATE_THREADhandler the primary realtime path — bypassing the fragile per-table INSERT event delivery.components/organization/sidebar/EmailsList.tsxUPDATElistener alongsideINSERTon thethreadchannel.UPDATE_THREADreducer handles: remove thread if status no longer matches the active filter, add it if it now does, otherwise update-in-place and re-sort bylast_message_created_atdesc.INSERT_THREADnow deduplicates: if the thread was already added via the UPDATE path (or a reconnect replay), the INSERT is a no-op.components/organization/conversation/Conversations.tsxuseState(seeded from SSR prop).email INSERTfiltered bythread_id; new messages append in real time with deduplication.conversationsstate change, not just on mount.channelRefbefore callingunsubscribe()to avoid stale-callback races.💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.