Skip to content

fix(ui): adopt inFlightRun on Control UI history reload - #93273

Closed
LiuwqGit wants to merge 3 commits into
openclaw:mainfrom
LiuwqGit:fix/issue-90755-inflight-run
Closed

LiuwqGit wants to merge 3 commits into
openclaw:mainfrom
LiuwqGit:fix/issue-90755-inflight-run

Conversation

@LiuwqGit

@LiuwqGit LiuwqGit commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

What problem does this PR solve?

  • Control UI loses the in-progress assistant response when the user navigates away from a running chat session and returns; only the last committed user message is shown even though the gateway run is still active.

Why does this matter now?

What is the intended outcome?

  • Control UI adopts the existing chat.history inFlightRun contract (already used by TUI) on history reload, rehydrating chatRunId / chatStream so partial assistant text or a reading indicator appears after switch-back.

What is intentionally out of scope?

  • No gateway contract changes, no active tool-call replay extension, no CHANGELOG edit, no unrelated UI refactors.

What does success look like?

  • After loadChatHistory, when the gateway reports an in-flight run, the Control UI shows buffered assistant text or a reading indicator and continues receiving live deltas for that run.

What should reviewers focus on?

  • ui/src/ui/controllers/chat.ts (adoptInFlightRunFromChatHistory + call site after stream reset)
  • ui/src/ui/controllers/chat.test.ts (loadChatHistory inFlightRun adoption)

Linked context

Which issue does this close?

Closes #90755

Which issues, PRs, or discussions are related?

Related #90755 (ClawSweeper queueable-fix / fix-shape-clear / source-repro)

Was this requested by a maintainer or owner?

  • ClawSweeper marked queueable with Best possible solution: adopt existing inFlightRun in Control UI, mirror TUI.

Real behavior proof (required for external PRs)

  • Behavior or issue addressed: Control UI ignores inFlightRun from chat.history on session switch-back.
  • Real environment tested: Local checkout on fix/issue-90755-inflight-run; Playwright + Edge driving Control UI E2E harness (startControlUiE2eServer) with mock Gateway chat.history returning inFlightRun.
  • Exact steps or command run after this patch:
export PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH="/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
node --import tsx scripts/capture-proof-90755.mts
node scripts/run-vitest.mjs ui/src/ui/controllers/chat.test.ts

Browser repro steps (mock gateway, real Control UI DOM):

  1. Open Session A — only committed user message visible (01-chat-before-switch-back.png).
  2. Switch to Session B (clears local stream state).
  3. Switch back to Session A; deferred chat.history resolves with inFlightRun: { runId: "run-proof-90755", text: "still working in the background…" }.
  4. Control UI shows streaming assistant bubble + in-progress indicator (02-chat-after-inflight-restore.png).
  • Evidence after fix (screenshot, recording, terminal capture, console output, console output, redacted runtime log, linked artifact, or copied live output):
{
  "chatRunId": "run-proof-90755",
  "chatStream": "still working in the background…",
  "visibleInDom": "still working in the background…"
}

Screenshots (committed under proof/pr-90755/ on this branch):

  • Before switch-back: proof/pr-90755/01-chat-before-switch-back.png

  • After inFlightRun adoption: proof/pr-90755/02-chat-after-inflight-restore.png

  • Observed result after fix: After session switch-back, Control UI renders buffered assistant text (still working in the background…) and shows the in-progress/streaming state instead of appearing idle with only the user message.

  • What was not tested: Live gateway + real agent streaming run; active tool-call replay mid-run.

  • Proof limitations or environment constraints: Mock Gateway supplies inFlightRun (same contract as production chat.history); browser is local Edge via Playwright. Not reporter's production Control UI instance.

  • Before evidence (optional but encouraged): 01-chat-before-switch-back.png — Session A after initial load shows only the committed user message, no in-progress assistant bubble.

Tests and validation

Which commands did you run?

  • node scripts/run-vitest.mjs ui/src/ui/controllers/chat.test.ts — 119 passed
  • node scripts/run-vitest.mjs ui/src/ui/views/chat.test.ts — 65 passed
  • node scripts/run-vitest.mjs ui/src/ui/app-gateway.node.test.ts — 104 passed
  • pnpm oxfmt --check ui/src/ui/controllers/chat.test.ts ui/src/ui/controllers/chat.ts — pass
  • pnpm check:test-types — pass

What regression coverage was added or updated?

  • loadChatHistory inFlightRun adoption — buffered text restore + empty-text reading-indicator adoption.

What failed before this fix, if known?

  • chatRunId stayed null after history reload despite gateway inFlightRun payload.

If no test was added, why not?

  • N/A — regression tests added.

Risk checklist

Did user-visible behavior change? (Yes/No)

Yes. Returning to a running session now shows in-progress assistant output instead of appearing idle.

Did config, environment, or migration behavior change? (Yes/No)

No.

Did security, auth, secrets, network, or tool execution behavior change? (Yes/No)

No.

What is the highest-risk area?

  • Interaction between history stream reset and in-flight adoption when local stream state already exists.

How is that risk mitigated?

  • Adoption runs after existing reset logic; existing orphaned-stream materialization tests unchanged; new focused adoption tests added.

Current review state

What is the next action?

  • Real browser proof added (proof/pr-90755/). Await ClawSweeper re-review / maintainer merge.

What is still waiting on author, maintainer, CI, or external proof?

  • Optional live gateway proof if maintainer requests; active tool-call replay out of scope unless reported.

Which bot or reviewer comments were addressed?

  • ClawSweeper status: needs proof — added Control UI browser screenshots + Playwright capture (scripts/capture-proof-90755.mts, local-only).

Restore chatRunId/chatStream from chat.history inFlightRun when
switching back to a running session, matching existing TUI behavior.

Fixes openclaw#90755

Co-authored-by: Cursor <[email protected]>
@clawsweeper

clawsweeper Bot commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close: the valid Control UI reconnect bug remains owned by the canonical open issue, while this PR repeats the direct cumulative inFlightRun.text adoption shape that maintainers already rejected as unsafe.

Canonical path: Keep #90755 as the canonical owner for a gateway/history contract that exposes or reconciles only the unpersisted active-run portion, with proof attached outside the repo branch.

So I’m closing this here and keeping the remaining discussion on #90755.

Review details

Best possible solution:

Keep #90755 as the canonical owner for a gateway/history contract that exposes or reconciles only the unpersisted active-run portion, with proof attached outside the repo branch.

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

Yes. The bug is source-reproducible: current main exposes chat.history.inFlightRun through Gateway/TUI paths while Control UI does not adopt it, and the PR screenshots show the intended UI behavior against a mock Gateway.

Is this the best way to solve the issue?

No. This PR is not the best fix because it assigns the cumulative in-flight buffer directly; the safer solution is the maintainer-requested canonical unpersisted active-run contract or reconciliation helper.

Security review:

Security review cleared: No concrete security or supply-chain concern was found; the diff does not touch dependencies, workflows, permissions, secrets, or executable install paths.

AGENTS.md: found and applied where relevant.

What I checked:

  • Repository policy read: Root and scoped UI policy were read fully; root policy affected this review because it requires whole-path review and says PR proof images/assets must not be committed to the product repo branch. (AGENTS.md:1, 66079161d72a)
  • Current Control UI history behavior: Current main's history loader has stream reconciliation and no inFlightRun adoption; the bug is real, but this loader already guards against clobbering newer local run state via resetStream. (ui/src/ui/controllers/chat.ts:741, 66079161d72a)
  • PR adopts cumulative text directly: The PR assigns normalized inFlightRun.text directly into state.chatStream, matching the unsafe direct-adoption shape maintainers rejected on the prior related PR. (ui/src/ui/controllers/chat.ts:447, a6e836e994f5)
  • PR adoption is unguarded after reconciliation: The PR calls the adoption helper after the reconciliation block without checking resetStream or an existing newer state.chatRunId, so a stale history result can overwrite a fresher local run. (ui/src/ui/controllers/chat.ts:831, a6e836e994f5)
  • Maintainer supersession evidence: A maintainer closed the prior related implementation and requested a canonical gateway/history contract for the unpersisted active-run portion; the canonical issue remains open for that work. (9cfe6746ca11)
  • Gateway buffer semantics: Current main builds the live buffer cumulatively before storing it and then exposes projected buffered text through inFlightRun, so the snapshot is not proven to be only the unpersisted tail. (src/gateway/server-chat.ts:748, 66079161d72a)

Likely related people:

  • vincentkoc: Closed the prior related implementation with the same cumulative-buffer concern and authored recent Control UI startup/history metadata work in the touched loader area. (role: prior reviewer and recent Control UI history contributor; confidence: high; commits: 2c6bdc8b2831; files: ui/src/ui/controllers/chat.ts, ui/src/ui/app-chat.ts, ui/src/test-helpers/control-ui-e2e.ts)
  • williamliu-ai: Authored the merged gateway/TUI chat.history.inFlightRun snapshot and TUI switch-back adoption path that this PR tries to consume from Control UI. (role: sibling in-flight run contract author; confidence: high; commits: 8eeb9300df40; files: src/gateway/chat-abort.ts, src/gateway/server-methods/chat.ts, src/tui/tui-session-actions.ts)
  • osolmaz: Authored recent Control UI stream/history reconciliation work in the same loader and rendering path affected by this PR. (role: adjacent stream reconciliation contributor; confidence: medium; commits: 17a285f29825; files: ui/src/ui/controllers/chat.ts, ui/src/ui/chat/stream-reconciliation.ts, ui/src/ui/chat/build-chat-items.ts)

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

@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. labels Jun 15, 2026
@LiuwqGit

Copy link
Copy Markdown
Contributor Author

CI babysit update

  • All checks green on prior head (903dc6d1df).
  • Merged latest origin/main (3 commits) → 0b6201c400; local chat.test.ts still 119/119.
  • No merge conflicts; no unresolved inline review threads.

Remaining blocker (not CI): ClawSweeper status: needs proof — real Control UI browser evidence for switch-back in-flight restore. L2 vitest covers state adoption; happy to add screenshot/recording if maintainer prefers author proof, or Mantis visual capture per bot suggestion.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jun 15, 2026
Playwright capture showing inFlightRun restore after session switch-back.

Co-authored-by: Cursor <[email protected]>
@LiuwqGit

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Added real Control UI browser proof (Playwright + Edge, mock Gateway chat.history.inFlightRun):

After fix — session switch-back restores buffered assistant text + in-progress indicator:
https://github.com/LiuwqGit/openclaw/blob/fix/issue-90755-inflight-run/proof/pr-90755/02-chat-after-inflight-restore.png

Before — only committed user message after initial load:
https://github.com/LiuwqGit/openclaw/blob/fix/issue-90755-inflight-run/proof/pr-90755/01-chat-before-switch-back.png

Runtime state after switch-back:

{ "chatRunId": "run-proof-90755", "chatStream": "still working in the background…" }

PR body updated with capture steps. Local repro: node --import tsx scripts/capture-proof-90755.mts (Edge path via PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH).

@clawsweeper

clawsweeper Bot commented Jun 15, 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: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 15, 2026
@clawsweeper

clawsweeper Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

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 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: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: reconnecting to a running session only shows last user message, missing agent's in-progress response

1 participant