Fix messages not being sent after attachment upload completes in background#6324
Conversation
…achments Co-Authored-By: Claude <noreply@anthropic.com>
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
SDK Size Comparison 📏
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughAdded a call to Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
|
|
🚀 Available in v6.37.1 |



Goal
Fix a race condition where messages with attachments are never sent to the server after a successful CDN upload, causing them to disappear from the UI until the app is restarted.
Implementation
The attachment upload flow uses a WorkManager worker (
UploadAttachmentsWorker) for the actual CDN upload and an in-memory coroutine observer (AttachmentsUploadStates) to bridge the result back toAttachmentsSender.waitForAttachmentsToBeSent(), which gates thedoSendMessagecall.When the worker finds that all attachments are already uploaded (
!hasPendingAttachment), it returned early without notifyingAttachmentsUploadStates. This left the in-memory observer hanging indefinitely, sowaitForAttachmentsToBeSentnever completed anddoSendMessagewas never called.This happens when:
updateMessages()UploadState.Success, and takes the early-return path — without signaling the observerThe fix adds
AttachmentsUploadStates.updateMessageAttachments(message)to the early-return branch so the observer receives the success signal anddoSendMessageproceeds.UI Changes
No UI changes.
Testing
Summary by CodeRabbit