Repository navigation
fix(webchat): render generated documents as attachments - #130402
vyctorbrzezowski merged 5 commits into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed August 28, 2026, 5:08 AM ET / 09:08 UTC. ClawSweeper reviewWhat this changesThe PR makes supported locally generated documents appear as managed downloadable WebChat attachments instead of raw Regression provenancePossible 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 Review scores
Verification
Live VerificationCommand: Result: FAIL (failed) — step 1 Assertions:
How this fits togetherAssistant 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]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +302, Tests +1013. Total +1315 across 31 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest 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:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a483d833e6ea. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (8 earlier review cycles)
|
|
Updated head 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 re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Pre-release round complete on pushed head Verified:
Product decision recorded in the PR body: legacy managed SVG records remain unavailable with HTTP |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
1ed4f8e to
310e73c
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Landed in 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 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 ( Product decision recorded in the PR body: legacy managed SVG records intentionally remain Validation: exact-head CI green (212 checks) on |
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]>
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]>
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)
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:
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:
PDF, ZIP, DOCX, and XLSX:
WAV, MP3, and MP4:
PNG and JPEG previews with original source labels:
XML, SVG, Python, JavaScript, and unknown binary remain blocked and end visibly:
All five current screenshots are dark-mode Control UI captures generated from the fresh Gateway transcript and inspected after capture.
Validation
thinkingSignatureremoved whileattachment.pathandmediaTicketleaked; it passes after unconditional media and attachment projection.node scripts/check-changed.mjspassed in clean Testbox execution before the chained E2E build.tbx_01m12d9x50qs75x6fkms6q8jn5: 20-format media-only rejection matrix and JSON/PDF reload/restart lifecycle withartifacts.listtypefileplus GET/HEAD/Range, https://github.com/openclaw/openclaw/actions/runs/33111717894310e73ca179e3a4fcd897815e0662073edbfa657: green, https://github.com/openclaw/openclaw/actions/runs/33157434453Production 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.