Skip to content

fix(webchat): render generated documents as attachments - #130402

Merged
vyctorbrzezowski merged 5 commits into
openclaw:mainfrom
vyctorbrzezowski:fix/webchat-media-artifacts
Aug 28, 2026
Merged

vyctorbrzezowski merged 5 commits into
openclaw:mainfrom
vyctorbrzezowski:fix/webchat-media-artifacts

Conversation

@vyctorbrzezowski

@vyctorbrzezowski vyctorbrzezowski commented Aug 26, 2026 •

Copy link
Copy Markdown
Member

Closes #130338

What Problem This Solves

WebChat could strip generated local-document MEDIA: directives without creating downloadable attachment cards. Current-source message-tool replies also lost filename, MIME, and per-item trust metadata before managed-media persistence.

Why This Change Was Made

The existing managed outgoing media owner now receives one atomic prepared-media item per source and emits document attachment envelopes through the existing SQLite record, authenticated download, cleanup, and artifact lifecycle. Current-source, embedded-run, restart-recovery, and normal WebChat projection all preserve the same filename, MIME, trust, and playback metadata.

Unsupported active or opaque formats keep the existing security boundary and now produce bounded visible failure guidance rather than disappearing. No schema, retention, or protocol version changed.

Product decision: legacy managed SVG records remain unavailable with HTTP 404; this intentionally keeps the active-content download boundary closed rather than reviving previously stored SVG capabilities.

User Impact

Generated JSON, CSV, YAML, Markdown, plain text, trusted generated HTML, PDF, ZIP, DOCX, and XLSX files appear as named attachment cards. WAV, MP3, and MP4 use managed playback cards; PNG and JPEG keep image previews and their source labels. XML, SVG, Python, JavaScript, and unknown binary files remain rejected by host-read policy, with a visible retry message and no raw MEDIA: leakage.

Evidence

Before

WebChat history rendered document directives as raw text:

Before: raw MEDIA directives in WebChat

Current 20-format proof

The deterministic flow uses one mock-provider response, an ephemeral Gateway, a real WebChat client, workspace files, and chat.history. It validates 20 outcomes: 15 structured artifacts and five policy rejections represented by visible failure guidance.

{"expected":20,"observed":20,"missing":[],"rawMediaVisible":false}

JSON, CSV, YAML, Markdown, text, and trusted generated HTML:

Text and markup MIME cards

PDF, ZIP, DOCX, and XLSX:

Office and archive MIME cards

WAV, MP3, and MP4:

Audio and video MIME cards

PNG and JPEG previews with original source labels:

PNG and JPEG previews

XML, SVG, Python, JavaScript, and unknown binary remain blocked and end visibly:

Rejected formats with visible warning

All five current screenshots are dark-mode Control UI captures generated from the fresh Gateway transcript and inspected after capture.

Validation

Production LOC: +547/-245 (net +302). Tests: +1081/-68 (net +1013). Production growth consolidates atomic media metadata, managed document projection, source-reply persistence/recovery, sanitizer capability stripping, and visible failure preservation into existing owner paths; no parallel store or fallback was added.

AI-assisted: yes. I reviewed the complete diff and validation evidence.

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@vyctorbrzezowski vyctorbrzezowski self-assigned this Aug 26, 2026
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M maintainer Maintainer-authored PR labels Aug 26, 2026
@vyctorbrzezowski
vyctorbrzezowski marked this pull request as ready for review August 26, 2026 20:52
@clawsweeper clawsweeper Bot added merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 28, 2026, 5:08 AM ET / 09:08 UTC.

ClawSweeper review

What this changes

The PR makes supported locally generated documents appear as managed downloadable WebChat attachments instead of raw MEDIA: transcript directives.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Blocked until stronger real behavior proof is added - 6 items remain

The generic WebChat path is repaired, but the bundled Codex app-server bridge still drops required document metadata, leaving the requested behavior incomplete.

Priority: P1
Reviewed head: 310e73ca179e3a4fcd897815e0662073edbfa657

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) PR readiness rating was derived from proof quality, review findings, security review, and reviewer confidence.
Proof confidence 🦪 silver shellfish (2/6) Needs stronger real behavior proof before merge: ClawSweeper live verification failed on the reviewed terminal surface. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🧂 unranked krab (1/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: ClawSweeper live verification failed on the reviewed terminal surface. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 6 items Introduced shared contract: This PR adds attachments and trusted-local-media to the shared source-reply payload, making preservation necessary for document projection.
Codex bridge drops the new fields: The bundled Codex extractor reconstructs the payload with text, media, presentation, interactive data, channel data, and idempotency, but omits attachments and trustedLocalMedia.
Metadata reaches the shared owner only through this bridge: Codex telemetry forwards its source-reply payloads to terminal preparation, which forwards them to the standard embedded reply payload builder.
Findings 1 actionable finding [P1] Preserve metadata in the Codex source-reply bridge
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs test/e2e/qa-lab/runtime/webchat-media-artifacts.e2e.test.ts

Result: FAIL (failed) — step 1 expect_output WEBCHAT_MEDIA_ARTIFACTS_PROOF={"expected":20,"observed":20,"missing":[],"rawMediaVisible":false}: expected terminal output was not visible within 30 seconds: "WEBCHAT_MEDIA_ARTIFACTS_PROOF={\"expected\":20,\"observed\":20,\"missing\":[],\"rawMediaVisible\":false}"

[failure]
expected terminal output was not visible within 30 seconds: "WEBCHAT_MEDIA_ARTIFACTS_PROOF={\"expected\":20,\"observed\":20,\"missing\":[],\"rawMediaVisible\":false}"

[command 1 combined output]
[test] starting test/vitest/vitest.e2e.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130402-rUTh9U/target

[openclaw] Building TypeScript (dist is stale: missing_private_qa_dist - private QA dist entry missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
  - tsdown:deps (48%)
  - rolldown-plugin-dts:generate (22%)
  - rolldown-plugin-dts:fake-js (19%)
See https://rolldown.rs/reference/InputOptions.checks#plugintimings for more details.

[tsdown-build] invocation 1/11 finished in 5.1s

Assertions:

  • FAIL expect_output: WEBCHAT_MEDIA_ARTIFACTS_PROOF={"expected":20,"observed":20,"missing":[],"rawMediaVisible":false}

How this fits together

Assistant source replies carry media URLs and metadata into Gateway, which validates and stores managed artifacts before WebChat renders them in events and history. Each embedded runtime bridge must preserve the source-reply metadata used for local-file trust and document type.

flowchart LR
  A[Assistant source reply] --> B[Runtime source-reply bridge]
  B --> C[Terminal reply payload]
  C --> D[Managed media preparation]
  D --> E[Artifact storage]
  E --> F[WebChat event and history]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: ClawSweeper live verification failed on the reviewed terminal surface. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Preserve metadata in the Codex source-reply bridge (P1) - The new managed-document flow depends on attachments and trustedLocalMedia, but this extractor rebuilds the internal reply without either field. A Codex app-server reply with a locally generated JSON or CSV file therefore reaches managed-media preparation as an untrusted, untyped local URL and is rejected rather than rendered as an attachment. Propagate both fields and add a focused regression case.
  • Resolve merge risk (P1) - Merging as-is leaves the bundled Codex runtime unable to render trusted locally generated documents through the expanded source-reply contract.
  • Complete next step (P2) - The remaining omission has a clear owner, narrow repair, and focused validation path.
  • Improve patch quality - Add after-fix proof from a real setup, such as a short recording, terminal output, linked artifact, or redacted logs.
  • Improve patch quality - Address the highest-priority review finding and re-run the changed-surface validation.

Findings

  • [P1] Preserve metadata in the Codex source-reply bridge — extensions/codex/src/app-server/dynamic-tools.ts:1496-1509
Agent review details

Security

None.

PR surface

Source +302, Tests +1013. Total +1315 across 31 files.

View PR surface stats
Area Files Added Removed Net
Source 16 547 245 +302
Tests 15 1081 68 +1013
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 31 1628 313 +1315

Review metrics

Metric Value Why it matters
Production versus test delta Unavailable: 16 production and 15 test files touched; exact line delta could not be hydrated from the offline promisor base. The patch materially changes both the managed-media owner and its boundary coverage, so the remaining Codex gap must be fixed without adding a parallel flow.

Stored data model

Persistent data-model change detected: vector/embedding metadata: src/infra/outbound/message-action-send.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #130338
Summary: This PR is a candidate repair for the linked WebChat document-artifact issue, but remains incomplete for the bundled Codex runtime.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Complete the bundled runtime bridge (recommended)
    Propagate attachment and trust metadata through Codex and prove a trusted local document reaches the managed attachment owner before merging.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Preserve attachment and trusted-local-media metadata in the bundled Codex source-reply bridge, with focused document coverage.

Technical review

Best possible solution:

Preserve attachments and trusted-local-media in the bundled Codex source-reply extractor and add focused local-document coverage.

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

Yes. Current source directly shows the metadata loss; a focused Codex bridge test can reproduce it with a local JSON or CSV source reply.

Is this the best way to solve the issue?

No. The shared media owner is the right boundary, but its contract must also be preserved by the existing Codex bridge.

Full review comments:

  • [P1] Preserve metadata in the Codex source-reply bridge — extensions/codex/src/app-server/dynamic-tools.ts:1496-1509
    The new managed-document flow depends on attachments and trustedLocalMedia, but this extractor rebuilds the internal reply without either field. A Codex app-server reply with a locally generated JSON or CSV file therefore reaches managed-media preparation as an untrusted, untyped local URL and is rejected rather than rendered as an attachment. Propagate both fields and add a focused regression case.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against a483d833e6ea.

Labels

Label changes:

  • add merge-risk: 🚨 compatibility: The expanded shared payload contract is not preserved by every bundled runtime that consumes it.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦪 silver shellfish and patch quality is 🧂 unranked krab. Replaced prior rating: 🦐 gold shrimp.
  • add status: needs maintainer proof decision: A ClawSweeper-authored PR needs a maintainer proof capture or override decision. Needs stronger real behavior proof before merge: ClawSweeper live verification failed on the reviewed terminal surface. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • remove proof: sufficient: Current real behavior proof status is insufficient, not sufficient.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🧂 unranked krab, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: needs maintainer proof decision.

Label justifications:

  • P1: A bundled assistant runtime still fails a user-facing generated-document workflow.
  • merge-risk: 🚨 compatibility: The expanded shared payload contract is not preserved by every bundled runtime that consumes it.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦪 silver shellfish and patch quality is 🧂 unranked krab. Replaced prior rating: 🦐 gold shrimp.
  • status: needs maintainer proof decision: A ClawSweeper-authored PR needs a maintainer proof capture or override decision. Needs stronger real behavior proof before merge: ClawSweeper live verification failed on the reviewed terminal surface. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs extensions/codex/src/app-server/dynamic-tools.test.ts.
  • [P1] node scripts/run-vitest.mjs test/e2e/qa-lab/runtime/webchat-media-artifacts.e2e.test.ts.

What I checked:

Likely related people:

  • Peter Steinberger: Current Codex source-reply extraction lines are attributed to this contributor in blame. (role: recent area contributor; confidence: medium; commits: dd7e0ea97498; files: extensions/codex/src/app-server/dynamic-tools.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (8 earlier review cycles)
  • reviewed 2026-08-26T21:01:58.295Z sha c98a266 :: needs changes before merge. :: [P1] Preserve trust when persisting current-source documents
  • reviewed 2026-08-26T21:44:08.223Z sha c98a266 :: needs changes before merge. :: [P1] Preserve trusted media metadata in current-source persistence
  • reviewed 2026-08-26T22:05:37.874Z sha c98a266 :: needs changes before merge. :: [P1] Preserve trusted metadata in current-source persistence | [P1] Report every media reference that cannot become an attachment
  • reviewed 2026-08-27T11:28:06.084Z sha de83de0 :: found issues before merge. :: [P1] Reject SVG before creating a managed document artifact
  • reviewed 2026-08-27T11:49:05.332Z sha 1e07b8b :: found issues before merge. :: [P1] Reject SVG before creating a managed document artifact
  • reviewed 2026-08-27T12:03:42.907Z sha 1e07b8b :: found issues before merge. :: [P1] Reject SVG before creating a managed artifact | [P2] Assert each rejected fixture rather than any warning
  • reviewed 2026-08-27T13:13:13.376Z sha 1ed4f8e :: needs maintainer review before merge. :: none
  • reviewed 2026-08-27T19:42:23.864Z sha 1ed4f8e :: needs changes before merge. :: [P1] Preserve metadata in the Codex source-reply bridge

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XL and removed size: M labels Aug 27, 2026
@vyctorbrzezowski

vyctorbrzezowski commented Aug 27, 2026 •

Copy link
Copy Markdown
Member Author

Updated head 1e07b8b5eab addresses the current-source metadata and silent-drop findings.

Verified:

The 20 outcomes are 15 allowed managed artifacts plus visible bounded failure guidance for XML, SVG, Python, JavaScript, and unknown binary inputs. The PR body now contains refreshed dark-mode screenshots inspected from the current Gateway transcript.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Aug 27, 2026
@vyctorbrzezowski

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 27, 2026
@vyctorbrzezowski

vyctorbrzezowski commented Aug 27, 2026 •

Copy link
Copy Markdown
Member Author

Pre-release round complete on pushed head 310e73ca179e3a4fcd897815e0662073edbfa657.

Verified:

Product decision recorded in the PR body: legacy managed SVG records remain unavailable with HTTP 404 to keep the active-content boundary closed.

@clawsweeper

clawsweeper Bot commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 27, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 27, 2026
@vyctorbrzezowski
vyctorbrzezowski force-pushed the fix/webchat-media-artifacts branch from 1ed4f8e to 310e73c Compare August 28, 2026 08:58
@vyctorbrzezowski

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vyctorbrzezowski
vyctorbrzezowski merged commit a178285 into openclaw:main Aug 28, 2026
258 checks passed
@vyctorbrzezowski

Copy link
Copy Markdown
Member Author

Landed in a1782855a25a919f5f68129a4a87b127da0d9898 (head 310e73ca179e3a4fcd897815e0662073edbfa657).

Generated documents now reach the chat as real attachment cards across 20 validated formats — JSON, CSV, YAML, Markdown, plain text, trusted generated HTML, PDF, ZIP, DOCX, XLSX as named cards; WAV/MP3/MP4 as managed playback; PNG/JPEG keeping previews. Formats outside the host-read policy (XML, SVG, Python, JavaScript, unknown binary) stay blocked but now fail visibly with retry guidance instead of disappearing or leaking raw MEDIA: text.

This also closes a history-sanitization gap: attachment blocks in chat history now go through the same projection as media blocks, so capability query parameters (mediaTicket) are stripped before entries reach clients (src/gateway/chat-display-projection.sanitize.ts, regression in chat-display-projection.test.ts).

Product decision recorded in the PR body: legacy managed SVG records intentionally remain 404 — the active-content download boundary stays closed.

Validation: exact-head CI green (212 checks) on 310e73ca, clean autoreview round on the same head, 20/20 format matrix from a live gateway with inspected dark-mode Control UI captures, no schema/retention/protocol surface changed.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 29, 2026
)

* fix(webchat): render generated documents as attachments

* fix(webchat): preserve managed media metadata

* test(media): align projection expectations

* fix(media): reject unsafe managed documents

* fix(webchat): preserve rejected media outcomes
@vyctorbrzezowski
vyctorbrzezowski deleted the fix/webchat-media-artifacts branch October 1, 2026 17:29
obviyus added a commit that referenced this pull request Nov 26, 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 #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.

Co-authored-by: Ayaan Zaidi <[email protected]>
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

agents Agent runtime and tooling gateway Gateway runtime maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: WebChat shows local document MEDIA directives as raw text

1 participant