Skip to content

fix(ui): completed turns scatter work across many Worked disclosures - #188045

Merged
vyctorbrzezowski merged 4 commits into
mainfrom
openclaw/restore-pre-183267-folding
Oct 30, 2026
Merged

vyctorbrzezowski merged 4 commits into
mainfrom
openclaw/restore-pre-183267-folding

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #183267

What Problem This Solves

Fixes: completed dashboard turns scatter their work across many Worked disclosures, leave work recorded after the answer hanging below it, and split tool-result images out of their tool group, since #183267 changed the completed-turn presentation.

User Impact

User impact: a completed dashboard turn again shows one Worked for X disclosure above the answer, holding the preamble, commentary, reasoning and tool activity in their original order. Work recorded after the answer sits above it, tool-result images stay with the tool that produced them, and speech bubble view keeps its single activity disclosure instead of wrapping it in a second Worked row. The stored transcript stays intact; existing live-turn, search and handoff boundaries are retained.

Why This Change Was Made

#183267 by @Marvinthebored replaced the single completed-turn rollup with per-envelope splitting (chat-work-chunks.ts), so narration became visible between one Worked disclosure per work stretch. The single rollup was a deliberate design by @vyctorbrzezowski, and replaying real transcripts (Anthropic, OpenAI, Codex and agent API runs) at ad55c5e, e7f0546 and current main showed the split presentation also introduced regressions, listed below.

This is a forward change that restores the earlier presentation in the files #183267 changed, rather than a revert commit. It removes the splitting module, its tool-card envelope bookkeeping, the split-fragment action/footer/terminal-status fields and the per-stretch timing, and restores the rollup's session timing and the earlier test expectations (including the three e2e expectations later adapted in 8c05667). Later unrelated main work is kept: #186323, the published-PR handoff split (4d50f6c), grouped work without failed counts (210b364), cached row display facts (#186512), the video widget lazy-import wait, and the empty-group guard from #186499 for provider voice groups. The presentationOwnsFooter clauses from #186499 and #186681 go away with the fields they guarded. The test-line scalar returns the 2,089 lines #183267 added.

Regressions observed on main that this restores
  1. Empty Worked rows before answers that carry (empty) OpenAI reasoning.
  2. With Show thinking, inline reasoning moved into a collapsed Worked.
  3. With tool calls hidden, stacks of empty Worked disclosures.
  4. Work recorded after the answer rendered between the answer and its footer.
  5. Speech bubble view wrapped the activity summary in Worked: two clicks, summary hidden.
  6. Turn duration lost after switching sessions in one pane.
  7. Per-stretch browser previews showed stale or duplicate tab previews.
  8. Live turns split and regrouped.
  9. A pre-handoff receipt became its own reply with a second header and footer.
  10. Reply jumps expanded unrelated disclosures, because fragments shared persisted IDs.
  11. Duplicate narration previously hidden in the rollup became visible.
  12. collapseCompletedTurnWork ran 5–10x slower.
  13. Narration containing Markdown characters disabled splitting, so that envelope's narration merged while plain narration split, out of order with its tool calls.
  14. Tool-result images (for example view_image frames) split out of their tool group into standalone assistant rows.

Evidence

Screenshots: real Control UI against the mock Gateway with synthetic data, 1100 px, light theme. Before is current main (589348d), after is this branch.

Flat completed turn with narration between tool calls and a test run after the answer

Before:

Flat completed turn on main

After (collapsed):

Flat completed turn with this branch, collapsed

After (expanded):

Flat completed turn with this branch, expanded

Speech bubble view, same turn

Before:

Speech bubble view on main

After:

Speech bubble view with this branch

view_image tool result with two frames

Before:

view_image turn on main

After:

view_image turn with this branch

Tests:

  • New regressions in chat-thread-grouping.test.ts (Markdown and plain narration stay in one ordered rollup, tool-result images stay in their tool group, post-answer work moves above the answer, bubble mode gets no rollup) fail on main's presentation code and pass here (4/4 red on 589348d, green on this branch).
  • chat-bubble-activity.e2e now asserts no .chat-work-group in bubble view and one activity disclosure that opens the tool summary in a single click.
  • vitest.ui over ui/src/pages/chat and ui/src/lib/chat: 629 files passed.
  • Mock-Gateway e2e over every ui/src/e2e/chat-* suite: 1046 tests passed. The 17 *.real-gateway suites failed at setup in this shared worktree (Gateway entrypoint/plugin build not prepared; no assertion ran) and are not passing live-Gateway evidence. The original PR CI also skipped its real-Gateway lane. chat-loading-geometry hit a transient artifact lock and passes on rerun. chat-stream-runtime-budgets (delta-burst commits) and chat-outbox-migration (v3 Blob migration) fail identically on current main 589348d in a side-by-side rerun, so they are not caused by this change.
  • pnpm tsgo:ui, pnpm tsgo:test:ui, oxlint and oxfmt on the touched files, and pnpm check:test-lines-ratchet --staged: pass.
  • Local autoreview (branch mode, base 589348d, P1): no actionable findings.

Review repairs and current validation

Independent review and the subsequent full CI identified these additional cases in the proposed rollup, now fixed:

  • A terminal error or aborted tool envelope recorded after an answer stays visible, outside completed work.
  • A freshly opened pane restores elapsed time only when its loaded completed reply matches the session metadata. Cached projections retain that timing, and switching session, agent or Gateway cannot borrow another turn's recap.
  • A completed assistant answer containing both text and tools retains assistant ownership, visible text and reply/copy actions. Ordinary assistant messages reuse their prepared display text instead of sanitizing it again.
  • Legacy mixed forwarded narration retains its tool grouping and sender-owned file links. An explicitly completed forwarded answer (final_answer or stop) keeps its visible answer and actions.

The existing presentation, recap and message owners implement these repairs; no additional state owner or compatibility path was introduced. Focused regressions fail on the uncorrected PR head and pass with the repairs. The terminal error/abort cases were relocated into the existing grouping suite to reuse its history assertions and keep the thread test file within its line cap.

Focused repair validation: 283 tests passed across the chat owners and progress suite. The latest grouping and action refinements passed 205 affected tests across seven suites, plus UI and UI-test typechecks and targeted lint/format checks. Both CI failures reproduced locally before repair. Explicit forwarded-answer cases also fail on the original PR grouping and pass with the final implementation. After the test-only relocation, both terminal cases were again confirmed red on the uncorrected presentation and green with the fix (1.22 seconds wrapper wall time for the green run). Line-cap and test-line ratchets pass without raising their baselines (6,280,129 test lines against a 6,326,480 ceiling). Fresh independent reviews of the initial repairs and the final CI repair delta returned no actionable P0–P2 findings. Full PR CI run 41003470362 passed on head 12eef1abf280e31b008795e8c90eb16e9d1c1362. Its tested merge 9ddca045716bc844e7084eec72314375cdb863a8 includes #186061; the merged source preserves per-message timestamps, Reply controls, hover/touch behavior, and main's grouped-message CSS.

Risk and coverage

This changes how completed-turn content is grouped, so failure visibility, reply actions, run ownership and cached timing are the main regression risks. The focused tests exercise those boundaries. The screenshots above use the real Control UI with a mock Gateway and synthetic messages; they are not live-Gateway proof. Earlier broad test results above describe the original implementation and are not relabeled as runs on the repair commit. No successful real-Gateway run is claimed.

Requested by @vyctorbrzezowski.

Work sessions

Worked on by

roboclaw-bot and others added 2 commits October 30, 2026 01:41
Restore the completed-turn presentation that predates #183267: in completed
dashboard turns, preamble, commentary, reasoning and tool activity fold into
one "Worked for X" disclosure above the answer, work recorded after the
answer moves above it, and speech bubble view keeps its activity disclosure
without a second rollup.

Remove the per-envelope work splitting (chat-work-chunks), its envelope
bookkeeping in tool cards and source previews, and the split-fragment
action/footer/terminal-status ownership fields. Restore session timing for
the rollup and the prior test expectations, keeping later unrelated main
changes (#186323, 4d50f6c handoff split, 210b364, bd10ba2, the video widget
lazy-import wait and the empty-group avatar guard from #186499).

Add regression coverage for Markdown narration order, tool-result images
staying in their tool group, post-answer work above the answer and bubble
mode without a rollup.

Co-authored-by: vyctorbrzezowski <[email protected]>
Worked on by:
- @vyctorbrzezowski

Co-authored-by: vyctorbrzezowski <[email protected]>
OpenClaw-Publication: 18f1a29d-eed5-4a6e-9d33-e5dc8590b854
@clawsweeper

clawsweeper Bot commented Oct 30, 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 docs Improvements or additions to documentation app: web-ui App: web-ui size: XL labels Oct 30, 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: 🦪 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. 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 Oct 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR restores one completed-turn work disclosure above the answer and removes mixed-envelope splitting.

Example: A settings-spacing turn includes narration, three tool steps, an answer, and a final test run.

  • Before: Four Worked disclosures interrupt the conversation, including one below the answer.
  • After: One Worked for 2 minutes, 34 seconds disclosure contains the ordered activity above the answer.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Direct visual proof supports the core change, the prior blockers are repaired, and no new actionable defect was found; current-head CI remains pending.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): Inspected screenshots exercise the running Control UI with synthetic mock-Gateway history and show the single collapsed and expanded rollup above the answer; focused regressions support the subsequent failure, timing, and action repairs, with no live-Gateway result claimed.
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 dashboard turns scatter activity across disclosures and can leave post-answer work below the answer.
Reason: Recorded owner direction supports restoring a compact completed-turn presentation, and the patch also repairs concrete grouping regressions.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it implements an owner-approved presentation repair absent from fetched main, and no actionable introduced defect remains in the reviewed head.

Priority: P2
Reviewed head: 12eef1abf280e31b008795e8c90eb16e9d1c1362

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Control UI projects stored messages and live session facts into transcript groups, work disclosures, run frames, and reply actions without rewriting the transcript.

flowchart TD
  A[Stored messages and session facts] --> B[Message grouping]
  B --> C[Completed turn presentation]
  C --> D[Run frames and transcript indexes]
  D --> E[Work disclosure]
  D --> F[Answer and reply actions]
Loading

Technical review

Best possible solution:

Land the existing single-rollup implementation after the current-head CI gate completes.

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

Fetched-main source implements per-stretch disclosures, and inspected before/after screenshots establish the visible problem; no target code was executed during this review.

Is this the best way to solve the issue?

The change restores the approved presentation through existing grouping, recap, and message owners while removing the superseded splitting path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 3a0d1de6c33d.

Provenance checked

  • Completed-turn grouping and envelope splitting changes intended behavior with a stated reason (e7f0546: Keep narration and visual results inline while folding only contiguous activity.)
  • Run-owned work duration keeps the original intent (25f6775: Retain known duration after session metadata advances without repeating it in the footer.)
  • Mixed assistant narration and reply ownership keeps the original intent (f6065d6: Keep assistant commentary and interrupted outcomes visible when tool-shaped envelopes would otherwise lose assistant presentation.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source -260, Tests -1203, Docs -2, Other 0. Total -1465 across 42 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 19 239 499 -260
Tests 21 424 1627 -1203
Docs 1 8 10 -2
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 42 672 2137 -1465

Review metrics

Metric Value Why it matters
Production versus test changes Production +239/-499; tests and fixtures +424/-1627. The repair removes splitting machinery and its obsolete scaffolding while retaining focused regression coverage.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Completed dashboard conversations become fragmented and require extra disclosure interactions, with limited impact outside chat presentation.
  • 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 (2 earlier review cycles)
  • reviewed 2026-10-30T02:46:29.427Z sha edb0e64 :: needs changes before merge. :: [P2] Keep terminal assistant failures after the last answer visible | [P2] Preserve saved timing for reopened chats without a work rollup
  • reviewed 2026-10-30T04:25:17.282Z sha 3a302ad :: needs maintainer review before merge. :: none

Reviewed October 30, 2026, 12:39 AM ET / 04:39 UTC (Revision 3).

@vyctorbrzezowski

Copy link
Copy Markdown
Member

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 30, 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. labels Oct 30, 2026
@vyctorbrzezowski
vyctorbrzezowski enabled auto-merge (squash) October 30, 2026 04:22
@vyctorbrzezowski

Copy link
Copy Markdown
Member

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. label Oct 30, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. 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. 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 Oct 30, 2026
@vyctorbrzezowski
vyctorbrzezowski merged commit a967fa7 into main Oct 30, 2026
115 of 116 checks passed
@vyctorbrzezowski
vyctorbrzezowski deleted the openclaw/restore-pre-183267-folding branch October 30, 2026 04:44
@vyctorbrzezowski

Copy link
Copy Markdown
Member

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 31, 2026
…penclaw#188045)

* fix(ui): completed turns scatter work across many Worked disclosures

Restore the completed-turn presentation that predates openclaw#183267: in completed
dashboard turns, preamble, commentary, reasoning and tool activity fold into
one "Worked for X" disclosure above the answer, work recorded after the
answer moves above it, and speech bubble view keeps its activity disclosure
without a second rollup.

Remove the per-envelope work splitting (chat-work-chunks), its envelope
bookkeeping in tool cards and source previews, and the split-fragment
action/footer/terminal-status ownership fields. Restore session timing for
the rollup and the prior test expectations, keeping later unrelated main
changes (openclaw#186323, 5429704 handoff split, 853d946, 3fad731, the video widget
lazy-import wait and the empty-group avatar guard from openclaw#186499).

Add regression coverage for Markdown narration order, tool-result images
staying in their tool group, post-answer work above the answer and bubble
mode without a rollup.

Co-authored-by: vyctorbrzezowski <[email protected]>

* fix(ui): completed turns scatter work across many Worked disclosures

Worked on by:
- @vyctorbrzezowski

Co-authored-by: vyctorbrzezowski <[email protected]>
OpenClaw-Publication: 18f1a29d-eed5-4a6e-9d33-e5dc8590b854

* fix(ui): preserve completed-turn outcomes and reply ownership

* fix(ui): retain forwarded narration and prepared action text

---------

Co-authored-by: vyctorbrzezowski <[email protected]>
Co-authored-by: Vyctor H. Brzezowski <[email protected]>
obviyus added a commit that referenced this pull request Nov 27, 2026
…#140835)

Root cause: `ui/src/pages/chat/chat-turn-presentation.ts:150` (`isCollapsibleWorkGroup`) treats every assistant text group that is not an explicit final answer as foldable work in a completed OpenAI turn. Text written before a tool call over Chat Completions has no phase label, only `stopReason: "toolUse"`, so a long explanation the user already read folds into **Worked for…** with the tools, and only the short closing line stays.

## What Problem This Solves

Reported by @leapdragon on 2026.9.2 with an `openai-completions` transport: the agent streams a long reply, calls a tool, then writes a short final line. When the turn completes, the long reply disappears behind the **Worked for** row. Current main still does this for OpenAI models over Chat Completions (OpenAI-compatible proxies such as LiteLLM/OpenRouter-style providers).

## Why This Change Was Made

Rule: assistant text folds into **Worked for…** only when the model labels it `commentary`. Unlabeled text stays visible below the one **Worked for** row, in source order. Tools, reasoning and labeled commentary still fold; there is still one rollup per turn (#188045).

Why this rule:
- The label is the model's own signal. OpenAI models that emit `phase` are told commentary may be hidden, so folding it loses nothing.
- A length cut-off or other guess about whether model text is "just status" would be a heuristic judge on model output. An absent label is unknown, not commentary, as #197429 argued.
- Where no label exists, the text stays visible, which is what every non-OpenAI model already does since #197429. This makes OpenAI-over-Chat-Completions consistent with that, not a new layout.

Where the label comes from:

| Path | Pre-tool text labeled `commentary`? | Source |
|---|---|---|
| OpenAI Responses, models that emit `phase` | Yes, folds | `packages/ai/src/transports/openai-responses-stream-internal.ts` stores `item.phase` as the text signature |
| Codex app-server harness | Yes, when Codex sends a phase | `extensions/codex/src/app-server/transcript-history-projection.ts` keeps the item phase |
| OpenAI Responses, models without `phase` | No, stays visible | Same transport; no phase to store |
| Chat Completions, any model | No, stays visible | The format has no phase field |

Known cost: on Chat Completions and on Responses models that don't emit `phase`, short status lines such as "Let me check the notes file." now stay visible under **Worked for** instead of folding.

This ports @leapdragon's fix from the old `chat-thread-grouping.ts` (now a thin wrapper) to the current presentation owner. The old review finding (tool batches on either side of kept text) doesn't apply here, because the current owner partitions work and answers separately instead of scanning backwards.

## User Impact

- Text written before a tool call without a commentary label stays visible after the turn completes and after reload.
- Labeled commentary, reasoning and tool activity still fold into **Worked for…**.
- Turns without tools and non-OpenAI turns don't change.

## Evidence

Built Gateway and Control UI (Docker, `node:24.22.1`), scripted models (`proxy/openai/gpt-5.4` on `openai-completions`, `resp/openai/gpt-5.5` on `openai-responses`), real Chromium. Each scenario runs in its own dashboard session: during streaming, after completion, then after reload.

| Build | Wire | Long pre-tool text | Short unlabeled status line | Labeled commentary | No-tool turn |
|---|---|---|---|---|---|
| main `41fcd490fb4d` (2 runs) | Chat Completions | folded away | folded | n/a | visible |
| main `41fcd490fb4d` | Responses | n/a | folded | folded | n/a |
| fix `77ec6f2633f5` | Chat Completions | visible (after and reload) | visible | n/a | visible |
| fix `77ec6f2633f5` | Responses | n/a | visible | folded | n/a |

Proof lines: #140835 (comment). Screenshots: #140835 (comment).

Regression test `keeps unlabeled pre-tool text visible while labeled commentary folds` in `chat-thread-grouping.test.ts` covers the boundary. Tests that covered other folding rules now use labeled commentary fixtures. Tests that asserted unlabeled text folds now expect it to stay visible. Focused chat presentation suites pass (17 files, 310 tests, plus browser shards).

## Merge danger

Two-way door: display grouping only, with no stored history, config or protocol change. A revert restores the previous folding. Blast radius: completed dashboard turns answered by OpenAI models without a commentary label.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 28, 2026
…#140835)

Root cause: `ui/src/pages/chat/chat-turn-presentation.ts:150` (`isCollapsibleWorkGroup`) treats every assistant text group that is not an explicit final answer as foldable work in a completed OpenAI turn. Text written before a tool call over Chat Completions has no phase label, only `stopReason: "toolUse"`, so a long explanation the user already read folds into **Worked for…** with the tools, and only the short closing line stays.

## What Problem This Solves

Reported by @leapdragon on 2026.9.2 with an `openai-completions` transport: the agent streams a long reply, calls a tool, then writes a short final line. When the turn completes, the long reply disappears behind the **Worked for** row. Current main still does this for OpenAI models over Chat Completions (OpenAI-compatible proxies such as LiteLLM/OpenRouter-style providers).

## Why This Change Was Made

Rule: assistant text folds into **Worked for…** only when the model labels it `commentary`. Unlabeled text stays visible below the one **Worked for** row, in source order. Tools, reasoning and labeled commentary still fold; there is still one rollup per turn (#188045).

Why this rule:
- The label is the model's own signal. OpenAI models that emit `phase` are told commentary may be hidden, so folding it loses nothing.
- A length cut-off or other guess about whether model text is "just status" would be a heuristic judge on model output. An absent label is unknown, not commentary, as #197429 argued.
- Where no label exists, the text stays visible, which is what every non-OpenAI model already does since #197429. This makes OpenAI-over-Chat-Completions consistent with that, not a new layout.

Where the label comes from:

| Path | Pre-tool text labeled `commentary`? | Source |
|---|---|---|
| OpenAI Responses, models that emit `phase` | Yes, folds | `packages/ai/src/transports/openai-responses-stream-internal.ts` stores `item.phase` as the text signature |
| Codex app-server harness | Yes, when Codex sends a phase | `extensions/codex/src/app-server/transcript-history-projection.ts` keeps the item phase |
| OpenAI Responses, models without `phase` | No, stays visible | Same transport; no phase to store |
| Chat Completions, any model | No, stays visible | The format has no phase field |

Known cost: on Chat Completions and on Responses models that don't emit `phase`, short status lines such as "Let me check the notes file." now stay visible under **Worked for** instead of folding.

This ports @leapdragon's fix from the old `chat-thread-grouping.ts` (now a thin wrapper) to the current presentation owner. The old review finding (tool batches on either side of kept text) doesn't apply here, because the current owner partitions work and answers separately instead of scanning backwards.

## User Impact

- Text written before a tool call without a commentary label stays visible after the turn completes and after reload.
- Labeled commentary, reasoning and tool activity still fold into **Worked for…**.
- Turns without tools and non-OpenAI turns don't change.

## Evidence

Built Gateway and Control UI (Docker, `node:24.22.1`), scripted models (`proxy/openai/gpt-5.4` on `openai-completions`, `resp/openai/gpt-5.5` on `openai-responses`), real Chromium. Each scenario runs in its own dashboard session: during streaming, after completion, then after reload.

| Build | Wire | Long pre-tool text | Short unlabeled status line | Labeled commentary | No-tool turn |
|---|---|---|---|---|---|
| main `41fcd490fb4d` (2 runs) | Chat Completions | folded away | folded | n/a | visible |
| main `41fcd490fb4d` | Responses | n/a | folded | folded | n/a |
| fix `77ec6f2633f5` | Chat Completions | visible (after and reload) | visible | n/a | visible |
| fix `77ec6f2633f5` | Responses | n/a | visible | folded | n/a |

Proof lines: #140835 (comment). Screenshots: #140835 (comment).

Regression test `keeps unlabeled pre-tool text visible while labeled commentary folds` in `chat-thread-grouping.test.ts` covers the boundary. Tests that covered other folding rules now use labeled commentary fixtures. Tests that asserted unlabeled text folds now expect it to stay visible. Focused chat presentation suites pass (17 files, 310 tests, plus browser shards).

## Merge danger

Two-way door: display grouping only, with no stored history, config or protocol change. A revert restores the previous folding. Blast radius: completed dashboard turns answered by OpenAI models without a commentary label.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 3f475cc)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 28, 2026
…openclaw#140835)

Root cause: `ui/src/pages/chat/chat-turn-presentation.ts:150` (`isCollapsibleWorkGroup`) treats every assistant text group that is not an explicit final answer as foldable work in a completed OpenAI turn. Text written before a tool call over Chat Completions has no phase label, only `stopReason: "toolUse"`, so a long explanation the user already read folds into **Worked for…** with the tools, and only the short closing line stays.

## What Problem This Solves

Reported by @leapdragon on 2026.9.2 with an `openai-completions` transport: the agent streams a long reply, calls a tool, then writes a short final line. When the turn completes, the long reply disappears behind the **Worked for** row. Current main still does this for OpenAI models over Chat Completions (OpenAI-compatible proxies such as LiteLLM/OpenRouter-style providers).

## Why This Change Was Made

Rule: assistant text folds into **Worked for…** only when the model labels it `commentary`. Unlabeled text stays visible below the one **Worked for** row, in source order. Tools, reasoning and labeled commentary still fold; there is still one rollup per turn (openclaw#188045).

Why this rule:
- The label is the model's own signal. OpenAI models that emit `phase` are told commentary may be hidden, so folding it loses nothing.
- A length cut-off or other guess about whether model text is "just status" would be a heuristic judge on model output. An absent label is unknown, not commentary, as openclaw#197429 argued.
- Where no label exists, the text stays visible, which is what every non-OpenAI model already does since openclaw#197429. This makes OpenAI-over-Chat-Completions consistent with that, not a new layout.

Where the label comes from:

| Path | Pre-tool text labeled `commentary`? | Source |
|---|---|---|
| OpenAI Responses, models that emit `phase` | Yes, folds | `packages/ai/src/transports/openai-responses-stream-internal.ts` stores `item.phase` as the text signature |
| Codex app-server harness | Yes, when Codex sends a phase | `extensions/codex/src/app-server/transcript-history-projection.ts` keeps the item phase |
| OpenAI Responses, models without `phase` | No, stays visible | Same transport; no phase to store |
| Chat Completions, any model | No, stays visible | The format has no phase field |

Known cost: on Chat Completions and on Responses models that don't emit `phase`, short status lines such as "Let me check the notes file." now stay visible under **Worked for** instead of folding.

This ports @leapdragon's fix from the old `chat-thread-grouping.ts` (now a thin wrapper) to the current presentation owner. The old review finding (tool batches on either side of kept text) doesn't apply here, because the current owner partitions work and answers separately instead of scanning backwards.

## User Impact

- Text written before a tool call without a commentary label stays visible after the turn completes and after reload.
- Labeled commentary, reasoning and tool activity still fold into **Worked for…**.
- Turns without tools and non-OpenAI turns don't change.

## Evidence

Built Gateway and Control UI (Docker, `node:24.22.1`), scripted models (`proxy/openai/gpt-5.4` on `openai-completions`, `resp/openai/gpt-5.5` on `openai-responses`), real Chromium. Each scenario runs in its own dashboard session: during streaming, after completion, then after reload.

| Build | Wire | Long pre-tool text | Short unlabeled status line | Labeled commentary | No-tool turn |
|---|---|---|---|---|---|
| main `dfa14eda1208` (2 runs) | Chat Completions | folded away | folded | n/a | visible |
| main `dfa14eda1208` | Responses | n/a | folded | folded | n/a |
| fix `77ec6f2633f5` | Chat Completions | visible (after and reload) | visible | n/a | visible |
| fix `77ec6f2633f5` | Responses | n/a | visible | folded | n/a |

Proof lines: openclaw#140835 (comment). Screenshots: openclaw#140835 (comment).

Regression test `keeps unlabeled pre-tool text visible while labeled commentary folds` in `chat-thread-grouping.test.ts` covers the boundary. Tests that covered other folding rules now use labeled commentary fixtures. Tests that asserted unlabeled text folds now expect it to stay visible. Focused chat presentation suites pass (17 files, 310 tests, plus browser shards).

## Merge danger

Two-way door: display grouping only, with no stored history, config or protocol change. A revert restores the previous folding. Blast radius: completed dashboard turns answered by OpenAI models without a commentary label.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…#140835)

Root cause: `ui/src/pages/chat/chat-turn-presentation.ts:150` (`isCollapsibleWorkGroup`) treats every assistant text group that is not an explicit final answer as foldable work in a completed OpenAI turn. Text written before a tool call over Chat Completions has no phase label, only `stopReason: "toolUse"`, so a long explanation the user already read folds into **Worked for…** with the tools, and only the short closing line stays.

## What Problem This Solves

Reported by @leapdragon on 2026.9.2 with an `openai-completions` transport: the agent streams a long reply, calls a tool, then writes a short final line. When the turn completes, the long reply disappears behind the **Worked for** row. Current main still does this for OpenAI models over Chat Completions (OpenAI-compatible proxies such as LiteLLM/OpenRouter-style providers).

## Why This Change Was Made

Rule: assistant text folds into **Worked for…** only when the model labels it `commentary`. Unlabeled text stays visible below the one **Worked for** row, in source order. Tools, reasoning and labeled commentary still fold; there is still one rollup per turn (#188045).

Why this rule:
- The label is the model's own signal. OpenAI models that emit `phase` are told commentary may be hidden, so folding it loses nothing.
- A length cut-off or other guess about whether model text is "just status" would be a heuristic judge on model output. An absent label is unknown, not commentary, as #197429 argued.
- Where no label exists, the text stays visible, which is what every non-OpenAI model already does since #197429. This makes OpenAI-over-Chat-Completions consistent with that, not a new layout.

Where the label comes from:

| Path | Pre-tool text labeled `commentary`? | Source |
|---|---|---|
| OpenAI Responses, models that emit `phase` | Yes, folds | `packages/ai/src/transports/openai-responses-stream-internal.ts` stores `item.phase` as the text signature |
| Codex app-server harness | Yes, when Codex sends a phase | `extensions/codex/src/app-server/transcript-history-projection.ts` keeps the item phase |
| OpenAI Responses, models without `phase` | No, stays visible | Same transport; no phase to store |
| Chat Completions, any model | No, stays visible | The format has no phase field |

Known cost: on Chat Completions and on Responses models that don't emit `phase`, short status lines such as "Let me check the notes file." now stay visible under **Worked for** instead of folding.

This ports @leapdragon's fix from the old `chat-thread-grouping.ts` (now a thin wrapper) to the current presentation owner. The old review finding (tool batches on either side of kept text) doesn't apply here, because the current owner partitions work and answers separately instead of scanning backwards.

## User Impact

- Text written before a tool call without a commentary label stays visible after the turn completes and after reload.
- Labeled commentary, reasoning and tool activity still fold into **Worked for…**.
- Turns without tools and non-OpenAI turns don't change.

## Evidence

Built Gateway and Control UI (Docker, `node:24.22.1`), scripted models (`proxy/openai/gpt-5.4` on `openai-completions`, `resp/openai/gpt-5.5` on `openai-responses`), real Chromium. Each scenario runs in its own dashboard session: during streaming, after completion, then after reload.

| Build | Wire | Long pre-tool text | Short unlabeled status line | Labeled commentary | No-tool turn |
|---|---|---|---|---|---|
| main `41fcd490fb4d` (2 runs) | Chat Completions | folded away | folded | n/a | visible |
| main `41fcd490fb4d` | Responses | n/a | folded | folded | n/a |
| fix `77ec6f2633f5` | Chat Completions | visible (after and reload) | visible | n/a | visible |
| fix `77ec6f2633f5` | Responses | n/a | visible | folded | n/a |

Proof lines: #140835 (comment). Screenshots: #140835 (comment).

Regression test `keeps unlabeled pre-tool text visible while labeled commentary folds` in `chat-thread-grouping.test.ts` covers the boundary. Tests that covered other folding rules now use labeled commentary fixtures. Tests that asserted unlabeled text folds now expect it to stay visible. Focused chat presentation suites pass (17 files, 310 tests, plus browser shards).

## Merge danger

Two-way door: display grouping only, with no stored history, config or protocol change. A revert restores the previous folding. Blast radius: completed dashboard turns answered by OpenAI models without a commentary label.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 3f475cc)

Companion audit: Pair the commentary fixture alignment (#206811) with visible unphased pre-final answer text (#140835); no later companion required.

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

app: web-ui App: web-ui docs Improvements or additions to documentation 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: 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.

2 participants