Repository navigation
fix(chat): keep notifications when fetching new messages while paused - #6841
Conversation
fetchNewMessages sent no markNotificationsAsRead=0, so the insurance poll running in the background made the server dismiss the user's chat notifications right after they were shown. Let the fetch clear notifications only while the chat is on screen (not paused); servers without chat-keep-notifications ignore the parameter. Signed-off-by: Krainov Gleb <krajnov.g@kontentplus.ru> Assisted-by: Claude-Code:claude-opus-5-5
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to Paused fetches now send the keep-notifications field, while resumed fetches retain the prior request behavior. The changed request path and regression assertion are verified, with no actionable merge-blocking risk identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)✅ Passed checks (4 passed)
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 |
rapterjet2004
left a comment
There was a problem hiding this comment.
LGTM, thanks for the thorough analysis. Resume order is fine (handleOnResume() runs before the resume fetch), and the new test covers all three states.
One thing to fix before merge: check-ai-trailers fails because Assisted-by: Claude-Code:claude-opus-5-5 doesn't match the allowed agent names. Something like Assisted-by: Claude Code (claude-opus-5-5) should pass.
Optional nit: tryCloseBacklog reads the pause state once, so if the chat pauses between rounds of a large backlog, the later rounds still clear notifications. Rare, and similar to the in-flight gap you already mention; passing a () -> Boolean would close it.
|
Thanks! The trailer is detected: the job log shows |
Symptom
A chat notification disappears right after it is shown while the conversation is still open in the back stack (app in the background, or another screen on top). In a log from one device (Huawei DEL-LX9, high performance backend), a chat notification was removed 0.45 s after it was shown: the server sent a delete push, and
GET notifications/<id>inNotificationWorkerreturned 404.Cause
OfflineFirstChatRepository.fetchNewMessages()callsChatMessageSyncer.tryCloseBacklog()withoutmarkNotificationsAsRead, so the defaulttrueapplies and the request carries nomarkNotificationsAsRead=0.ChatManager::waitForNewMessages, parameter inChatController::receiveMessages.fetchNewMessages()also runs while the chat is not on screen: the insurance request loop (every 2 minutes), messages from signaling, and the fetch after an upload or share completes. In the log above, the insurance request started when the process was woken by the push, about 0.1 s before the notification was fetched.ChatMessageSyncer.fetchRoomCatchUp, added in 🔄️ Chat message pre-fetching #6454) already passesmarkNotificationsAsRead = false;fetchNewMessages()was not covered.Change
fetchNewMessages()passesmarkNotificationsAsRead = !itIsPaused, reusing the existing pause flag of the repository (set byhandleOnPause/handleOnResume).ChatViewModel.onResumecallshandleOnResume()before itsfetchNewMessages(), so this fetch still clears notifications, as before.markNotificationsAsRead=0. Notifications are then cleared when the user reads the chat (setReadMarker,ChatController::setReadMarker) or when the chat is resumed.itIsPausedis now@Volatile: it is written on the main thread and read from fetch coroutines.chat-keep-notificationscapability ignore the parameter, so nothing changes for them. The fetch is not gated by the capability because the open chat still needs it.Not covered: a request that already started before
onPausecan still clear notifications.How to test
GET .../chat/<token>?...lookIntoFuture=1...withoutmarkNotificationsAsRead=0. After: the request carriesmarkNotificationsAsRead=0and the notification stays.Unit test:
OfflineFirstChatRepositoryTest—fetchNewMessages keeps notifications only while the chat is paused(fails without the change).Not yet tested on a device after the change.
Related
The insurance requests keep running while the chat is paused; skipping them is a separate PR (#6842). That PR alone does not fix this one: signaling and upload paths still call
fetchNewMessages()while paused.Related by area: #6763 (marks prefetch requests next to
markNotificationsAsReadinChatMessageSyncer), #6370 (read marker set by polling).🖼️ Screenshots
Not applicable.
🚧 TODO
🏁 Checklist
/backport to stable-xx.x🤖 AI (if applicable)
The analysis, code, test and this description were prepared with Claude Code (claude-opus-5-5) and reviewed by me. The commit carries an
Assisted-bytrailer.