Skip to content

fix(chat): preserve reasoning and tool trace after navigation - #118332

Merged
fuller-stack-dev merged 1 commit into
openclaw:mainfrom
fuller-stack-dev:codex/ope-6-preserve-chat-trace
Aug 3, 2026
Merged

fuller-stack-dev merged 1 commit into
openclaw:mainfrom
fuller-stack-dev:codex/ope-6-preserve-chat-trace

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Aug 3, 2026 •

Copy link
Copy Markdown
Member

Summary

  • preserve sanitized reasoning and tool-call blocks when chat.history projects a mixed assistant message
  • render canonical structured reasoning in the shared native chat UI when reasoning display is enabled, while keeping copy/export answer-only
  • cover real Control UI navigation away from and back to a thread with Chromium E2E proof

Root cause

Transcript persistence retained the complete assistant turn. The loss occurred later in the gateway display projection: the mixed text/tool branch rebuilt the message from visible text blocks only, discarding sanitized thinking and toolCall siblings. Live events could therefore show the full trace, while authoritative history replay after navigation could not.

The durable invariant is that history projection may sanitize and bound blocks, but must not change their visibility merely because visible text and tool activity share one assistant message.

Validation

  • red base reproduction at 3c4dbea2ed17f084d8584ca78dcfb49ffee94ae1: mixed history returned text only (Testbox run)
  • focused gateway regression: 1 passed, 92 skipped (Testbox run)
  • adjacent tool-only preservation + commentary-only negative control: 2 passed, 142 skipped (Testbox run)
  • complete affected gateway projection file: 211 passed (Testbox run)
  • swift test --package-path apps/shared/OpenClawKit --filter ChatMessageVisibleTextTests: 8 passed
  • native i18n inventory verification: 5,395 entries, changed=false; Android and Apple inventories verified (Testbox run)
  • Chromium navigation E2E with reasoning, answer, and tool activity visible after return: 1 passed, 6 skipped (Testbox run)
  • pnpm check:changed: passed all selected core, core-test, and app lanes (Testbox run)
  • path-scoped changed gate for the final browser E2E: passed (same retained Testbox)
  • source-blind behavior validation: 4/4 user tasks, 6/6 expected behaviors, and 4/4 anti-cheat probes passed
  • autoreview: clean, no accepted/actionable findings

Production delta is +11 lines net; tests add the gateway regression, native enable/disable and copy guard, and the browser navigation contract.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime size: M maintainer Maintainer-authored PR labels Aug 3, 2026
@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. labels Aug 3, 2026
@clawsweeper

clawsweeper Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 2, 2026, 9:37 PM ET / August 3, 2026, 01:37 UTC.

ClawSweeper review

What this changes

The branch preserves sanitized reasoning and tool-call blocks in mixed assistant history messages, then renders enabled reasoning in native chat while leaving copied and exported text answer-only.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep this member-authored, maintainer-labeled PR open for explicit maintainer review. Current main demonstrably drops non-text assistant siblings whenever a history message also contains visible text and a tool block; the branch repairs that owner boundary, preserves copy/export’s answer-only behavior, and has focused Gateway, native, and browser-navigation coverage. No discrete patch defect was found, but the exact head still has a failing macOS Swift check and an in-progress iOS check to resolve before merge.

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

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with strong targeted proof, capped below A until the exact-head Apple check failure is resolved and iOS validation completes.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR supplies after-fix Chromium navigation evidence for the visible Control UI behavior, backed by focused Gateway and native regression coverage; redact any private data if additional logs or recordings are posted.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR supplies after-fix Chromium navigation evidence for the visible Control UI behavior, backed by focused Gateway and native regression coverage; redact any private data if additional logs or recordings are posted.
Evidence reviewed 7 items Current-main defect: Current main's mixed-tool projection rebuilds an assistant message from text blocks only, so thinking and toolCall siblings are discarded during history replay.
Canonical owner-boundary repair: The branch retains already-sanitized non-text siblings while still stripping and bounding visible assistant text, so the Gateway remains the single history-display owner.
Regression coverage: The focused projection test asserts that a mixed assistant message retains sanitized reasoning, visible text, and tool-call data; the Gateway integration test exercises the chat.history path from a persisted transcript.
Findings None None.
Security None None.

How this fits together

Persisted assistant transcript messages are sanitized by the Gateway before chat.history returns them to Control UI and native clients. This projection decides whether the trace already visible during a live run remains available after a user navigates away and reloads the conversation.

flowchart LR
  A[Persisted assistant transcript] --> B[Gateway history request]
  B --> C[Sanitized display projection]
  C --> D[History response]
  D --> E[Control UI reload]
  D --> F[Native chat rendering]
  E --> G[Reasoning and tool trace restored]
  F --> G
Loading

Decision needed

Question Recommendation
Should maintainers accept history replay preserving the same enabled reasoning and tool trace already available during live chat once the exact-head Apple validation is complete? Land after exact-head validation: Accept the Gateway-owned parity fix after diagnosing or clearing the failing macOS Swift job and completing the iOS job.

Why: The author is a repository member and the PR carries the protected maintainer label; the change also alters persisted conversation-state replay across clients, so an explicit maintainer acceptance is required even though the code path is well supported.

Before merge

  • Resolve merge risk (P1) - This changes the structured assistant state replayed from persisted history to multiple clients; maintainers should retain the Gateway’s existing sanitization and verify the exact payload remains safe for all consumers.
  • Resolve merge risk (P1) - The exact head has a failing macos-swift check and an in-progress ios-build check, leaving the affected native surface incompletely validated.
  • Complete next step (P2) - This member-authored, maintainer-labeled PR has no mechanical repair finding; the remaining action is explicit acceptance of the session-replay behavior after exact-head native validation.
Agent review details

Security

None.

PR surface

Source +8, Tests +158, Other +30. Total +196 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 1 16 8 +8
Tests 3 162 4 +158
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 5 69 39 +30
Total 9 247 51 +196

Review metrics

Metric Value Why it matters
Production vs test delta +11 production lines net; +185 test lines net The production change stays focused on the Gateway projection and native display boundary, while most added code is regression and navigation coverage.

Stored data model

Persistent data-model change detected: serialized state: apps/shared/OpenClawKit/Tests/OpenClawKitTests/ChatMessageVisibleTextTests.swift, serialized state: ui/src/e2e/chat-flow.history-recovery.e2e.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Complete cross-client validation before merge (recommended)
    Diagnose or clear the failed macOS Swift check and wait for the in-progress iOS check on the exact head before accepting the changed replay payload.
  2. Accept the remaining Apple-check uncertainty
    Merge based on the focused Gateway, native helper, and Chromium evidence while explicitly accepting the unresolved native CI state.

Technical review

Best possible solution:

Keep the Gateway sanitizer as the canonical history-projection owner, preserve its bounded and stripped blocks, and land the replay-parity repair only after the exact-head Apple checks are green or their failure is shown unrelated.

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

Yes, from source: current main's mixed-tool history projection at src/gateway/chat-display-projection.sanitize.ts:160 retains only text blocks, and the branch adds focused projection and chat.history regression coverage for the lost siblings. I did not execute the tests in this read-only review.

Is this the best way to solve the issue?

Yes. Repairing the Gateway display projection is the narrowest maintainable fix because it serves both Control UI and native consumers after per-block sanitization; the native change only renders already-canonical structured thinking under its existing reasoning-display option.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against f2af4e97b356.

Labels

Label justifications:

  • P2: This is a bounded chat-history replay defect with clear user-visible impact but no evidence of data loss, security bypass, or service unavailability.
  • merge-risk: 🚨 session-state: Merging changes which structured assistant blocks are replayed from persisted conversation history to client UIs.
  • 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. Sufficient (live_output): The PR supplies after-fix Chromium navigation evidence for the visible Control UI behavior, backed by focused Gateway and native regression coverage; redact any private data if additional logs or recordings are posted.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR supplies after-fix Chromium navigation evidence for the visible Control UI behavior, backed by focused Gateway and native regression coverage; redact any private data if additional logs or recordings are posted.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Git history attributes the current mixed-tool projection and native visible-text foundations to the same recent chat-display implementation, making this the clearest owner-boundary route. (role: feature introducer and recent area contributor; confidence: high; commits: 181da6f69c45, e144bc16d8; files: src/gateway/chat-display-projection.sanitize.ts, apps/shared/OpenClawKit/Sources/OpenClawChatUI/ChatMessageVisibleText.swift)

Rank-up moves

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

  • Diagnose or clear the exact-head macos-swift failure.
  • Wait for the exact-head ios-build result before merge.

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 (3 earlier review cycles)
  • reviewed 2026-08-03T00:40:29.283Z sha b453dd94edc15db6b03f077b3f8c28e442e4fa9d :: needs maintainer review before merge. :: none
  • reviewed 2026-08-03T00:51:34.696Z sha f281e070e65d2970d7081e1f54cd4c689adcae49 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-03T00:59:45.626Z sha f258ef6 :: needs maintainer review before merge. :: none

@fuller-stack-dev
fuller-stack-dev force-pushed the codex/ope-6-preserve-chat-trace branch from b453dd9 to f281e07 Compare August 3, 2026 00:45
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 3, 2026
@fuller-stack-dev
fuller-stack-dev force-pushed the codex/ope-6-preserve-chat-trace branch from f281e07 to f258ef6 Compare August 3, 2026 00:54
@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Aug 3, 2026
@fuller-stack-dev fuller-stack-dev self-assigned this Aug 3, 2026
@fuller-stack-dev
fuller-stack-dev merged commit d3c5ac8 into openclaw:main Aug 3, 2026
217 of 223 checks passed
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

@fuller-stack-dev
fuller-stack-dev deleted the codex/ope-6-preserve-chat-trace branch August 3, 2026 03:08
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 3, 2026
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 gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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