Skip to content

fix(chat): keep code controls when streaming fences close - #154430

Merged
vincentkoc merged 4 commits into
mainfrom
fix/chat-stream-fragment-promotion-20260921
Sep 21, 2026
Merged

vincentkoc merged 4 commits into
mainfrom
fix/chat-stream-fragment-promotion-20260921

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Closing a streamed code fence moves its Markdown from the active tail into the stable prefix. That move recreated the DOM, dropping expansion/wrapping choices and reader enhancements even though the reply was still streaming.

User Impact

Code controls keep their state when a fence closes and later paragraphs arrive in the same live reply. Corrections, rendering-option changes, and reference reinterpretation still reset content when needed.

This does not preserve DOM across final/saved-history replacement. The broader continuity work has been removed and deferred. No deployment is included.

Why This Change Was Made

Keep the promoted fragment in the same ordered Lit part and retain its existing renderer. Already-completed history still uses the lightweight static path.

The final diff is four files: +27 net production lines, +330 test lines, and +1 docs line—a 97% reduction in production growth from the earlier version of this PR. No projection, gateway, run-lifecycle, or saved-message identity changes remain.

Evidence

  • Baseline: 9/14 promotion tests fail; the real-app fence-close regression fails because the retained node disconnects.
  • Fixed: all 35 browser-component tests (4.01s) and 27 fence/messaging E2E tests (74.01s) pass, including the unchanged authoritative-history messaging regression.
  • Formatting, UI/test type checks, scoped lint, line-cap/assertion gates, docs lint, and UI build pass. Independent source review and scoped autoreview are clean.
  • Same synthetic fixture after fence closure; the run is still active in both captures.

Before: expansion and wrapping are lost.

Before: closing the streaming fence collapses the code block and removes wrapping

After: all nine rows stay expanded and wrapped.

After: closing the streaming fence retains expanded rows and wrapping

@clawsweeper

clawsweeper Bot commented Sep 21, 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.

@vincentkoc vincentkoc self-assigned this Sep 21, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review September 21, 2026 04:44
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui size: XL maintainer Maintainer-authored PR labels Sep 21, 2026
@clawsweeper clawsweeper Bot added 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: 🐚 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. labels Sep 21, 2026
@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 21, 2026, 4:35 AM ET / 08:35 UTC (Revision 5).

ClawSweeper review

What this changes

Preserves code-block expansion and wrapping when a streamed fence closes, with browser regressions and updated chat documentation.

Merge readiness

⛔ Blocked before merge - 2 items remain

The focused fix remains necessary on current main, and no introduced correctness or security defect was found. The current screenshot attachments could not be inspected, leaving the repository’s visual landing gate unresolved.

Priority: P2
Reviewed head: c47d201055f192e6b43dd146cafb84638a36e4d3

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, maintainable repair with meaningful regression coverage; screenshot accessibility remains a landing prerequisite rather than a code defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The external-contributor proof gate does not apply to this MEMBER-authored PR. Reported browser evidence targets the actual composer-to-streamed-Markdown path, but its new screenshots could not be inspected; the separate repository screenshot gate remains unresolved.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The external-contributor proof gate does not apply to this MEMBER-authored PR. Reported browser evidence targets the actual composer-to-streamed-Markdown path, but its new screenshots could not be inspected; the separate repository screenshot gate remains unresolved.
Evidence reviewed 8 items Pinned introduced change: The merge-base-to-head delta changes Markdown fragment retention, two browser test files, and chat documentation. Promotion updates the existing fragment without changing its renderer; source corrections and canonical-prefix changes retain the reset path.
Current main still needs the fix: Current main appends completed HTML to a separate fragment array and renders the active tail in a separate Lit part, retaining the promotion boundary that replaces code controls.
Latest release comparison: The v2026.9.5 source also keeps completed fragments and the active tail in separate parts; it does not contain this promotion repair.
Findings None None.
Security None None.

How this fits together

The Control UI converts streamed assistant Markdown into completed fragments and an active tail. This change keeps the tail’s existing DOM and controls when it becomes a completed fragment.

flowchart LR
  A[Assistant text updates] --> B[Sanitize and split Markdown]
  B --> C[Completed fragments]
  B --> D[Active tail]
  D --> E[Fence closes]
  E --> C
  C --> F[Retained code controls]
Loading

Before merge

  • Resolve merge risk (P1) - The required before/after fence-close screenshots remain unverified because both current attachment URLs return 404 from the review environment.
  • Complete next step (P2) - Verify and inspect the current before/after fence-close screenshots, restoring their PR attachments if necessary.
Agent review details

Security

None.

PR surface

Source +27, Tests +330, Docs +1. Total +358 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 30 3 +27
Tests 2 330 0 +330
Docs 1 4 3 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 364 6 +358

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep promotion inside the existing Markdown renderer while preserving canonical resets and the lightweight completed-history path.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep promotion inside the existing Markdown renderer while preserving canonical resets and the lightweight completed-history path.

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

Yes, source establishes the trigger: expand and wrap an open streamed fence, then append its closing delimiter. Current main transfers that content into a different rendered part; the new E2E case exercises this sequence, but was not run during this review.

Is this the best way to solve the issue?

Yes. Reusing the existing fragment and incremental renderer repairs the promotion boundary without introducing a second state owner or changing saved-history identity.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • remove proof: sufficient: Current real behavior proof status is not_applicable, not sufficient.
  • remove proof: 📸 screenshot: Current real behavior proof evidence kind is not_applicable.

Label justifications:

  • P2: This fixes reader-control resets during an otherwise functioning chat reply, with limited blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The external-contributor proof gate does not apply to this MEMBER-authored PR. Reported browser evidence targets the actual composer-to-streamed-Markdown path, but its new screenshots could not be inspected; the separate repository screenshot gate remains unresolved.

Evidence

What I checked:

  • Pinned introduced change: The merge-base-to-head delta changes Markdown fragment retention, two browser test files, and chat documentation. Promotion updates the existing fragment without changing its renderer; source corrections and canonical-prefix changes retain the reset path. (ui/src/pages/chat/components/chat-message-text.ts:381, c47d201055f1)
  • Current main still needs the fix: Current main appends completed HTML to a separate fragment array and renders the active tail in a separate Lit part, retaining the promotion boundary that replaces code controls. (ui/src/pages/chat/components/chat-message-text.ts:378, 7ff455860b90)
  • Latest release comparison: The v2026.9.5 source also keeps completed fragments and the active tail in separate parts; it does not contain this promotion repair. (ui/src/pages/chat/components/chat-message-text.ts:382, ec9c1a13db89)
  • Related merged work leaves this boundary open: The supplied GitHub record for fix(ui): preserve reader controls while chat replies stream #153815 confirms its merge and explicitly defers tail-to-stable promotion. Its recorded patch adds incremental active-tail rendering, establishing relevant prior merged work by Vincent Koc without superseding this fix. (ui/src/pages/chat/components/chat-message-media-markdown.ts:45, c2c55199f2e5)
  • Regression coverage matches the production entrypoint: The added E2E scenario sends through the chat composer, injects Gateway deltas, expands and wraps an open fence, then checks that its original element remains connected after closure. Component cases cover promotion, JSON controls, media refresh, corrections, and reference reinterpretation. The captured body reports baseline failures and passing browser/E2E batches; this read-only review did not execute them. (ui/src/e2e/chat-code-block-fences.e2e.test.ts:79, c47d201055f1)
  • Current visual evidence unavailable: The prepared manifest records HTTP 404 for both current attachments, ending a6de7d41-df0b-4646-8a4f-2b0ba46e4ecf and 5745fd37-d324-48e4-9d33-cbd99c2d37aa. Subsequent GitHub HEAD reads also returned 404; web fallback returned cache misses. The two successfully downloaded images were inspected and demonstrate the earlier active-tail disclosure scenario, not this fence-close transition. The captured body identity remains sourceRevision 7ab03aaef26b09ff72ea959f2f9d8d021108fce0ea592c49b3fc0684000fdb2b.

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Verify that the current before/after fence-close images render and can be inspected; restore the attachments if they are unavailable to other reviewers.

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 (4 earlier review cycles)
  • reviewed 2026-09-21T04:55:12.811Z sha a8be8f5e7624a44e4a3a384cacd5be622a7c04b3 :: blocked before merge. :: none
  • reviewed 2026-09-21T06:01:30.981Z sha 5ae0d05 :: blocked before merge. :: none
  • reviewed 2026-09-21T06:27:39.791Z sha ed7096d :: needs maintainer review before merge. :: none
  • reviewed 2026-09-21T07:57:15.676Z sha 9b49ecd :: needs maintainer review before merge. :: none

Retain ordinary Markdown and assistant-body occurrence identity through append-only promotion, finalization, and definitive saved-history adoption. Keep ambiguous replacements and semantic resets intentional; preserve static completed-history rendering.
@vincentkoc
vincentkoc force-pushed the fix/chat-stream-fragment-promotion-20260921 branch from a8be8f5 to 5ae0d05 Compare September 21, 2026 05:53
@vincentkoc vincentkoc changed the title fix(chat): keep reader state when streamed replies finish fix(chat): keep code controls when streaming fences close Sep 21, 2026
@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. labels Sep 21, 2026
@vincentkoc
vincentkoc enabled auto-merge (squash) September 21, 2026 08:54
@vincentkoc
vincentkoc merged commit f7bd9a2 into main Sep 21, 2026
155 of 157 checks passed
@vincentkoc
vincentkoc deleted the fix/chat-stream-fragment-promotion-20260921 branch September 21, 2026 08:58
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash auto-merge.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 22, 2026
…54430)

* fix(chat): keep reader state when streamed replies finish

Retain ordinary Markdown and assistant-body occurrence identity through append-only promotion, finalization, and definitive saved-history adoption. Keep ambiguous replacements and semantic resets intentional; preserve static completed-history rendering.

* fix(chat): give stream projection types acyclic owners

* fix(chat): preserve authoritative receipt handoff identity

* fix(chat): narrow control retention to streaming Markdown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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.

1 participant