Mark pending channel messages sent on RESP_CODE_SENT#186
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d270683d25
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (_retryService != null) { | ||
| _retryService!.updateMessageFromSent(ackHash, timeoutMs); | ||
| } | ||
| _markMostRecentPendingChannelMessageSent(); |
There was a problem hiding this comment.
Restrict channel sent updates to channel ACKs
_handleMessageSent now calls _markMostRecentPendingChannelMessageSent() for every full RESP_CODE_SENT, but those responses are also used for direct messages. If a user has any pending outgoing channel message and then sends a direct message, the direct-message ACK will incorrectly flip that channel message to sent even though no channel send confirmation was received, producing false delivery state in the channel UI/storage.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch. Updated in 96fb9ca: channel pending→sent is now gated so it only runs when RESP_CODE_SENT was not matched to a direct message and there are no pending direct retries. This prevents direct-message ACKs from flipping channel state.
| if (_markMostRecentPendingChannelMessageSent()) { | ||
| return; |
There was a problem hiding this comment.
Preserve direct fallback handling for short sent frames
In the legacy fallback path (frame.length < 10), returning immediately after marking a pending channel message means the previous direct-message fallback loop is skipped whenever any channel message is pending. On older firmware/protocol variants that emit short RESP_CODE_SENT frames, this leaves outgoing direct messages stuck in pending as long as a channel pending message exists.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed in 96fb9ca. I removed the early channel return from the short-frame fallback path; frame.length < 10 now preserves the original direct-message fallback loop so direct pending messages are still advanced on legacy short sent frames.
I need to switch to in progress as this is still not properly catching all acks. |
|
Update: fixed channel sent-state feedback for hardware that returns RESP_CODE_OK (code=0) instead of RESP_CODE_SENT (code=6) after channel sends. What changed:
Validation:
I will test with additional hardware soon and report any behavior differences. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e8e422f054
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| final queuedMessageId = _pendingChannelCommandAckQueue.removeAt(0); | ||
| _markPendingChannelMessageSentById(queuedMessageId); |
There was a problem hiding this comment.
Stop treating generic RESP_CODE_OK as a channel send ACK
_handleOk dequeues and marks a pending channel message as sent for every RESP_CODE_OK, but RESP_CODE_OK is a generic success code (see docs/BLE_PROTOCOL.md), not a channel-send-specific ACK. This means any unrelated OK response (for example, contact import/export flows that listen for OK in lib/screens/contacts_screen.dart) can incorrectly flip an unsent channel message to sent, and then the real send confirmation may advance the next queued message.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed in f733129. RESP_CODE_OK no longer blindly dequeues channel state. sendFrame now tracks only commands that explicitly opt into generic ACK correlation, and channel pending->sent on OK happens only when the dequeued command is CMD_SEND_CHANNEL_TXT_MSG. Contacts import/export/zero-hop now opt in too, so their OK responses no longer advance channel send state.
| _pendingChannelSentQueue.add(message.messageId); | ||
| _pendingChannelCommandAckQueue.add(message.messageId); |
There was a problem hiding this comment.
Queue reaction sends before consuming RESP_CODE_SENT
Only the non-reaction branch enqueues message IDs here, but reactions still send CMD_SEND_CHANNEL_TXT_MSG and can produce RESP_CODE_SENT. Because _handleMessageSent consumes one queued channel ID for unmatched sent responses, a sent response generated by a reaction can be applied to a different pending channel message, causing premature sent state in channel history.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed in f733129. Reaction channel sends now enqueue a dedicated queue token before CMD_SEND_CHANNEL_TXT_MSG, and _markNextPendingChannelMessageSent consumes that token without promoting an unrelated pending message. This prevents reaction-generated RESP_CODE_SENT from being applied to another channel message.
|
Follow-up pushed in f733129 to address the latest review feedback:
darT analyze checks run on updated files: no issues. |
Problem
Outgoing channel messages can remain in a pending state even after the app receives
RESP_CODE_SENT, especially in sparse/public-channel paths where echo timing is delayed.Solution
RESP_CODE_SENT, mark the most recent pending outgoing channel message assentScope
lib/connector/meshcore_connector.dartonlyValidation
flutter analyzepassesflutter testpassesCloses #185