Skip to content

fix(ui): stabilize WebChat message ordering#74733

Open
VladyslavLevchuk wants to merge 1 commit into
openclaw:mainfrom
VladyslavLevchuk:fix/webchat-message-order
Open

fix(ui): stabilize WebChat message ordering#74733
VladyslavLevchuk wants to merge 1 commit into
openclaw:mainfrom
VladyslavLevchuk:fix/webchat-message-order

Conversation

@VladyslavLevchuk

@VladyslavLevchuk VladyslavLevchuk commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Rebased PR fix(ui): stabilize WebChat message ordering #74733 onto current origin/main and replaced the old XL patch with a focused WebChat reliability fix.
  • Keep optimistic user messages visible when a stale in-flight chat.history response resolves after a local send.
  • Avoid clearing active assistant stream/tool state while a run is still in progress.
  • Clear tool-stream artifacts during /clear/sessions.reset so old stream/tool cards cannot survive a reset.
  • Add a small temp-path guard cleanup for the current-main context treemap output path so pnpm check passes.

Problem

WebChat can start a chat.history request, then the user sends a message before that request resolves. The old response was reconciled against the request-start message list, so it could overwrite the newer optimistic user message and clear the active stream. Visually, the sent message could disappear and then come back only after a later response/history refresh.

Approach

  • Track local chat mutations separately from history request versions.
  • When a history response resolves after local state changed, merge against the latest visible chat state and preserve unanchored optimistic messages that are not present in the stale history payload.
  • Only clear streaming/tool state from history reloads when there is no active stream/run.
  • Reset tool-stream collections in the synchronous /clear reset path before reloading history.

Real behavior proof

  • Behavior or issue addressed: WebChat sent messages could disappear while an older chat.history request resolved after the local send; this patch keeps the optimistic send and active stream state visible.
  • Real environment tested: Vladyslav's Mac mini running the real OpenClaw launchd gateway (ai.openclaw.gateway) on port 18789, installed from this fork via the global /opt/homebrew/bin/openclaw npm symlink.
  • Exact steps or command run after this patch: Built and installed the final fork head, then restarted the real gateway: pnpm build, pnpm ui:build, npm install -g /Users/vladyslavlevchuk/Projects/openclaw-pr-74733, launchctl kickstart -k gui/$(id -u)/ai.openclaw.gateway, openclaw --version, curl -I http://127.0.0.1:18789/, and log inspection of ~/.openclaw/logs/gateway.log.
  • Evidence after fix: Copied live output from the real setup:
$ openclaw --version
OpenClaw 2026.5.10-beta.1 (48efa0e)

$ launchctl print gui/501/ai.openclaw.gateway
state = running
pid = 82744
last exit code = 0
arguments = /opt/homebrew/bin/openclaw gateway --port 18789

$ tail ~/.openclaw/logs/gateway.log
2026-05-10T14:18:23.620-04:00 [gateway] http server listening (10 plugins: acpx, active-memory, bonjour, browser, canvas, device-pair, file-transfer, memory-core, phone-control, talk-voice; 2.5s)
2026-05-10T14:18:24.289-04:00 [gateway] ready

$ curl -I http://127.0.0.1:18789/
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Cache-Control: no-cache
  • Observed result after fix: The fork is running in a real OpenClaw gateway setup and serving the rebuilt Control UI from the final PR head. The WebChat race is covered by a regression test that reproduces the stale-history response landing after a local send and asserts the optimistic user message remains visible while the active stream remains intact.
  • What was not tested: I did not manually send a production WebChat message through the operator's live session after installing; the live setup is installed for operator verification, and stale 2026.5.7 native clients may need an app restart or browser hard refresh to reconnect to the beta gateway.

Verification

  • pnpm build passed.
  • pnpm ui:build passed.
  • pnpm check passed.
  • pnpm --dir ui exec vitest run src/ui/controllers/chat.test.ts src/ui/chat/history-merge.test.ts src/ui/app-chat.test.ts --config vitest.config.ts passed: 101 tests.
  • pnpm format:check CHANGELOG.md src/auto-reply/reply/context-treemap.ts ui/src/ui/controllers/chat.ts ui/src/ui/controllers/chat.test.ts ui/src/ui/chat/history-merge.test.ts ui/src/ui/app-chat.ts ui/src/ui/app-chat.test.ts passed.
  • pnpm exec oxlint src/auto-reply/reply/context-treemap.ts ui/src/ui/controllers/chat.ts ui/src/ui/controllers/chat.test.ts ui/src/ui/chat/history-merge.test.ts ui/src/ui/app-chat.ts ui/src/ui/app-chat.test.ts passed.
  • pnpm tsgo:test:ui passed.
  • Final head 48efa0e303: pnpm check:changed passed.
  • Final head 48efa0e303: env -u OPENCLAW_ALLOW_INSECURE_PRIVATE_WS -u OPENCLAW_GATEWAY_HOST -u OPENCLAW_GATEWAY_TOKEN -u OPENCLAW_VAPID_SUBJECT pnpm test:changed:max passed: 21 shards.

Full Test Note

I also ran pnpm test after pnpm build. The branch-relevant shards passed, but the full local run failed in unrelated areas because this machine exports live OpenClaw gateway/VAPID env vars and because some broad current-main tests are sensitive to built dist/ or unrelated mock drift. I did not fold those unrelated repairs into this WebChat PR.

AI Assistance

AI-assisted. I reviewed the resulting diff and understand the behavior it changes.

@VladyslavLevchuk VladyslavLevchuk marked this pull request as draft April 30, 2026 01:43
@clawsweeper

clawsweeper Bot commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed May 30, 2026, 1:02 AM ET / 05:02 UTC.

Summary
Review failed before ClawSweeper could summarize the requested change.

PR surface: Source +38, Tests +94, Docs +1. Total +133 across 7 files.

Reproducibility: unclear. The review failed before ClawSweeper could establish a reproduction path.

Review metrics: none identified.

Merge readiness
Overall: 🌊 off-meta tidepool
Proof: 🌊 off-meta tidepool
Patch quality: 🌊 off-meta tidepool
Result: rating does not apply to this item.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

  • [P1] No close action taken because the review did not complete.

Maintainer options:

  1. Decide the mitigation before merge
    Retry the Codex review after fixing the execution failure.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] Review did not complete, so no work-lane recommendation was made.
Review details

Best possible solution:

Retry the Codex review after fixing the execution failure.

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

Unclear. The review failed before ClawSweeper could establish a reproduction path.

Is this the best way to solve the issue?

Unclear. Retry the review first so ClawSweeper can evaluate the actual issue and fix direction.

AGENTS.md: unclear because the file could not be read completely.

Codex review notes: model gpt-5.5, reasoning high; reviewed against b352cb2d8e7f.

Label changes

Label justifications:

  • rating: 🌊 off-meta tidepool: Overall readiness is 🌊 off-meta tidepool; proof is 🌊 off-meta tidepool and patch quality is 🌊 off-meta tidepool.
Evidence reviewed

PR surface:

Source +38, Tests +94, Docs +1. Total +133 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 3 50 12 +38
Tests 3 94 0 +94
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 145 12 +133

What I checked:

  • failure reason: codex execution failed.
  • codex failure detail: Codex review failed for this PR with exit 1.
  • codex stdout: Per-item Codex failure; continuing with the rest of the shard.

Likely related people:

  • unknown: Codex failed before it could trace repository history. (role: review did not complete; confidence: low)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@VladyslavLevchuk VladyslavLevchuk force-pushed the fix/webchat-message-order branch from b1c77be to ee167f9 Compare April 30, 2026 01:53
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M and removed size: S labels Apr 30, 2026
@VladyslavLevchuk VladyslavLevchuk force-pushed the fix/webchat-message-order branch from ee167f9 to b13558d Compare April 30, 2026 02:01
@VladyslavLevchuk VladyslavLevchuk force-pushed the fix/webchat-message-order branch from b13558d to f8ca635 Compare April 30, 2026 02:15
@VladyslavLevchuk VladyslavLevchuk changed the title fix(ui): stabilize chat item timestamps fix(ui): stabilize webchat history refreshes Apr 30, 2026
@VladyslavLevchuk VladyslavLevchuk force-pushed the fix/webchat-message-order branch from f8ca635 to 4069f02 Compare April 30, 2026 02:26
@VladyslavLevchuk VladyslavLevchuk force-pushed the fix/webchat-message-order branch from 4069f02 to cd7e5c3 Compare April 30, 2026 02:44
@VladyslavLevchuk VladyslavLevchuk changed the title fix(ui): stabilize webchat history refreshes fix(ui): stabilize WebChat message ordering Apr 30, 2026
@VladyslavLevchuk VladyslavLevchuk marked this pull request as ready for review April 30, 2026 03:00
@VladyslavLevchuk VladyslavLevchuk force-pushed the fix/webchat-message-order branch 2 times, most recently from 1f5d1ca to 62a2076 Compare April 30, 2026 03:30
@VladyslavLevchuk VladyslavLevchuk force-pushed the fix/webchat-message-order branch 7 times, most recently from 63df144 to 0afb27a Compare April 30, 2026 17:55
@openclaw-barnacle openclaw-barnacle Bot added the cli CLI command changes label Apr 30, 2026
@caiyc16888

Copy link
Copy Markdown

Dear @steipete, @vincentkoc,

We're experiencing a persistent WebChat issue where only the last message appears in the conversation view — history is not being rendered (backend data is intact, confirmed by checking session files).

This problem is directly addressed by the two PRs below, both of which remain unmerged:

Both capture the exact symptoms we're seeing: stale in-flight chat.history responses replacing local state, WebChat losing visible continuity, and brief socket detach/reattach tearing down state.

Could either of these please be reviewed and merged into the next release? This is affecting daily usability of the Control UI / WebChat. Happy to help test if a preview build is available.

Thanks 🙏

@caiyc16888 caiyc16888 mentioned this pull request May 3, 2026
25 tasks
@VladyslavLevchuk VladyslavLevchuk force-pushed the fix/webchat-message-order branch from 3c6572b to ff32a73 Compare May 10, 2026 17:48
@openclaw-barnacle openclaw-barnacle Bot added size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. and removed gateway Gateway runtime cli CLI command changes size: XL labels May 10, 2026
@VladyslavLevchuk VladyslavLevchuk marked this pull request as ready for review May 10, 2026 17:49
@VladyslavLevchuk VladyslavLevchuk force-pushed the fix/webchat-message-order branch 2 times, most recently from 606340a to e0b4405 Compare May 10, 2026 18:05
@VladyslavLevchuk VladyslavLevchuk force-pushed the fix/webchat-message-order branch from e0b4405 to 48efa0e Compare May 10, 2026 18:18
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 10, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label May 30, 2026
@clawsweeper clawsweeper Bot added the rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. label May 30, 2026
@barnacle-openclaw barnacle-openclaw Bot removed the stale Marked as stale due to inactivity label May 30, 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 proof: supplied External PR includes structured after-fix real behavior proof. rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants