Repository navigation
fix(gateway): show claude-cli narration only once in replies that send images - #195959
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesNormalize 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway 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]
Technical reviewBest 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
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +61, Tests +40, Other +1. Total +102 across 6 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 9, 2026, 10:58 AM ET / 15:58 UTC (Revision 2). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
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.
|
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. |
|
Merged in 935d07d. Thanks @Marvinthebored for the report in #195857 and the fix, and @Peetiegonzalez for raising it. When a |
…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]>
…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)
…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]>







Root cause:
src/gateway/server-methods/chat-transcript-persistence.ts:180compares each delivered text block with the authored caption after onlysanitizeAssistantDisplayText. Whenmessages.responseUsageis 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
responseUsageLineat the end of the delivered block. When it consumed the footer, it adds the footer back under the rebuilt caption.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:
MEDIA:lines on this path, so the extraMEDIA:normalization of delivered blocks is gone. Only the footer stopped the match.MEDIA:and authored-footer cases are gone; they have no observed occurrence.config/test-lines-allocations/195857-native-media-captions.txtare removed.chat-assistant-caption.ts, becausechat-transcript-persistence.tsis 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
claudeemits Claude Code 2.1.330 stream-json: narration, Bash, narration, Bash, then a caption with 1 or 4MEDIA: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)