Fix message flash/disappear on send#307
Conversation
WalkthroughTreats temporary session IDs prefixed with Changes
Sequence Diagram(s)(omitted) Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
0c04e28 to
703a97c
Compare
|
@EricBlanquer can you also send detailed reproduction steps for this (including which LLM you picked for testing)? |
Fixes a race condition where user messages would briefly disappear then reappear when sending new messages. Root cause: 1. App.jsx: File watcher checked activeSessions.has(selectedSession.id) but didn't account for temporary new-session-* IDs, causing premature message reloads 2. ChatInterface.jsx: useEffect syncing chatMessages with convertedMessages ran even during isLoading, overwriting optimistic UI updates Changes: - App.jsx (line 189): Include temporary session IDs in active session check to prevent race condition - ChatInterface.jsx (line 3139): Skip chatMessages sync during isLoading to preserve optimistic updates Tested: Message now stays visible during send/response cycle without flashing
010e5db to
462738d
Compare
|
@EricBlanquer I tried your reproduction and this is what I see on this branch: There seems to be a lag to see the message after sending a new one. Screen.Recording.2026-01-27.173947.mp4 |


Description
Fixes a race condition where user messages would briefly disappear then reappear when sending new messages.
Root Cause
The issue was caused by two independent code paths that could overwrite optimistic UI updates:
App.jsx (line 189): The file watcher checked
activeSessions.has(selectedSession.id)but didn't account for temporarynew-session-*IDs. This causedexternalMessageUpdateto be incremented prematurely, triggering a message reload.ChatInterface.jsx (line 3139): The useEffect syncing
chatMessageswithconvertedMessagesran even duringisLoading, overwriting optimistic UI updates before the server responded.Changes
App.jsx
activeSessionshasn't been updated yet with the real session IDChatInterface.jsx
!isLoadingcondition to the chatMessages sync useEffectTesting
✅ Tested: Messages now stay visible during the entire send/response cycle without flashing
Why Both Fixes Are Needed
externalMessageUpdatefrom triggering the useEffect at line 3102, which callssetChatMessages(converted)directly (bypassingisLoadingprotection)convertedMessagesWithout both fixes, messages can still flash via the unprotected code path.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.