Skip to content

fix(gateway): show claude-cli narration only once in replies that send images - #195959

Merged
obviyus merged 5 commits into
openclaw:mainfrom
Marvinthebored:fix/195857-media-narration
Nov 25, 2026
Merged

obviyus merged 5 commits into
openclaw:mainfrom
Marvinthebored:fix/195857-media-narration

Conversation

@Marvinthebored

@Marvinthebored Marvinthebored commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Root cause: src/gateway/server-methods/chat-transcript-persistence.ts:180 compares each delivered text block with the authored caption after only sanitizeAssistantDisplayText. When messages.responseUsage is on, delivery appends the usage footer to that block, so neither the exact match nor the #188333 native-mirror suffix match fires. The final image row keeps the narration-prefixed aggregate as its display text.

Closes #195857

What Problem This Solves

In the Control UI, a claude-cli reply that narrates, runs tools and then sends images with MEDIA: lines repeated the narration at the top of the image reply. This happened when the usage footer (messages.responseUsage) was on. #188333 fixed the same duplication without the footer.

What changes

  • A claude-cli image reply with the usage footer on now shows the narration once, in its own native rows. The reply bubble shows the caption, the footer and the images.
  • The caption match ignores this payload's exact responseUsageLine at the end of the delivered block. When it consumed the footer, it adds the footer back under the rebuilt caption.
  • Replies without a footer, replies without images and non-claude-cli runtimes are unchanged (proof below).

Adoption note

Thanks @Marvinthebored for the report and the fix. Your four commits are kept as they were. On top of them, one commit reduces the change to what the real case needs:

  • Delivered blocks carry no MEDIA: lines on this path, so the extra MEDIA: normalization of delivered blocks is gone. Only the footer stopped the match.
  • The fenced-MEDIA: and authored-footer cases are gone; they have no observed occurrence.
  • The regression is now one usage row in the existing fix(gateway): stop Claude CLI image replies from repeating narration #188333 enrichment test. The 40-line table test and config/test-lines-allocations/195857-native-media-captions.txt are removed.
  • The helper stays in chat-assistant-caption.ts, because chat-transcript-persistence.ts is at its 700-line cap.

Production +67 -11 against the merge base (the head before was +74 -13). Tests +17 -7.

Evidence

The built Gateway and Control UI ran in a secretless Docker container, with real Chromium driving the chat composer. A stand-in claude emits Claude Code 2.1.330 stream-json: narration, Bash, narration, Bash, then a caption with 1 or 4 MEDIA: images. messages.responseUsage=full. Main ran twice and this PR ran twice. Each run covered three controls: no footer, no images, and the embedded runtime. Results are in the proof comment, which is linked below.

Regression: the new usage row fails with the base chat-transcript-persistence.ts (1 failed, 17 passed) and passes on this head.

Proof comment (table and screenshots): #195959 (comment)

@clawsweeper

clawsweeper Bot commented Nov 9, 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.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Nov 9, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. 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 clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 9, 2026
@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Normalize native image-reply captions before comparison so narration appears once while the usage footer and images remain visible.

Example: A Claude CLI turn says “Checking files.” and “Rendering images.” before returning “Answer ready.” with four MEDIA images and a usage footer.

  • Before: The progress lines appear under Worked and again above the final answer.
  • After: The progress lines appear only under Worked; the answer retains its caption, footer, and four images.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, useful repair with direct UI proof and no actionable finding; broader exact-head CI remains in progress.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): Inspected before/after Control UI screenshots cover Claude CLI replies with one and four images, expanded Worked sections, and usage footers; the author records history reload on isolated Gateways, and the candidate shows narration once with captions and images retained.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Completed Claude CLI image replies repeat progress narration outside the Worked section.
Reason: The patch restores the documented narration layout and the predecessor's explicit intent with no new configuration or public API.

Merge readiness

✅ Ready for maintainer review

This PR fixes a concrete caption mismatch still present on main; the prior test-budget finding is resolved, and no new actionable defect was found.

Priority: P2
Reviewed head: c53c74aeac45738b9731308bbc93b0e4e4ce9d34

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied material does not show a base-red/head-green run of the new regression tests.
Agent review details

How this fits together

Gateway reply dispatch passes prepared media and delivery metadata to the existing transcript rewrite owner, which preserves model content and writes the display projection consumed by chat history and Control UI.

flowchart TD
  A[Claude CLI messages] --> B[Reply dispatch]
  B --> C[Prepared media and usage metadata]
  C --> D[Transcript display rewrite]
  D --> E[Original model content preserved]
  D --> F[Chat history display projection]
  F --> G[Control UI]
Loading

Technical review

Best possible solution:

Retain this focused repair in the existing transcript display owner, preserving original model text and authored media placement.

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

The supplied before/after screenshots demonstrate the reported UI behavior, and current-main source explains the mismatch; no target code was executed during this read-only review.

Is this the best way to solve the issue?

Normalizing transport-only caption differences at the existing rewrite boundary directly repairs the mismatch without broad history filtering or changes to model content.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Native caption consumption keeps the original intent (41e20da: Keep each native final row's own text while consuming aggregate narration already represented by native progress rows.)
  • Authored media placement keeps the original intent (8c3cd75: Preserve authored heading and image order using source associations while leaving original model content unchanged.)
  • Model and display separation keeps the original intent (9030d86: Keep rich attachment display representations separate from replayable model content.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Holger Gruenhagen: Raw commit 41e20da adds src/gateway/server-methods/chat-transcript-persistence.ts:169 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 41e20dadb936; files: src/gateway/server-methods/chat-transcript-persistence.ts)
  • Peter Steinberger: Raw commit 6de0dba adds src/gateway/server-methods/chat-transcript-persistence.ts:122 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6de0dba61775; files: src/gateway/server-methods/chat-transcript-persistence.ts)

PR surface

Source +61, Tests +40, Other +1. Total +102 across 6 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 4 74 13 +61
Tests 1 40 0 +40
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 6 115 13 +102

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:

No label changes.

Label justifications:

  • P2: Repeated progress narration impairs completed image-reply readability, while the answer and attachments remain available.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster 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-09T12:41:19.582Z sha f9b2029 :: needs changes before merge. :: [P2] Account for the regression file in the test-line budget

Reviewed November 9, 2026, 10:58 AM ET / 15:58 UTC (Revision 2).

@Marvinthebored

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. 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: 🦐 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. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 9, 2026
Delivered caption blocks carry no MEDIA lines on the real path, so only the appended usage footer stops the openclaw#188333 suffix match. Keep the footer-aware match and footer retention in a small caption helper, drop the delivered-side MEDIA re-normalization, fold the regression into the openclaw#188333 enrichment test, and remove the test-lines allocation.
@obviyus

obviyus commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Gateway + Control UI proof (built in secretless Docker, real Chromium 156). Main = merge base 7c78826, PR head = 2e30d12 (also c53c74a before the shrink). Screenshots: history reloaded, Worked expanded.

case                 side                    narration (history)  last bubble (DOM)                         images
cli-img1  footer     main 7c78826284 run1    x2 / x2              "Checking files. Rendering images. Answer ready. <footer>"  1
cli-img1  footer     main 7c78826284 run2    x2 / x2              same                                      1
cli-img1  footer     PR c53c74aeac run1/2    x1 / x1              "Answer ready. <footer>"                  1
cli-img1  footer     final 2e30d12c1a run1/2 x1 / x1              "Answer ready. <footer>"                  1
cli-img4  footer     main run1/run2          x2 / x2              narration + "Answer ready. <footer>"      4
cli-img4  footer     PR c53c74aeac run1/2    x1 / x1              "Answer ready. <footer>"                  4
cli-img4  footer     final 2e30d12c1a run1/2 x1 / x1              "Answer ready. <footer>"                  4
control: no footer (session responseUsage=off), 1 image   all 6 runs: x1 / x1, "Answer ready.", 1 image; DOM bytes identical (sha 085166f97763)
control: claude-cli without images                        all 6 runs: x1 / x1, "Answer ready.", 0 images; DOM identical (sha b2bd4a9170b3)
control: embedded runtime (openclaw), 1 image             all 6 runs: x1, "Answer ready.", 1 image; DOM identical (sha a4eda7399aec)

Unit:
  contributor test file on base 7c78826284 (container): 6/6 fail; on c53c74aeac: 6/6 pass.
  final folded row "usage=Usage: 12 in / 3 out" with base chat-transcript-persistence.ts: 1 failed | 17 passed; on 2e30d12c1a: pass.
  ocx test over touched tests + importers (13 files): 13 passed, 211 tests.

main: 1 image, footer on, narration repeated at top of reply

PR: 1 image, footer on, narration once

main: 4 images, footer on

PR: 4 images, footer on

control: footer off, unchanged

control: no images, unchanged

control: embedded runtime, unchanged

@obviyus
obviyus merged commit 935d07d into openclaw:main Nov 25, 2026
128 of 129 checks passed
@obviyus

obviyus commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Merged in 935d07d. Thanks @Marvinthebored for the report in #195857 and the fix, and @Peetiegonzalez for raising it. When a claude-cli reply sends images and messages.responseUsage adds a usage footer, Control UI now shows the progress narration once instead of repeating it at the top of the reply; the bubble shows the caption, the footer and the images. Replies without images, without a footer and on other runtimes are unchanged.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 26, 2026
…d images (openclaw#195959)

Root cause: `src/gateway/server-methods/chat-transcript-persistence.ts:180` compares each delivered text block with the authored caption after only `sanitizeAssistantDisplayText`. When `messages.responseUsage` is on, delivery appends the usage footer to that block, so neither the exact match nor the openclaw#188333 native-mirror suffix match fires. The final image row keeps the narration-prefixed aggregate as its display text.

Closes openclaw#195857

## What Problem This Solves

In the Control UI, a claude-cli reply that narrates, runs tools and then sends images with `MEDIA:` lines repeated the narration at the top of the image reply. This happened when the usage footer (`messages.responseUsage`) was on. openclaw#188333 fixed the same duplication without the footer.

## What changes

- A claude-cli image reply with the usage footer on now shows the narration once, in its own native rows. The reply bubble shows the caption, the footer and the images.
- The caption match ignores this payload's exact `responseUsageLine` at the end of the delivered block. When it consumed the footer, it adds the footer back under the rebuilt caption.
- Replies without a footer, replies without images and non-claude-cli runtimes are unchanged (proof below).

## Adoption note

Thanks @Marvinthebored for the report and the fix. Your four commits are kept as they were. On top of them, one commit reduces the change to what the real case needs:

- Delivered blocks carry no `MEDIA:` lines on this path, so the extra `MEDIA:` normalization of delivered blocks is gone. Only the footer stopped the match.
- The fenced-`MEDIA:` and authored-footer cases are gone; they have no observed occurrence.
- The regression is now one usage row in the existing openclaw#188333 enrichment test. The 40-line table test and `config/test-lines-allocations/195857-native-media-captions.txt` are removed.
- The helper stays in `chat-assistant-caption.ts`, because `chat-transcript-persistence.ts` is at its 700-line cap.

Production +67 -11 against the merge base (the head before was +74 -13). Tests +17 -7.

## Evidence

The built Gateway and Control UI ran in a secretless Docker container, with real Chromium driving the chat composer. A stand-in `claude` emits Claude Code 2.1.330 stream-json: narration, Bash, narration, Bash, then a caption with 1 or 4 `MEDIA:` images. `messages.responseUsage=full`. Main ran twice and this PR ran twice. Each run covered three controls: no footer, no images, and the embedded runtime. Results are in the proof comment, which is linked below.

Regression: the new usage row fails with the base `chat-transcript-persistence.ts` (1 failed, 17 passed) and passes on this head.

Proof comment (table and screenshots): openclaw#195959 (comment)

Co-authored-by: phone-build <phone-build@localhost>
Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 28, 2026
…d images (#195959)

Root cause: `src/gateway/server-methods/chat-transcript-persistence.ts:180` compares each delivered text block with the authored caption after only `sanitizeAssistantDisplayText`. When `messages.responseUsage` is on, delivery appends the usage footer to that block, so neither the exact match nor the #188333 native-mirror suffix match fires. The final image row keeps the narration-prefixed aggregate as its display text.

Closes #195857

## What Problem This Solves

In the Control UI, a claude-cli reply that narrates, runs tools and then sends images with `MEDIA:` lines repeated the narration at the top of the image reply. This happened when the usage footer (`messages.responseUsage`) was on. #188333 fixed the same duplication without the footer.

## What changes

- A claude-cli image reply with the usage footer on now shows the narration once, in its own native rows. The reply bubble shows the caption, the footer and the images.
- The caption match ignores this payload's exact `responseUsageLine` at the end of the delivered block. When it consumed the footer, it adds the footer back under the rebuilt caption.
- Replies without a footer, replies without images and non-claude-cli runtimes are unchanged (proof below).

## Adoption note

Thanks @Marvinthebored for the report and the fix. Your four commits are kept as they were. On top of them, one commit reduces the change to what the real case needs:

- Delivered blocks carry no `MEDIA:` lines on this path, so the extra `MEDIA:` normalization of delivered blocks is gone. Only the footer stopped the match.
- The fenced-`MEDIA:` and authored-footer cases are gone; they have no observed occurrence.
- The regression is now one usage row in the existing #188333 enrichment test. The 40-line table test and `config/test-lines-allocations/195857-native-media-captions.txt` are removed.
- The helper stays in `chat-assistant-caption.ts`, because `chat-transcript-persistence.ts` is at its 700-line cap.

Production +67 -11 against the merge base (the head before was +74 -13). Tests +17 -7.

## Evidence

The built Gateway and Control UI ran in a secretless Docker container, with real Chromium driving the chat composer. A stand-in `claude` emits Claude Code 2.1.330 stream-json: narration, Bash, narration, Bash, then a caption with 1 or 4 `MEDIA:` images. `messages.responseUsage=full`. Main ran twice and this PR ran twice. Each run covered three controls: no footer, no images, and the embedded runtime. Results are in the proof comment, which is linked below.

Regression: the new usage row fails with the base `chat-transcript-persistence.ts` (1 failed, 17 passed) and passes on this head.

Proof comment (table and screenshots): #195959 (comment)

Co-authored-by: phone-build <phone-build@localhost>
Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 935d07d)
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…d images (#195959)

Root cause: `src/gateway/server-methods/chat-transcript-persistence.ts:180` compares each delivered text block with the authored caption after only `sanitizeAssistantDisplayText`. When `messages.responseUsage` is on, delivery appends the usage footer to that block, so neither the exact match nor the #188333 native-mirror suffix match fires. The final image row keeps the narration-prefixed aggregate as its display text.

Closes #195857

## What Problem This Solves

In the Control UI, a claude-cli reply that narrates, runs tools and then sends images with `MEDIA:` lines repeated the narration at the top of the image reply. This happened when the usage footer (`messages.responseUsage`) was on. #188333 fixed the same duplication without the footer.

## What changes

- A claude-cli image reply with the usage footer on now shows the narration once, in its own native rows. The reply bubble shows the caption, the footer and the images.
- The caption match ignores this payload's exact `responseUsageLine` at the end of the delivered block. When it consumed the footer, it adds the footer back under the rebuilt caption.
- Replies without a footer, replies without images and non-claude-cli runtimes are unchanged (proof below).

## Adoption note

Thanks @Marvinthebored for the report and the fix. Your four commits are kept as they were. On top of them, one commit reduces the change to what the real case needs:

- Delivered blocks carry no `MEDIA:` lines on this path, so the extra `MEDIA:` normalization of delivered blocks is gone. Only the footer stopped the match.
- The fenced-`MEDIA:` and authored-footer cases are gone; they have no observed occurrence.
- The regression is now one usage row in the existing #188333 enrichment test. The 40-line table test and `config/test-lines-allocations/195857-native-media-captions.txt` are removed.
- The helper stays in `chat-assistant-caption.ts`, because `chat-transcript-persistence.ts` is at its 700-line cap.

Production +67 -11 against the merge base (the head before was +74 -13). Tests +17 -7.

## Evidence

The built Gateway and Control UI ran in a secretless Docker container, with real Chromium driving the chat composer. A stand-in `claude` emits Claude Code 2.1.330 stream-json: narration, Bash, narration, Bash, then a caption with 1 or 4 `MEDIA:` images. `messages.responseUsage=full`. Main ran twice and this PR ran twice. Each run covered three controls: no footer, no images, and the embedded runtime. Results are in the proof comment, which is linked below.

Regression: the new usage row fails with the base `chat-transcript-persistence.ts` (1 failed, 17 passed) and passes on this head.

Proof comment (table and screenshots): #195959 (comment)

Co-authored-by: phone-build <phone-build@localhost>
Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 935d07d)

Companion audit: No later follow-up found. Match only against the unformatted caption while retaining stable dispatch/persistence ownership.

Release adaptation: Carry usage metadata through existing dispatch and enrichment; leave delivered text and replay IDs untouched.

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawtributors PR from a clawtributor gateway Gateway runtime 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.

[Bug]: Control UI still repeats claude-cli narration at the top of MEDIA image replies on main (after #188333)

3 participants