-
Notifications
You must be signed in to change notification settings - Fork 732
Fix message flash/disappear on send #307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix message flash/disappear on send #307
Conversation
WalkthroughTreats temporary session IDs prefixed with Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
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 |
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
0c04e28 to
703a97c
Compare
|
@EricBlanquer can you also send detailed reproduction steps for this (including which LLM you picked for testing)? |


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.