Repository navigation
fix(whatsapp): retain unmatched attachments across captioned replacement - #131672
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 4:30 PM ET / 20:30 UTC. ClawSweeper reviewWhat this changesThe PR changes WhatsApp deferred-media replacement so only accepted matching attachments are superseded and unmatched attachments remain queued for settlement. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open for maintainer review: current main still contains the whole-payload overlap discard, while this PR moves ownership to per-attachment provider acceptance. No introduced blocking correctness defect was found; channel-boundary proof or a recorded exception remains the landing risk. Priority: P1 Review scores
Verification
How this fits togetherWhatsApp inbound reply handling buffers media-only tool output until a later captioned reply replaces it or turn settlement flushes it. Provider send receipts determine which queued attachments were delivered and which message-sent events are emitted. flowchart LR
A[Tool media reply] --> B[Deferred attachment queue]
C[Captioned reply] --> D[Per-attachment matching]
D --> E[WhatsApp media transport]
E --> F[Accepted provider receipt]
F --> G[Settlement]
G --> H[Message-sent events]
Decision needed
Why: The source repair and focused tests are coherent, but only a maintainer can accept an exception to the repository's normal channel-boundary proof expectation. Before merge
Agent review detailsSecurityNone. PR surfaceSource -49, Tests +242, Docs +1. Total +194 across 6 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the receipt-level supersession design and capture a redacted mock-gateway or live WhatsApp trace for deferred multi-attachment output followed by a captioned partial replacement before landing. Do we have a high-confidence way to reproduce the issue? No runtime reproduction was run in this read-only review, but current-main source makes the A,B followed by captioned A scenario reproducible with high confidence. Is this the best way to solve the issue? Yes. Moving supersession to the accepted-media receipt boundary avoids treating a visible caption or unrelated attachment as proof that every queued attachment was delivered; channel-boundary evidence remains needed before landing. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4c6ed51733d3. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
Track WhatsApp acceptance per media URL so captioned replacements supersede only delivered attachments. Keep unmatched media under the original deferred finalization, preserve hook vetoes and partial-send errors, and share one ordered media-send branch.
Move overlap regressions to the canonical message_sent boundary and assert retained provider receipts, finalization visibility, and duplicate-free observer outcomes.
b0e001f to
10eda0e
Compare
|
Merged via squash.
|
…ent (openclaw#131672) * fix(whatsapp): retain unmatched attachments across captioned replacement Track WhatsApp acceptance per media URL so captioned replacements supersede only delivered attachments. Keep unmatched media under the original deferred finalization, preserve hook vetoes and partial-send errors, and share one ordered media-send branch. * test(whatsapp): verify attachment remainders through core settlement Move overlap regressions to the canonical message_sent boundary and assert retained provider receipts, finalization visibility, and duplicate-free observer outcomes.
Important
review-required: per-attachment delivery/finalization semantics. Prepared under the auto-QA campaign from a channel-delivery audit (finding C1). Changes WhatsApp attachment finalization ownership, so this stays a draft for maintainer review.
What Problem This Solves
A WhatsApp reply that sends multiple images and is then followed by a captioned replacement sharing one image silently dropped the unmatched image. A multi-image tool response
mediaUrls:[A,B]enters the deferred-media path; a latertext:"Here is A", mediaUrls:[A]replacement — because the dedup tested whether any URL overlapped — resolved the entire pending[A,B]batch as non-visible and removed it. The recipient got A, never B, with no error and a misleading "superseded" message; settlement could not flush the removed remainder.Why This Change Was Made
The invariant: replacing attachment A must not discard an unsent attachment B just because they share a logical payload — every admitted attachment gets delivery or an accurate recorded non-outcome. The fix subtracts only the attachments actually covered by the replacement and retains the unmatched units with their finalization ownership, recording real per-attachment acceptance instead of inferring "some content became visible." This also let the owner shed accumulated cruft: the whole-batch overlap-discard (introduced by
a2efabf4c93, retained through66a75bb9e52), a redundant post-canonical URL normalization, four duplicated media-send branches, and an ID-compare acceptance inference all removed — net −49 production lines.User Impact
[A,B]followed by a captioned[A]now delivers B exactly once and does not re-deliver A; a full[A,B]→[A,B]replacement still supersedes cleanly; a non-overlapping[A,B]→[C]is unchanged; a vetoed or errored replacement still suppresses / surfaces its error.Evidence
message-planalready account per-attachment; verified unaffected).[A,B]→[A]produced[[A]]pre-fix,[[A],[B]]after (realcreateWhatsAppReplyPlan+ injected accepting transport, original prepare→tool→final→settled order).message_sentsuite. Post-rebase whatsapp inbound-dispatch suite green; changed-file gate + two Codex autoreviews clean.