Skip to content

fix(ui): keep pre-final assistant text visible after a completed turn - #140835

Merged
obviyus merged 4 commits into
openclaw:mainfrom
leapdragon:fix/webchat-keep-pre-final-text
Nov 27, 2026
Merged

obviyus merged 4 commits into
openclaw:mainfrom
leapdragon:fix/webchat-keep-pre-final-text

Conversation

@leapdragon

@leapdragon leapdragon commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

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:

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.

openai-completions transports retag already streamed answer text as commentary once a tool call follows. The completed-turn collapse then folded that text behind the worked-for row, so a long reply vanished and only the short closing message stayed visible. Fold tool and text-less assistant groups only.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

Claude-Session: https://claude.ai/code/session_01VsJbS7YcJnDVxErEuaM8xP
@clawsweeper

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

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 7, 2026
@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR keeps text-bearing assistant groups visible when completed dashboard turns collapse their intermediate work.

Example: An assistant writes “Here is the full answer,” calls read, then writes “That covers it.”

  • Before: The full answer and tool activity collapse behind “Worked for,” leaving the closing sentence visible.
  • After: Both assistant messages remain visible, while the following tool activity collapses.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The change addresses a recognizable visibility problem, but retains a grouping regression and awaits a decision on its broader presentation policy.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Partial
User problem: A substantive reply streamed before tool activity can disappear from the normal completed transcript behind “Worked for.”.
Reason: Preserving answers has clear value, but exposing all commentary changes an intentional presentation contract, and mixed text/tool envelopes retain tool ownership in this patch.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open: maintainers explicitly retained this PR's separate post-completion scope, and current main still intentionally collapses commentary rather than implementing its broader visibility policy.

Priority: P2
Reviewed head: 6b37bd8b678ebc74980046ca78a25fe5e13588a0
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should completed dashboard turns expose every pre-final assistant text group, despite the recently restored commentary rollup?
  • Recommendation: Narrow preservation to answer output: Retain the current commentary contract and repair any demonstrated answer misclassification through the existing owners.
  • Why: VACInc requested retaining this scope, but did not approve its blanket visibility policy; current documentation and the later merged restoration intentionally collapse commentary.

Before merge

  • Add real behavior proof - This branch supplies grouping-test output, while the inspected browser images exercise the different explicit-answer patch in fix(chat): keep earlier answers visible after tool continuations #143525; provide sanitized before/after captures, a recording, or diagnostic output from this branch's rebuilt and served Control UI through completion and history reload, redacting credentials, IPs, phone numbers, and private endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Preserve tool collapsing across visible assistant text (P2) - For a completed turn ordered as user → read result → assistant text → exec result → final reply, this new exemption makes the backward scan at lines 359–364 stop at the assistant text. Only the exec batch enters the work group; the earlier read batch stays exposed. The base folds both batches, so this contradicts the promised preservation of tool collapsing. Partition work separately from preserved text instead of using preserved text as the scan boundary. This is the previously reported, still-unfixed finding.
  • Complete next step - Resolve GitHub's reported branch conflicts against current main while retaining its answer, failure, and per-run presentation boundaries.

Findings

  • [P2] Preserve tool collapsing across visible assistant text — ui/src/pages/chat/chat-thread-grouping.ts:219-222

Provenance

Tests

  • Missing end-to-end proof: Show this branch retaining pre-tool text through completion and history reload while two tool batches separated by that text still collapse; the supplied tests do not show a base-failing browser regression.
Agent review details

How this fits together

The Control UI groups history and streamed messages into transcript rows, then separates completed-turn work from visible answers before rendering disclosures.

flowchart TD
A[History and stream messages] --> B[Normalize and classify content]
B --> C[Group transcript messages]
C --> D[Collapse completed work]
D --> E[Project transcript rows]
E --> F[Render answers and disclosures]
Loading

Technical review

Best possible solution:

Use the existing completed-turn partition to preserve verified answer output and collapse tool batches, with owner agreement before exposing all commentary.

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

Source establishes the commentary-folding path and the patch's tool-batch regression; the exact reported openai-completions scenario was not run, and no target code or tests were executed.

Is this the best way to solve the issue?

The predicate change is incomplete because the existing contiguous scan stops at preserved text, while current main already has a partition owner that can preserve outputs without abandoning earlier tool batches.

Full review comments:

  • [P2] Preserve tool collapsing across visible assistant text — ui/src/pages/chat/chat-thread-grouping.ts:219-222
    For a completed turn ordered as user → read result → assistant text → exec result → final reply, this new exemption makes the backward scan at lines 359–364 stop at the assistant text. Only the exec batch enters the work group; the earlier read batch stays exposed. The base folds both batches, so this contradicts the promised preservation of tool collapsing. Partition work separately from preserved text instead of using preserved text as the scan boundary. This is the previously reported, still-unfixed finding.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 8873aeb433fd.

Provenance checked

  • Completed-turn commentary folding changes intended behavior with a stated reason (5b7b2d0: feat(ui): collapse completed turn work behind a "Worked for X" rollup #105012 deliberately collapsed intermediate commentary and tools so completed turns read final-output-first; this PR explains its broader exemption using the reported transport retagging.)
  • Cached content classification and visualization assertions keeps the original intent (3661c68: Prepared visibility classification preserves visible outcomes through normalization and in-place changes; the PR retains that mechanism while changing which text groups collapse.)

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

PR surface

Source +10, Tests +82. Total +92 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 11 1 +10
Tests 2 97 15 +82
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 108 16 +92

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Completed-turn presentation can hide substantive text behind a disclosure, but the transcript remains available and the affected surface is bounded.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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 (3 earlier review cycles)
  • reviewed 2026-09-07T05:11:16.337Z sha 6b37bd8 :: needs real behavior proof before merge. :: [P2] Preserve tool collapsing across visible assistant text
  • reviewed 2026-09-23T05:56:17.987Z sha 6b37bd8 :: needs real behavior proof before merge. :: [P2] Preserve tool collapsing across visible assistant text
  • reviewed 2026-10-02T05:04:42.321Z sha 6b37bd8 :: needs real behavior proof before merge. :: [P2] Preserve tool collapsing across visible assistant text

Reviewed November 1, 2026, 6:13 PM ET / 23:13 UTC (Revision 4).

@VACInc

VACInc commented Sep 13, 2026

Copy link
Copy Markdown
Member

Related merge: #146554 preserves continuous live text through tool activity. It does not change completed-turn grouping or the rule that folds text retagged as commentary behind the worked-for row. This PR should remain open for its separate post-completion visibility scope.

@openclaw-barnacle

Copy link
Copy Markdown

This assigned pull request has been automatically marked as stale after being open for 27 days.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Oct 5, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 1, 2026
# Conflicts:
#	ui/src/pages/chat/chat-thread-grouping.test.ts
#	ui/src/pages/chat/chat-thread-grouping.ts
#	ui/src/pages/chat/chat-thread.test.ts
- Unlabeled assistant text in an OpenAI turn folds into Worked for only when it is a short
  status line (200 characters or fewer); a longer explanation stays visible.
- Explicitly labeled commentary keeps folding as before.
- Ports leapdragon's grouping fix to the current presentation owner.
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: XS and removed size: S labels Nov 27, 2026
@obviyus

obviyus commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Before/after screenshots: built Gateway + Control UI, scripted Chat Completions model (proxy/openai/gpt-5.4), real Chromium. main 41fcd49 vs fix 80fe957.

main: long pre-tool text while streaming

main: after completion the long text is folded into Worked for

main: after reload, still folded

fix: long text stays visible after completion

fix: same layout after reload

fix: short status line still folds

fix: no-tool turn unchanged

@obviyus

obviyus commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator
label=main run=1 profile=p140835main commit=41fcd490fb4dc8074d33f91d7825020ff9268653
[54.3s] RESULT LONG during.pre=true after.pre=false after.worked=1 reload.pre=false reload.worked=1
[54.3s] RESULT SHORT during.pre=true after.pre=false after.worked=1 reload.pre=false reload.worked=1
[54.3s] RESULT NOTOOL during.pre=true after.pre=true after.worked=0 reload.pre=true reload.worked=0
label=main run=2 profile=p140835main commit=41fcd490fb4dc8074d33f91d7825020ff9268653
[54.1s] RESULT LONG during.pre=true after.pre=false after.worked=1 reload.pre=false reload.worked=1
[54.1s] RESULT SHORT during.pre=true after.pre=false after.worked=1 reload.pre=false reload.worked=1
[54.1s] RESULT NOTOOL during.pre=true after.pre=true after.worked=0 reload.pre=true reload.worked=0
label=cand run=1 profile=p140835cand commit=80fe9572b14dab3efc36e8a2e52afeb86fa1222e
[54.6s] RESULT LONG during.pre=true after.pre=true after.worked=1 reload.pre=true reload.worked=1
[54.6s] RESULT SHORT during.pre=true after.pre=false after.worked=1 reload.pre=false reload.worked=1
[54.6s] RESULT NOTOOL during.pre=true after.pre=true after.worked=0 reload.pre=true reload.worked=0
label=cand run=2 profile=p140835cand commit=80fe9572b14dab3efc36e8a2e52afeb86fa1222e
[53.8s] RESULT LONG during.pre=true after.pre=true after.worked=1 reload.pre=true reload.worked=1
[53.8s] RESULT SHORT during.pre=true after.pre=false after.worked=1 reload.pre=false reload.worked=1
[53.8s] RESULT NOTOOL during.pre=true after.pre=true after.worked=0 reload.pre=true reload.worked=0

- Drop the 200-character status-line cutoff; assistant text folds into Worked for only when
  the model labels it commentary. Unlabeled text stays visible, as it does for non-OpenAI
  models since openclaw#197429.
- Label the commentary fixtures in tests that cover other folding boundaries; flip the tests
  that asserted unlabeled text folds.
@obviyus

obviyus commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Screenshots for head 77ec6f2 (fold only labeled commentary). Built Gateway + Control UI, scripted Chat Completions (proxy/openai/gpt-5.4) and Responses (resp/openai/gpt-5.5) models, real Chromium.

fix, Chat Completions: long pre-tool text stays visible

fix: same layout after reload

fix, Chat Completions: unlabeled status line stays visible under Worked for

fix: no-tool turn unchanged

fix, Responses: labeled commentary still folds

fix, Responses without phase: status line visible

main, Responses without phase: status line folded

@obviyus

obviyus commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator
label=main run=1 profile=p140835main commit=41fcd490fb4dc8074d33f91d7825020ff9268653
RESULT LONG during.pre=true after.pre=false after.worked=1 reload.pre=false reload.worked=1
RESULT SHORT during.pre=true after.pre=false after.worked=1 reload.pre=false reload.worked=1
RESULT NOTOOL during.pre=true after.pre=true after.worked=0 reload.pre=true reload.worked=0
label=main run=2 profile=p140835main commit=41fcd490fb4dc8074d33f91d7825020ff9268653
RESULT LONG during.pre=true after.pre=false after.worked=1 reload.pre=false reload.worked=1
RESULT SHORT during.pre=true after.pre=false after.worked=1 reload.pre=false reload.worked=1
RESULT NOTOOL during.pre=true after.pre=true after.worked=0 reload.pre=true reload.worked=0
label=main run=r1 profile=p140835main commit=41fcd490fb4dc8074d33f91d7825020ff9268653
RESULT RLABEL during.pre=true after.pre=false after.worked=1 reload.pre=false reload.worked=1
RESULT RPLAIN during.pre=true after.pre=false after.worked=1 reload.pre=false reload.worked=1
label=lab run=1 profile=p140835lab commit=77ec6f2633f50907b027e918f1da7a8bc11b217f
RESULT LONG during.pre=true after.pre=true after.worked=1 reload.pre=true reload.worked=1
RESULT SHORT during.pre=true after.pre=true after.worked=1 reload.pre=true reload.worked=1
RESULT NOTOOL during.pre=true after.pre=true after.worked=0 reload.pre=true reload.worked=0
label=lab run=r1 profile=p140835lab commit=77ec6f2633f50907b027e918f1da7a8bc11b217f
RESULT RLABEL during.pre=true after.pre=false after.worked=1 reload.pre=false reload.worked=1
RESULT RPLAIN during.pre=true after.pre=true after.worked=1 reload.pre=true reload.worked=1

@obviyus

obviyus commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Rejected review findings:

Local review of head 77ec6f2 (round 2): patch is correct, no code findings. It holds the PR open on two points; both are rejected.

  1. "Maintainer decision required: should completed OpenAI dashboard turns preserve all unlabeled assistant text instead of folding it as progress?"
    Decided. This is an obvious bug (users lose text they already read) whose only blocker was a product call, so per Ayaan's 2026-11-27 rule ("obvious bugs, make the product call") the loop made it, after a Fable consult and a transport check. Rule: fold only text the model labels commentary; unlabeled text stays visible. The label is the model's own signal. A length or content guess would be a heuristic judge on model output. Unlabeled text staying visible is what non-OpenAI models already get since fix(ui): keep assistant answers out of the collapsed Worked fold #197429. The single Worked rollup from fix(ui): completed turns scatter work across many Worked disclosures #188045 is kept. Known cost (stated in the body): short status lines show on Chat Completions and on Responses models that don't emit phase.

  2. "Real behavior proof missing."
    The review only sees unit tests. The browser proof is a built Gateway and Control UI with real Chromium, on both the Chat Completions and Responses wires, main vs this head, through completion and reload:

@obviyus
obviyus merged commit 3f475cc into openclaw:main Nov 27, 2026
91 of 93 checks passed
@obviyus

obviyus commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Landed in 3f475cc. In Control UI, assistant text written before a tool call no longer folds away into "Worked for" when the turn finishes, unless the model itself labeled it as commentary. Long explanations stay visible after completion and after reload, and OpenAI turns now match how every other provider already shows this text. Thanks @leapdragon for the report and the original fix; we ported it to the current presentation code in commits on top of yours.

obviyus added a commit that referenced this pull request Nov 27, 2026
…06809)

## What Problem This Solves

`checks-ui-e2e` is red on `main` in `chat-flow.model-picker-refresh.e2e.test.ts` › "keeps historical work with its author when switching routed models" (scheduled run 46007024811, and unrelated PRs). The assertion at line 309 expects "Finding from GPT." to be hidden inside **Worked**, but it is shown below it. It fails every run, not only sometimes.

## Why This Change Was Made

#140835 changed the product rule on purpose: assistant text folds into **Worked** only when the model labels it `commentary`. Unlabeled text before a tool call now stays visible. That PR relabeled the unit fixtures but not this e2e fixture, whose pre-tool text has no phase. The test asserted the removed behavior.

Fix: label the fixture's pre-tool text `phase: "commentary"`, the same change #140835 made to its unit fixtures. No product code changes. The test still proves what it is for: the fold follows the model that wrote the work (Claude's commentary stays inline, GPT's folds), before and after switching the routed model.

## User Impact

None. Test-only.

## Evidence

- On `main` (`11a3b5704647`), locally: fails with the same assertion as CI (`expected true to be false`, line 309); failure screenshot shows **Worked ›** followed by visible "Finding from GPT.".
- With the fix: the whole file (4 tests) passed in 10 of 10 sequential local runs.

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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 28, 2026
…enclaw#206809)

## What Problem This Solves

`checks-ui-e2e` is red on `main` in `chat-flow.model-picker-refresh.e2e.test.ts` › "keeps historical work with its author when switching routed models" (scheduled run 46007024811, and unrelated PRs). The assertion at line 309 expects "Finding from GPT." to be hidden inside **Worked**, but it is shown below it. It fails every run, not only sometimes.

## Why This Change Was Made

openclaw#140835 changed the product rule on purpose: assistant text folds into **Worked** only when the model labels it `commentary`. Unlabeled text before a tool call now stays visible. That PR relabeled the unit fixtures but not this e2e fixture, whose pre-tool text has no phase. The test asserted the removed behavior.

Fix: label the fixture's pre-tool text `phase: "commentary"`, the same change openclaw#140835 made to its unit fixtures. No product code changes. The test still proves what it is for: the fold follows the model that wrote the work (Claude's commentary stays inline, GPT's folds), before and after switching the routed model.

## User Impact

None. Test-only.

## Evidence

- On `main` (`fcc3552b7dbc`), locally: fails with the same assertion as CI (`expected true to be false`, line 309); failure screenshot shows **Worked ›** followed by visible "Finding from GPT.".
- With the fix: the whole file (4 tests) passed in 10 of 10 sequential local runs.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
* fix: preserve completed Claude tool calls in chat history

* fix: preserve completed Claude tool calls in chat history

OpenClaw-Publication: d3a267f1-3ba5-4fc9-a4dd-3968148f8eb1
(cherry picked from commit a27b4e6)

Follow-ups: 49492d7 fix: align Control UI tooling and docs with task card removal (#207747) [not selected for this narrow backport]; cebbb78 fix: keep tagged silent replies out of chat (#207738) [not selected for this narrow backport]; d4e1305 fix: hide desktop Details when there is nothing to show (#205093) [not selected for this narrow backport]; 11b2cf0 fix: keep the selected Review file compact when the tree is open (#203825) [not selected for this narrow backport]; 4be636b feat(ui): offer Add to Home agent when Home sidebar is open (#207773) [not selected for this narrow backport]; f766de4 fix: surface favorites and recommended models in picker search (#201450) [not selected for this narrow backport]; 61a7661 improve(ui): remove suggested-task cards from Control UI (#199167) [not selected for this narrow backport]; 48cc039 fix: keep long process names compact above mobile output (#203767) [not selected for this narrow backport]; 9316f05 fix: show the first message when session naming fails (#205607) [not selected for this narrow backport]; aa4a68f fix(ui): show chat completions as activity rows (#201891) [not selected for this narrow backport]; ec209d0 fix(ui): link selection sessions to their source session (#206509) [not selected for this narrow backport]; 3f475cc fix(ui): keep pre-final assistant text visible after a completed turn (#140835) [not selected for this narrow backport]; 05ec989 fix: keep chat photo previews sharp within their byte limits (#206461) [not selected for this narrow backport]; b3bdfb5 feat(ui): preview CSV chat attachments as tables (#206148) [not selected for this narrow backport]; 6b3ccab fix: show Waiting and Resumed for Claude CLI subagent handoffs (#206158) [not selected for this narrow backport]; 762aa00 fix: keep dictation recording when switching tabs or applications [not selected for this narrow backport]; d3f9fca fix: keep similar subagent names distinct in compact rows (#203777) [not selected for this narrow backport]; 864efbb improve: keep composer error cards on one line (#204337) [not selected for this narrow backport]; d7ed2dd fix: stop replaying Claude progress updates in active chats (#203970) [not selected for this narrow backport]; 269f884 fix: show Claude CLI document uploads only once in chat (#203866) [not selected for this narrow backport]; 4708bac fix(ui): show Linear artwork in chat tool activity (#204414) [not selected for this narrow backport]

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
(cherry picked from commit d5eafe8)

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]>
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. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants