Skip to content

fix(ui): preserve chat history and active run timing - #119729

Merged
fuller-stack-dev merged 7 commits into
openclaw:mainfrom
fuller-stack-dev:codex/fix-control-ui-history-timer
Aug 5, 2026
Merged

fuller-stack-dev merged 7 commits into
openclaw:mainfrom
fuller-stack-dev:codex/fix-control-ui-history-timer

Conversation

@fuller-stack-dev

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

Copy link
Copy Markdown
Member

Closes #119728

Related: #110771, #111854, #113980

AI-assisted: Codex was used to diagnose, implement, review, and verify this change. No agent transcript is included.

What Problem This Solves

Fixes an issue where users returning to an active Control UI session could lose otherwise-displayable chat history, reasoning, and tool activity behind [chat.history omitted: message too large], while the working timer restarted from the navigation, reconnect, or reload time.

Why This Change Was Made

The Gateway display projection now removes private __openclaw.upstreamUserText reconstruction metadata before applying the public history budget. The active-run snapshot also carries its authoritative start timestamp, and Control UI history/tool replay preserves that timestamp rather than substituting the recovery time.

This is distinct from #111854 / #113980: those handle how genuinely oversized rows are presented after omission. This change prevents a normal visible row from being omitted solely because private metadata inflated the display payload.

The dependency boundary was checked directly against OpenAI Codex source at 4df8027a9703: codex-rs/protocol/src/models.rs:908-920,1252-1256 defines internal message metadata and its removal boundary; codex-rs/core/src/client.rs:832-856,1180-1200 clears that metadata before unsupported-provider delivery and metadata-insensitive request comparison.

User Impact

Navigating away from, reconnecting to, or reloading an active session now restores the visible prompt, assistant progress/reasoning, running tool activity, stop control, and elapsed working time from the original run start. Completed reasoning, answer text, and tool call/result history also remain visible after switching sessions.

Release Note Context

Control UI: preserve chat history, reasoning/tool activity, and elapsed working time after session navigation, reconnect, or reload.

CHANGELOG.md is intentionally unchanged for maintainer release preparation.

Evidence

Direct Azure Crabbox proof

Gateway contract:

pnpm test \
  src/gateway/chat-display-projection.test.ts \
  src/gateway/chat-abort.test.ts \
  src/gateway/server.chat.gateway-server-chat-b.test.ts

Result: 3 files, 149 tests passed.

Active-turn Chromium recovery:

OPENCLAW_CAPTURE_UI_PROOF=1 \
node scripts/run-vitest.mjs run \
  --config test/vitest/vitest.ui-e2e.config.ts \
  --configLoader runner \
  ui/src/e2e/chat-active-turn-recovery.e2e.test.ts

Result: 3 tests passed: SPA navigation, socket reconnect, and full reload. Downloaded screenshots show the prompt, progress text, running Read tool, stop control, and original 10-minute elapsed time after navigation/reload.

Completed history/reasoning/tool Chromium recovery:

OPENCLAW_UI_E2E_ARTIFACT_DIR=.artifacts/control-ui-e2e/azure-history-timer-proof/completed \
node scripts/run-vitest.mjs run \
  --config test/vitest/vitest.ui-e2e.config.ts \
  --configLoader runner \
  ui/src/e2e/chat-flow.history-recovery.e2e.test.ts \
  -t "restores reasoning and tool activity after navigating away from a session"

Result: 1 focused test passed. Downloaded screenshots and WebM show reasoning, answer text, and Read tool activity before and after returning to the session.

Artifact archive SHA-256: 2f5b91df6e284b60c3a2d653cc43b827935b4ec5005092d7e47dd001f986c1dd.

Authoritative reconnect timer follow-up

OPENCLAW_CAPTURE_UI_PROOF=1 \
  pnpm test ui/src/e2e/chat-active-turn-recovery.e2e.test.ts

Result: 1 file, 3 tests passed. The reconnect snapshot uses an authoritative start time approximately 10 minutes old and asserts both the recovered elapsed component timestamp and visible 10m text. The downloaded 04-reconnect-after.png visibly shows the restored prompt, assistant progress, running Read README.md tool, stop control, and 10m 1s elapsed time after socket reconnect.

  • Reconnect screenshot SHA-256: 5f845e3745d7d1f499452718d6aef09cb5c1924bbc926de9278b524842feae47
  • Follow-up artifact archive SHA-256: 69654c4efdfd035e109417dc4f15b6dca234871fda4b3e88786ae079940940cb

Oversized fallback budget follow-up

pnpm test \
  src/gateway/chat-abort.test.ts \
  ui/src/pages/chat/chat-history.inflight.test.ts

Result: 2 files, 74 tests passed. The exact-boundary regression proves the former minimal { runId, text } fallback remains within maxBytes, omits startedAt when adding it would overflow, and retains startedAt when the fallback budget permits it.

The Chromium proof was not repeated for this follow-up because the change only guards the optional timestamp in the oversized-snapshot fallback. Ordinary active-turn snapshots, including the captured reconnect case, still use the unchanged full-snapshot path.

Frozen-base final proof

Results:

  • 149 Gateway contract tests passed.
  • 26 Control UI in-flight history tests passed.
  • 1 real Gateway restart/history persistence test from the included canonical base passed.
  • 3 Chromium active-turn navigation/reconnect/reload tests passed.
  • Targeted oxlint reported zero errors; targeted formatting and git diff --check passed.

The downloaded reconnect screenshot visibly shows the restored prompt, assistant progress, running Read README.md tool, stop control, and 10m 1s elapsed time.

  • Reconnect screenshot SHA-256: ea8784d4408a4b3e9e1fb07092c1ba28f202226bdb38b296ac1b7d43e87d6b32
  • Final artifact archive SHA-256: f5a50de690ba4cc00846020aacbb9ea74bf0c46c30b45da3040339b8cdef4818

Additional checks

  • Testbox focused proof: 200 focused Gateway/UI tests passed, 3 Chromium E2E tests passed, and check:changed passed.
  • Final test-only autoreview --mode uncommitted: clean, no accepted/actionable findings; correctness confidence 0.99.
  • git diff --check: passed.

Scope

  • Production: +35 / -5 lines (net +30)
  • Tests/helpers: +119 / -17 lines (net +102)
  • No configuration, storage schema, protocol version, dependency, or changelog changes.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Aug 5, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Aug 5, 2026
@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 5, 2026, 7:35 PM ET / 23:35 UTC.

ClawSweeper review

What this changes

The PR removes private reconstruction metadata before Gateway history budgeting and preserves an active run’s original start time through Control UI recovery.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No actionable patch defect was found, and the previous fallback-budget finding is fixed. This maintainer-authored, protected PR remains open for explicit maintainer handling because the required sibling Codex source checkout is unavailable for contract verification.

Priority: P1
Reviewed head: 20b2ee5e73aacb863f804d47e468902d072fa70e
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch and its regression coverage address the prior finding, but the required direct Codex contract check is unavailable in this environment.
Proof confidence 🌊 off-meta tidepool Not applicable: The author is a repository member, so the external-contributor proof gate does not apply; the PR body nevertheless reports focused Chromium and Gateway evidence.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The author is a repository member, so the external-contributor proof gate does not apply; the PR body nevertheless reports focused Chromium and Gateway evidence.
Evidence reviewed 6 items Current-main defect path: Current main selects an active run’s startedAtMs but omits it from the returned snapshot, so recovery has no authoritative start time.
Bounded fallback repair: The branch adds startedAt only when the minimal recovery snapshot remains within the history byte budget; its boundary test preserves the former exact-fit fallback.
Recovery consumer: The branch accepts a finite snapshot timestamp before replaying activity, preserving the run start rather than substituting recovery time.
Findings None None.
Security None None.

How this fits together

Gateway history projects persisted session records into a bounded display payload, then sends any active-run snapshot to the Control UI. The UI replays that snapshot into visible history, tools, and the elapsed working indicator.

flowchart LR
A[Session transcript] --> B[Gateway display projection]
B --> C[Remove private reconstruction metadata]
C --> D[History byte budget]
D --> E[Active run snapshot]
E --> F[Control UI recovery]
F --> G[Visible history and elapsed time]
Loading

Decision needed

Question Recommendation
Should this PR proceed once a reviewer with a sibling Codex checkout verifies that upstreamUserText is reconstruction-only metadata and safe to omit from display projection? Verify the Codex contract, then merge: Inspect the cited Codex metadata boundary against the exact dependency source and retain this focused repair if it confirms the field is non-display reconstruction data.

Why: Repository policy requires the acting reviewer to inspect the exact Codex source before a Codex-related merge or proof-sufficiency verdict, and this read-only environment cannot supply that source.

Before merge

  • Resolve merge risk (P1) - The branch’s Codex-specific metadata rationale cannot receive dependency-contract clearance until a reviewer can inspect the required sibling Codex source.
Agent review details

Security

None.

PR surface

Source +36, Tests +96. Total +132 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 5 42 6 +36
Tests 6 112 16 +96
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 154 22 +132

Review metrics

Metric Value Why it matters
Production vs test LOC production +35/-5; tests/helpers +119/-17 The production growth carries one coherent recovery-state capability and is backed by focused Gateway and Control UI coverage.

Stored data model

Persistent data-model change detected: serialized state: src/gateway/chat-display-projection.test.ts, vector/embedding metadata: src/gateway/chat-display-projection.test.ts. Confirm migration or upgrade compatibility proof before merge.

Mantis proof suggestion

A redacted web-chat recovery recording would materially complement the supplied Chromium evidence for this user-visible navigation and reconnect flow. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis web UI chat proof: verify that returning to an active session preserves visible progress, tool activity, and the original elapsed time.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Verify the reconstruction-metadata contract from a sibling Codex checkout, then land this single Gateway-to-Control-UI recovery path if that contract confirms the field is display-private.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Verify the reconstruction-metadata contract from a sibling Codex checkout, then land this single Gateway-to-Control-UI recovery path if that contract confirms the field is display-private.

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

Yes—source shows current main drops the selected active-run start time and retains private metadata through display projection; the branch adds focused boundary and Chromium recovery coverage.

Is this the best way to solve the issue?

Yes, provisionally—the producer projects display data and the active-run owner carries its authoritative timestamp; direct Codex contract inspection remains required before a merge verdict.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The author is a repository member, so the external-contributor proof gate does not apply; the PR body nevertheless reports focused Chromium and Gateway evidence.
  • remove merge-risk: 🚨 availability: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: The changed path restores active session history, tool activity, and elapsed timing after navigation, reconnect, or reload.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The author is a repository member, so the external-contributor proof gate does not apply; the PR body nevertheless reports focused Chromium and Gateway evidence.

Evidence

What I checked:

  • Current-main defect path: Current main selects an active run’s startedAtMs but omits it from the returned snapshot, so recovery has no authoritative start time. (src/gateway/chat-abort.ts:371, d3d25737cf31)
  • Bounded fallback repair: The branch adds startedAt only when the minimal recovery snapshot remains within the history byte budget; its boundary test preserves the former exact-fit fallback. (src/gateway/chat-abort.ts:404, 20b2ee5e73aa)
  • Recovery consumer: The branch accepts a finite snapshot timestamp before replaying activity, preserving the run start rather than substituting recovery time. (ui/src/pages/chat/chat-history.ts:1790, 20b2ee5e73aa)
  • Shared Gateway entry point: Both chat.history and chat.startup obtain and bound the same in-flight snapshot before responding. (src/gateway/server-methods/chat-history-handler.ts:550, d3d25737cf31)
  • Main and release status: The PR head is not contained by current main or the latest release; it is not superseded or shipped. (20b2ee5e73aa)
  • Codex contract gap: The required sibling Codex source checkout is absent, and the partial clone could not retrieve it because DNS resolution failed; the PR body’s Codex citations were not treated as independently verified.

Likely related people:

  • Peter Steinberger: Available blame attributes the current active-run recovery and Gateway snapshot boundaries to the same recent main commit; deeper provenance is limited by the promisor checkout. (role: recent area contributor; confidence: medium; commits: 40a3bd2e10; files: src/gateway/chat-abort.ts, ui/src/pages/chat/chat-history.ts, src/gateway/chat-display-projection.sanitize.ts)

Rank-up moves

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

  • Have a reviewer with the sibling Codex checkout verify the cited metadata boundary, then request an exact-head review refresh.

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 (1 earlier review cycle)
  • reviewed 2026-08-05T21:32:05.790Z sha e30965e :: found issues before merge. :: [P2] Keep the fallback snapshot within its byte budget

@fuller-stack-dev

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Aug 5, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

ClawSweeper Rank-up move disposition for exact head 20b2ee5e73aacb863f804d47e468902d072fa70e:

  • Direct sibling Codex verification is complete. I inspected ../codex and the exact managed dependency tags. At rust-v0.146.1 (79b4f03d35962b005b007a015113b38930711665), codex-rs/protocol/src/models.rs:1116-1120 explicitly removes internal chat-message metadata before unsupported-provider delivery; codex-rs/core/src/client.rs:362-374 compares response items while ignoring that metadata, and :850-853 clears it for non-OpenAI providers. The two contract files are unchanged from rust-v0.146.0 to rust-v0.146.1. This confirms the cited metadata is transport/reconstruction state rather than Control UI display content.
  • The requested exact-head refresh was the single bounded re-review just completed; its durable verdict is comment 5197630437. No further refresh is needed because the head is unchanged and the review found no actionable patch defect.

No code or base update was made.

@fuller-stack-dev
fuller-stack-dev merged commit 3645e36 into openclaw:main Aug 5, 2026
134 checks passed
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

@fuller-stack-dev
fuller-stack-dev deleted the codex/fix-control-ui-history-timer branch August 5, 2026 23:48
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 6, 2026
* fix(ui): preserve chat history and active run timing

* test(ui): prove reconnect preserves active timer

* fix(gateway): keep recovery fallback within budget

* test(gateway): keep chat abort coverage within lint budget
vincentkoc added a commit to VACInc/openclaw that referenced this pull request Aug 6, 2026
…cope

* origin/main: (24 commits)
  fix(backup): skip transient gateway lock databases (openclaw#119782)
  test(agents): use canonical auth session fixtures (openclaw#119821)
  fix(memory): keep QMD file hints after stale docid misses (issue openclaw#113041) (openclaw#113515)
  test(doctor): align fast-path repair contracts (openclaw#119812)
  perf(agents): index subagent recovery ownership (openclaw#119793)
  fix(gateway): keep chat startup off catalog discovery (openclaw#119742)
  fix(test): keep TUI PTY suites in their owner lane (openclaw#119787)
  docs: correct dashboard auth precedence (openclaw#119785)
  docs: document control ui owner handoff
  fix: grant host-authorized control ui owner access
  fix(worktrees): preserve registered roots during orphan cleanup (openclaw#119709)
  fix(matrix): prevent shared client key collisions (openclaw#119667)
  fix(diagnostics-otel): propagate exported span context (openclaw#112283)
  fix(worker): isolate state observer failures (openclaw#117507)
  fix(qa): attest realized profile executions (openclaw#119761)
  fix(gateway): finish successful sessions after timestamp races (openclaw#119752)
  fix(agents): fence restart recovery lifecycle (openclaw#119776)
  fix(ui): preserve chat history and active run timing (openclaw#119729)
  improve(ollama): reduce inactive startup cost (openclaw#119745)
  improve(gateway): defer inactive plugin runtime imports (openclaw#119733)
  ...
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 P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S 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.

[Bug]: Control UI session recovery drops visible history and resets active elapsed time

1 participant