fix: prevent delivered message status from regressing#535
Conversation
LXMF fires spurious failure/sent callbacks after a message is already confirmed delivered. This triggered propagation retries that overwrote 'delivered' (double checkmark) with 'propagated' (single checkmark). Python: add _successfully_delivered tracking set (mirrors existing _successfully_propagated pattern) to guard _on_message_delivered, _on_message_failed, and _on_message_sent from regressing state. Kotlin: make 'delivered' truly terminal — block any status update that would change it to a non-delivered state (defense-in-depth). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Greptile SummaryThis PR implements a robust fix for LXMF's spurious callback issue where delivered messages regress to propagated/sent status. The solution uses defense-in-depth: Python layer (
Kotlin layer (
Testing (
The implementation is clean, well-documented, and addresses the root cause with appropriate logging for debugging. Confidence Score: 4/5
Important Files Changed
Last reviewed commit: 14425c4 |
| self._successfully_propagated = {} # {msg_hash_hex: timestamp} - messages that reached relay | ||
| self._successfully_delivered = {} # {msg_hash_hex: timestamp} - messages confirmed by recipient |
There was a problem hiding this comment.
These dicts are accessed from multiple threads (LXMF callbacks + cleanup loop) without locks. Consider using threading.Lock() similar to announce_lock on line 484 to prevent race conditions during concurrent read/modify operations.
Prompt To Fix With AI
This is a comment left during a code review.
Path: python/reticulum_wrapper.py
Line: 547-548
Comment:
These dicts are accessed from multiple threads (LXMF callbacks + cleanup loop) without locks. Consider using `threading.Lock()` similar to `announce_lock` on line 484 to prevent race conditions during concurrent read/modify operations.
How can I resolve this? If you propose a fix, please make it concise.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Summary
delivered(double checkmark) withpropagated(single checkmark)_successfully_deliveredtracking set to guard_on_message_delivered,_on_message_failed, and_on_message_sentfrom regressing already-delivered messagesdeliveredtruly terminal — blocks any status update that would change it to a non-delivered state (defense-in-depth)Evidence
Device logs showing the bug and fix working:
Test plan
MessageStatusIconTesttests passMessagingViewModelTeststatus degradation tests passpropagated/retrying_propagated/sentstatus blocked when message already delivered🤖 Generated with Claude Code