Skip to content

fix: show confirmed attachment sends in chat history - #205932

Merged
obviyus merged 2 commits into
openclaw:mainfrom
RaphLorr:fix/wechat-sent-attachment-preview
Nov 26, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
RaphLorr:fix/wechat-sent-attachment-preview

Conversation

@RaphLorr

@RaphLorr RaphLorr commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Root cause: src/infra/outbound/source-reply-mirror.ts:521 builds the history preview for a message-tool send with the same owner used for replies that have not been delivered yet. When that preview cannot be prepared, its attachment_error block (code delivery-failed, "Not sent · Delivery failed. Try sending this file again.") was stored as-is, even though the channel had already confirmed the send with a platform message id.

Thanks @RaphLorr for the report, the reproduction and the fix.

What Problem This Solves

When the message tool sends a local document to the current channel and the channel confirms it with a platform message id, Control UI could still show a red "Not sent" card for that file. People then resend a document the recipient already has.

Why the preview fails: the preview owner only ingests a local non-image file when the reply payload is explicitly trusted (src/gateway/managed-image-attachments.ts:964, since #130402). A model-chosen local PDF is not, so the item throws, and the catch-all failure code at src/gateway/managed-image-attachments.ts:920 labels that refusal delivery-failed. That trust rule is deliberate and stays unchanged here; the wrong part is only showing it as a delivery failure after a confirmed delivery.

Fix

The source-reply mirror already holds the delivery fact. When the send has a concrete platform message id and the preview contains attachment_error blocks, the display sidecar replaces them with one line: "Attachment sent to the channel. Preview unavailable in chat history."

  • Sends without a platform receipt keep their current display.
  • Previews that succeed (images, trusted files) are unchanged.
  • The media reader, local-file trust and access checks are unchanged.
  • Only openclawDisplayContent (the Control UI display sidecar) changes. The canonical transcript message that replay and model context read is byte-identical to main (evidence below).

Evidence

Real Gateway + Control UI proof on this head (main twice, fix twice, real Chromium, after reload), with controls for an image preview and a send without a platform receipt, and the serialization-boundary check that the canonical transcript entry is byte-identical to main: #205932 (comment)

@RaphLorr's original evidence reproduced the report twice on WeChat with OpenClaw 2026.11.10 (provider returned a platform message id; Control UI showed a failed card).

  • src/infra/outbound/source-reply-mirror.test.ts drives the real preview owner with a local PDF: the receipt case fails on main source and passes here (25/25); importer suites 89/89.
  • Production +13 lines, tests +38 net, against the merge base.

Merge danger

Two-way door. The change only alters what the display sidecar stores for newly mirrored confirmed sends; a revert restores the old card for new rows. Rows written while this is live keep the notice text. Blast radius: Control UI history for message-tool sends with a platform receipt whose preview fails.

@clawsweeper

clawsweeper Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 26, 2026
@clawsweeper

clawsweeper Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: passed.

What this changes

Replace attachment preview errors with a sent notice when the source-conversation delivery has a confirmed platform message ID.

Example: The message tool delivers report.pdf with message ID sent-1, but history cannot prepare its preview.

  • Before: Control UI shows “Not sent” and suggests sending the file again.
  • After: History says “Attachment sent to the channel. Preview unavailable in chat history.”

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A worthwhile, focused repair with shipped-path visual evidence and reported red/green regression validation; required CI is not yet satisfied.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (screenshot): The updated evidence exercises the real message tool through isolated Gateways and the standard loopback media adapter, checks recipient bytes and receipt identity, and shows the corrected shipped Control UI after reload; the inspected screenshots resolve the earlier direct-function-only proof gap.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A recipient receives a document while Control UI tells the sender it was not sent and encourages a duplicate send.
Reason: Accurate delivery status prevents unnecessary resends without adding configuration, public APIs, or another delivery owner.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: current main still mislabels confirmed sends when preview preparation fails, and the focused repair has no actionable correctness findings.

Reviewed head: 7dc1c053422929e4c2ab68d3f177cbfa3f687fa4

Before merge

None.

Findings

None.

Agent review details

How this fits together

The outbound source-reply mirror consumes successful message-tool delivery results and prepared display blocks, then records the source session's assistant history for Control UI.

flowchart LR
  A[Message tool] --> B[Channel delivery]
  B --> C[Delivery fact]
  C --> D[Source reply mirror]
  E[Preview preparation] --> D
  D --> F[Session transcript]
  F --> G[Control UI history]
Loading

Technical review

Best possible solution:

Keep the receipt-aware correction in the existing source-reply mirror and land it once required CI succeeds.

Do we have a high-confidence way to reproduce the issue?

Current-main source exposes the erroneous preview-error path, supported by the contributor's base/head Gateway reproduction and inspected screenshots; this review did not execute target code.

Is this the best way to solve the issue?

The patch is a small, complete correction at the owner that knows both delivery confirmation and preview outcome, preserving media-access checks and receipt-free behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against ef006253e47c.

Provenance checked

  • Source-reply display preparation keeps the original intent (eee457d: The merged repair made successfully delivered source images visible in history using the sender's media reader and existing transcript custody.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Focused introduced change: The pinned introduced diff changes only the existing source-reply mirror and its tests; confirmed receipts replace attachment-error display blocks while retaining other blocks. (src/infra/outbound/source-reply-mirror.ts:530, 7dc1c0534229)
  • Current main retains the defect: Current main passes preview-preparation attachment errors directly into history without distinguishing an already confirmed channel delivery. (src/infra/outbound/source-reply-mirror.ts:530, ef006253e47c)
  • Production settlement boundary: The local send owner invokes mirroring only after settled, non-partial delivery and supplies the delivered payloads and existing media access. (src/infra/outbound/message-action-send.ts:694, 7dc1c0534229)
  • Updated shipped-path proof: The contributor describes isolated base/head Gateways using the real message tool, standard loopback media delivery, matching recipient receipts and PDF bytes, and Control UI reload. All four downloaded screenshots were inspected and show the erroneous resend card before and the sent notice after. (7dc1c0534229)
  • Regression and validation evidence: The two added rows independently protect confirmed-receipt replacement and receipt-free preservation. The updated body reports the confirmed case failing on base, all 25 focused tests passing on head, core typecheck and targeted lint/format passing, and 13 QA delivery contract tests passing; this read-only review ran no tests. (src/infra/outbound/source-reply-mirror.test.ts:207, 7dc1c0534229)
  • Existing-state compatibility: The existing openclawDisplayContent field already accepts text blocks, and transcript preparation reuses persisted display content for an existing idempotent event; the patch adds no stored field, migration, or historical rewrite. (src/config/sessions/transcript.ts:584, 7dc1c0534229)

Likely related people:

  • Peter Steinberger: Raw commit 60c24e3 adds src/infra/outbound/source-reply-mirror.ts:605 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 60c24e3be3f4; files: src/infra/outbound/source-reply-mirror.ts)
  • Firas Alswihry: Raw commit 0df9f29 adds src/infra/outbound/source-reply-mirror.ts:151 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 0df9f297b60c; files: src/infra/outbound/source-reply-mirror.ts)

PR surface

Source +15, Tests +39. Total +54 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 15 0 +15
Tests 1 40 1 +39
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 55 1 +54

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-26T11:53:29.573Z sha 7dc1c05 :: needs real behavior proof before merge. :: none

Reviewed November 26, 2026, 7:23 AM ET / 12:23 UTC (Revision 2).

@RaphLorr
RaphLorr marked this pull request as ready for review November 26, 2026 12:18
@RaphLorr

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Nov 26, 2026
…wner

- Return the notice blocks directly instead of copying into a mutable array.
- Drive the regression through the real preview owner with a local PDF instead of mocking it.
@obviyus

obviyus commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

Proof on exact head a4ab219ed0 against base fa5d2a7ee1 (main twice, fix twice, real Chromium, full page reload).

Setup: each side built from git archive inside a secretless node:24.22.1 container (Gateway dist + Control UI). Each run used a fresh isolated Gateway (--profile p205932base|p205932head, state under /t), the stock qa-channel plugin against a local QA bus stand-in, and a scripted local model. An inbound DM asks for the report; the model calls the real message tool with media: /t/ws/output/report.pdf (current conversation). The bus answers with platform id qa-out-1. Nothing is injected into the preview: it fails naturally on the trust gate for model-chosen local non-image files.

run          channel receipt   Control UI after reload                                               display sidecar block
base-1 pdf   qa-out-1          report.pdf  Not sent · Delivery failed. Try sending this file again.  attachment_error delivery-failed
base-2 pdf   qa-out-1          report.pdf  Not sent · Delivery failed. Try sending this file again.  attachment_error delivery-failed
head-1 pdf   qa-out-1          Attachment sent to the channel. Preview unavailable in chat history.  text notice
head-2 pdf   qa-out-1          Attachment sent to the channel. Preview unavailable in chat history.  text notice
base/head png  qa-out-1        chart.png image preview (unchanged)                                   image (managed)
base/head no receipt (id "")   no mirrored row on either side (unchanged)                            none

Canonical transcript entry (transcript_events.event_json, model: "delivery-mirror"), with openclawDisplayContent split off and only run-specific timestamp/ids normalized: identical on all four PDF runs, sha256 cea39f81a2a7… (base-1, base-2, head-1, head-2). Its content is [{"type":"text","text":"Here is the quarterly report.\nreport.pdf"}] on both sides. Only the display sidecar differs:

base: [{"type":"text","text":"Here is the quarterly report."},{"type":"attachment_error","attachment":{"code":"delivery-failed","kind":"document","label":"report.pdf","mimeType":"application/pdf"}}]
head: [{"type":"text","text":"Here is the quarterly report."},{"type":"text","text":"Attachment sent to the channel. Preview unavailable in chat history."}]

Nothing under src/agents reads openclawDisplayContent, so replay and model context are unaffected.

Why the preview fails (unchanged here, by design): the preview owner runs createManagedOutgoingMediaBlocks, which refuses a local non-image file unless the payload is trusted (src/gateway/managed-image-attachments.ts:964); the catch-all code at :920 then labels it delivery-failed. Probe through buildAssistantReplyContent with the sender's reader: untrusted PDF -> attachment_error delivery-failed ("Managed document attachment "report.pdf" could not be prepared"); PNG -> image; same PDF with trustedLocalMedia: true -> document attachment.

Note: the stock qa-channel send action is text-only, so the bus stand-in received the caption without the file bytes; the platform receipt is what the mirror branches on.

Unit: src/infra/outbound/source-reply-mirror.test.ts now drives the real preview owner with a local PDF. Red on base source (receipt case receives attachment_error), 25/25 green on the head; importer suites 89/89.

Screenshots: main (Not sent), fix (sent notice), controls (image preview, no receipt).

main: Not sent card after reload

fix: sent notice after reload

control: image preview unchanged

control: no receipt, no mirrored row

@obviyus
obviyus merged commit 60ebf18 into openclaw:main Nov 26, 2026
122 checks passed
@obviyus

obviyus commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

Thanks @RaphLorr for finding and fixing this. Landed: when a channel confirms a send with a platform message id but Control UI can't build the history preview, chat history now shows that the attachment was sent instead of a red "Not sent" card. Unconfirmed sends and working previews are unchanged, and the transcript content the model replays is byte-identical. We added one small follow-up commit on top of yours and kept your commit and credit.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 27, 2026
Root cause: `src/infra/outbound/source-reply-mirror.ts:521` builds the history preview for a message-tool send with the same owner used for replies that have not been delivered yet. When that preview cannot be prepared, its `attachment_error` block (code `delivery-failed`, "Not sent · Delivery failed. Try sending this file again.") was stored as-is, even though the channel had already confirmed the send with a platform message id.

Thanks @RaphLorr for the report, the reproduction and the fix.

## What Problem This Solves

When the `message` tool sends a local document to the current channel and the channel confirms it with a platform message id, Control UI could still show a red "Not sent" card for that file. People then resend a document the recipient already has.

Why the preview fails: the preview owner only ingests a local non-image file when the reply payload is explicitly trusted (`src/gateway/managed-image-attachments.ts:964`, since openclaw#130402). A model-chosen local PDF is not, so the item throws, and the catch-all failure code at `src/gateway/managed-image-attachments.ts:920` labels that refusal `delivery-failed`. That trust rule is deliberate and stays unchanged here; the wrong part is only showing it as a delivery failure after a confirmed delivery.

## Fix

The source-reply mirror already holds the delivery fact. When the send has a concrete platform message id and the preview contains `attachment_error` blocks, the display sidecar replaces them with one line: "Attachment sent to the channel. Preview unavailable in chat history."

- Sends without a platform receipt keep their current display.
- Previews that succeed (images, trusted files) are unchanged.
- The media reader, local-file trust and access checks are unchanged.
- Only `openclawDisplayContent` (the Control UI display sidecar) changes. The canonical transcript message that replay and model context read is byte-identical to main (evidence below).

## Evidence

Real Gateway + Control UI proof on this head (main twice, fix twice, real Chromium, after reload), with controls for an image preview and a send without a platform receipt, and the serialization-boundary check that the canonical transcript entry is byte-identical to main: openclaw#205932 (comment)

@RaphLorr's original evidence reproduced the report twice on WeChat with OpenClaw 2026.11.10 (provider returned a platform message id; Control UI showed a failed card).

- `src/infra/outbound/source-reply-mirror.test.ts` drives the real preview owner with a local PDF: the receipt case fails on main source and passes here (25/25); importer suites 89/89.
- Production +13 lines, tests +38 net, against the merge base.

## Merge danger

Two-way door. The change only alters what the display sidecar stores for newly mirrored confirmed sends; a revert restores the old card for new rows. Rows written while this is live keep the notice text. Blast radius: Control UI history for message-tool sends with a platform receipt whose preview fails.

Co-authored-by: Ayaan Zaidi <[email protected]>
kami-saia pushed a commit to kami-saia/openclaw that referenced this pull request Nov 29, 2026
Root cause: `src/infra/outbound/source-reply-mirror.ts:521` builds the history preview for a message-tool send with the same owner used for replies that have not been delivered yet. When that preview cannot be prepared, its `attachment_error` block (code `delivery-failed`, "Not sent · Delivery failed. Try sending this file again.") was stored as-is, even though the channel had already confirmed the send with a platform message id.

Thanks @RaphLorr for the report, the reproduction and the fix.

## What Problem This Solves

When the `message` tool sends a local document to the current channel and the channel confirms it with a platform message id, Control UI could still show a red "Not sent" card for that file. People then resend a document the recipient already has.

Why the preview fails: the preview owner only ingests a local non-image file when the reply payload is explicitly trusted (`src/gateway/managed-image-attachments.ts:964`, since openclaw#130402). A model-chosen local PDF is not, so the item throws, and the catch-all failure code at `src/gateway/managed-image-attachments.ts:920` labels that refusal `delivery-failed`. That trust rule is deliberate and stays unchanged here; the wrong part is only showing it as a delivery failure after a confirmed delivery.

## Fix

The source-reply mirror already holds the delivery fact. When the send has a concrete platform message id and the preview contains `attachment_error` blocks, the display sidecar replaces them with one line: "Attachment sent to the channel. Preview unavailable in chat history."

- Sends without a platform receipt keep their current display.
- Previews that succeed (images, trusted files) are unchanged.
- The media reader, local-file trust and access checks are unchanged.
- Only `openclawDisplayContent` (the Control UI display sidecar) changes. The canonical transcript message that replay and model context read is byte-identical to main (evidence below).

## Evidence

Real Gateway + Control UI proof on this head (main twice, fix twice, real Chromium, after reload), with controls for an image preview and a send without a platform receipt, and the serialization-boundary check that the canonical transcript entry is byte-identical to main: openclaw#205932 (comment)

@RaphLorr's original evidence reproduced the report twice on WeChat with OpenClaw 2026.11.10 (provider returned a platform message id; Control UI showed a failed card).

- `src/infra/outbound/source-reply-mirror.test.ts` drives the real preview owner with a local PDF: the receipt case fails on main source and passes here (25/25); importer suites 89/89.
- Production +13 lines, tests +38 net, against the merge base.

## Merge danger

Two-way door. The change only alters what the display sidecar stores for newly mirrored confirmed sends; a revert restores the old card for new rows. Rows written while this is live keep the notice text. Blast radius: Control UI history for message-tool sends with a platform receipt whose preview fails.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 60ebf18)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants