Skip to content

fix(ui): claim new-session handoffs on the direct chat route - #114377

Merged
steipete merged 3 commits into
mainfrom
fix/ui-e2e-session-path-drift
Jul 27, 2026
Merged

steipete merged 3 commits into
mainfrom
fix/ui-e2e-session-path-drift

Conversation

@steipete

@steipete steipete commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Four tests in ui/src/e2e/new-session-page.e2e.test.ts have been failing on main since #113883 landed path-based session routes. Bisected on a clean Blacksmith Testbox: cca5b147857d5c~1 green, cca5b147857d5c red. Nothing caught it because test/vitest/vitest.ui-e2e.config.ts is not referenced by ci.yml — only by package.json and mantis-web-ui-chat-proof.yml, which runs a single unrelated file.

Two of the four are stale test expectations. Two are real product regressions, tracked in #114374.

Why This Change Was Made

Stale expectations. #113883 replaced ?session=<key> with a /chat/<key> path, so url.searchParams.get("session") never matches again; the assertion now compares against controlUiSessionPath(sessionKey). Separately, the transcript bootstrap prefers chat.startup whenever the Gateway advertises it, so three waitForRequest("chat.history") gates could no longer fire and the image test deferred a method the app never calls. Those gates are replaced by the rendered rows they were standing in for, and the deferral moves to chat.startup.

ui/src/test-helpers/control-ui-e2e.ts gains the other half of that: a scenario that configures only chat.history now has its transcript replayed onto the chat.startup payload, so both bootstrap paths serve the same conversation instead of one silently returning nothing.

Product regressions (#114374). chat-pane-lifecycle.ts claimed the two one-shot handoffs — the rejected turn and the accepted prompt — only on the session-switch path. Before #113883 every created session went through that path. With deferred session navigation a pane can be routed straight onto the created session key, and then neither handoff is ever admitted: the rejected turn expires against its 60s TTL and the user gets no retry affordance, and the accepted prompt stays invisible until the transcript bootstrap resolves. The fix admits both handoffs on the direct-route branch as well, which is the same seam that already owns them.

Verified by instrumenting the handoff store: PROBE_PREPARE fires without a matching PROBE_CONSUME on unpatched main.

User Impact

Submitting a new session that the Gateway rejects now surfaces the error and keeps the draft recoverable instead of silently dropping it, and an accepted prompt appears immediately rather than after the transcript loads. The rest is test-only.

Evidence

Blacksmith Testbox, pnpm test:ui:e2e ui/src/e2e/new-session-page.e2e.test.ts:

State Result
main @ 736a788cb81d5b 37 passed, 4 failed
this branch 40 passed, 1 failed

The remaining failure is resolves a pending catalog target after reconnect without clearing the draft. It is not caused by this PR: it fails in isolation on unmodified main and at cca5b147857d5c~1, so it predates #113883. It passed in main's full-suite run only because an earlier test used to die on a stale URL assertion before completing its offline/online cycle; fixing that assertion removes the masking. Root cause is now identified and filed separately as #114398 — the new-session route loader drops the requested agent id while offline, so catalog.routeKey flips from ["","claude"] to ["research","claude"] on reconnect and resetDraft() wipes the typed message. That gets its own PR.

Chat unit suites covering the touched seam: chat-page.test.ts, route.test.ts, chat-pane-board.test.ts — 62 passed.

Fixes #114374

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: XS maintainer Maintainer-authored PR labels Jul 27, 2026
@steipete
steipete marked this pull request as ready for review July 27, 2026 06:31
@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 Jul 27, 2026
@clawsweeper

clawsweeper Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 27, 2026, 3:42 AM ET / 07:42 UTC.

ClawSweeper review

What this changes

The PR updates Control UI new-session handoffs so direct chat routes claim rejected-turn and initial-prompt state before transcript history resolves, with related mocked-Gateway test updates.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 5 items remain

Keep this maintainer-labeled PR open. The supplied context supports a focused repair for the direct-route handoff regression, but the sandbox prevented the mandatory current-source, scoped-policy, history, and lifecycle inspection; it also lacks inspectable after-fix browser/runtime proof.

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

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The proposal has focused test signal, but inspectable real behavior proof and the required source-level review are incomplete.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR reports mocked-Gateway E2E and unit results but supplies no inspectable after-fix browser or runtime artifact for direct-route prompt visibility or rejected-turn recovery; add redacted browser output, a recording, diagnostics, or runtime logs. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR reports mocked-Gateway E2E and unit results but supplies no inspectable after-fix browser or runtime artifact for direct-route prompt visibility or rejected-turn recovery; add redacted browser output, a recording, diagnostics, or runtime logs. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 3 items Repository review policy: The supplied root policy requires exhaustive current-source, caller/callee, test, documentation, scoped-policy, and history review before a PR verdict.
Read-only inspection unavailable: The allowed shell inspection failed before executing because the sandbox could not create its loopback interface; no repository files, git history, scoped AGENTS.md, maintainer notes, or live PR artifact could be inspected.
Provided PR context: The body links the central direct-route regression to the open report at #114374 and reports mocked-Gateway E2E plus unit results, but it provides no inspectable after-fix browser or runtime artifact.
Findings None None.
Security None None.

How this fits together

Control UI creates a new session from a submitted prompt, routes the browser to that session’s chat view, and reconciles temporary prompt or rejection handoffs with Gateway transcript history. The affected lifecycle controls whether users immediately see their prompt or a recovery state while transcript data is still loading.

flowchart LR
  A[New-session submission] --> B[Session creation]
  B --> C[Direct chat route]
  C --> D[Handoff admission]
  D --> E[Transcript history merge]
  E --> F[Visible prompt or retry state]
Loading

Decision needed

Question Recommendation
Should this maintainer-labeled Control UI session-state repair proceed after a reviewer verifies the direct-route lifecycle and receives real after-fix browser evidence? Complete focused lifecycle review: Inspect current direct-route, switch-route, reconnect, and transcript-reconciliation behavior, then assess redacted real-browser proof.

Why: The sandbox prevented the required source and history review, while the patch affects user-visible ephemeral session state where incorrect handoff ownership could regress ordering or recovery.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR reports mocked-Gateway E2E and unit results but supplies no inspectable after-fix browser or runtime artifact for direct-route prompt visibility or rejected-turn recovery; add redacted browser output, a recording, diagnostics, or runtime logs. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - The patch changes one-shot session-state admission and transcript merging, but the direct-route branch could not be compared with route-switch, reconnect, and sibling history-reconciliation paths.
  • Resolve merge risk (P1) - The supplied validation is mocked-Gateway test evidence; merge should wait for redacted real-browser or runtime proof showing immediate prompt visibility and rejected-turn recovery.
  • Complete next step (P2) - A maintainer must complete the mandatory current-source and lifecycle review; no safe automated repair action can be selected from the provided context alone.
Agent review details

Security

None.

PR surface

Source +61, Tests +28. Total +89 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 5 63 2 +61
Tests 2 36 8 +28
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 99 10 +89

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Verify handoff ordering before merge (recommended)
    Confirm direct-route admission, history reconciliation, reconnect behavior, and rejected-turn recovery using current-source review and redacted browser evidence.
  2. Pause pending lifecycle review
    Do not merge until the full state lifecycle can be inspected and the direct-route behavior is proven outside mocked test fixtures.

Technical review

Best possible solution:

Confirm the patch against the complete current chat lifecycle, then add redacted browser or runtime evidence that a directly routed new session immediately shows its submitted prompt and exposes a rejected-turn retry state without duplicate or reordered transcript rows.

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

No high-confidence reproduction was independently established because the read-only shell failed before source or tests could be inspected. The supplied context gives a focused mocked-Gateway path and direct-route sequence, so the report is source-reproducible only from that evidence.

Is this the best way to solve the issue?

Unclear. The patch is plausibly at the stated handoff seam, but the required comparison with current lifecycle callers, sibling paths, tests, and history could not be completed.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: The stated impact is a bounded Control UI regression affecting prompt visibility and failed-turn recovery.
  • merge-risk: 🚨 session-state: The patch changes transient prompt and rejected-turn handoffs reconciled with session transcript state during navigation.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR reports mocked-Gateway E2E and unit results but supplies no inspectable after-fix browser or runtime artifact for direct-route prompt visibility or rejected-turn recovery; add redacted browser output, a recording, diagnostics, or runtime logs. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Repository review policy: The supplied root policy requires exhaustive current-source, caller/callee, test, documentation, scoped-policy, and history review before a PR verdict. (AGENTS.md:1)
  • Read-only inspection unavailable: The allowed shell inspection failed before executing because the sandbox could not create its loopback interface; no repository files, git history, scoped AGENTS.md, maintainer notes, or live PR artifact could be inspected.
  • Provided PR context: The body links the central direct-route regression to the open report at Bug: #113883 dropped navigations, blank optimistic prompt, and lost rejected turn (Control UI e2e not in CI) #114374 and reports mocked-Gateway E2E plus unit results, but it provides no inspectable after-fix browser or runtime artifact. (70ce23d25e09)

Likely related people:

  • steipete: The provided related-item context attributes both the preceding path-route change and this follow-up repair to this contributor; broader current-main ownership could not be established without local history inspection. (role: recent area contributor; confidence: low; commits: cca5b147857d, 70ce23d25e09; files: ui/src/pages/chat/chat-pane-lifecycle.ts, ui/src/pages/chat/initial-turn-handoff.ts)

Rank-up moves

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

  • Add redacted real-browser or runtime proof for direct-route prompt visibility and rejected-turn recovery.
  • Compare the direct-route branch with existing switch, reconnect, and transcript-reconciliation paths 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 (2 earlier review cycles)
  • reviewed 2026-07-27T06:36:26.641Z sha 9a07efbd571554ef66d91f5ba4354aa1636173e0 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-27T07:21:07.577Z sha 3265cc7b6ce5477604c20a809ffe652d03d21ee3 :: needs real behavior proof before merge. :: none

@steipete steipete changed the title test(ui): align new-session e2e with path routes and startup transcript fix(ui): claim new-session handoffs on the direct chat route Jul 27, 2026
@steipete
steipete force-pushed the fix/ui-e2e-session-path-drift branch from 9a07efb to 3265cc7 Compare July 27, 2026 07:16
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. label Jul 27, 2026
steipete added 3 commits July 27, 2026 00:37
Deferred session navigation can route a pane straight onto the created
session key, which never runs the switch path that admits the one-shot
handoffs. The rejected turn then expired unclaimed instead of offering a
retry, and an accepted prompt stayed hidden until the transcript bootstrap
resolved. Mirror chat-state-route's admission on the direct branch.

Fixes #114374
A pane that admits the accepted prompt before its transcript bootstrap
resolves leaves that row in chatMessages while the history request is in
flight. The merge then re-placed it as a late optimistic tail, and since
#113266 stable rows keep insertion order, the first turn rendered below the
tool activity it kicked off. The handoff reconciler owns that head row, so
exclude it from the late tail.
@steipete

Copy link
Copy Markdown
Contributor Author

Both rank-up moves from the ClawSweeper review, addressed against head 70ce23d25e09b6.

1. Real-browser proof for direct-route prompt visibility and rejected-turn recovery

Captured with Playwright/Chromium against a built Control UI, screenshotting the live pane at the same point in each scenario with and without the product commits (git checkout HEAD~2 -- chat-pane-lifecycle.ts chat-pane-deps.ts / HEAD~1 -- chat-history.ts).

Rejected turn — adopts a created session when rejected-turn persistence exceeds browser storage

Before After
before after

Before, the pane is empty: the user's message is gone, with no error and nothing to retry — the handoff expired unclaimed against its 60s TTL. After, the storage error banner is shown and the failed turn is present with its Retry control, so the message is recoverable.

Accepted prompt — reconciles an image-bearing initial prompt into one user row

Before After
before after

Both frames are 2.5s after the route commits. Before, the thread is still skeletons — the prompt is not visible because it only arrives once the transcript bootstrap resolves. After, the prompt renders immediately.

Checksums and sizes: artifact-manifest.json. The screenshot calls were temporary instrumentation and are not part of the diff.

2. Comparison with the switch, reconnect, and transcript-reconciliation paths

  • Switch path — chat-state-route.ts:297-308 admits both handoffs and sets the same lastError/chatError pair when the rejected turn is claimed. The new direct-route branch in chat-pane-lifecycle.ts mirrors that exactly; it is the same seam, reached when nextSessionKey === state.sessionKey so switchPaneSession never runs.
  • Reconnect path — admitInitialUserMessageHandoff reads through handoff.read(sessionKey, client), which returns null for a replacement client (initial-user-message-handoff.ts:34-38). A reconnect that swaps the Gateway client therefore cannot resurrect a prompt into the wrong session; the existing keeps a pending prompt across reconnects from the same browser client and does not expose a pending prompt to a replacement gateway client cases still pass.
  • Transcript reconciliation — this is where the interaction actually was. Admitting the prompt before the in-flight chat.history/chat.startup response leaves it in chatMessages, and collectLateOptimisticTailMessages then re-placed it at the tail. Since fix(ui): keep stable chat rows in insertion order and only sort live tool/stream items by timestamp #113266 stable rows keep insertion order, that put the first turn below the tool activity it started. reconcileInitialUserMessageHandoff already owns that head row, so the fix excludes it from the late tail rather than adding a second placement rule. Covered by shows the initial prompt while the newly created session is still running (asserts the prompt row's y is above the tool row) and a new unit case in initial-turn-handoff.test.ts.

CI is green on this head (71 pass / 18 skip) after one rerun of checks-node-compact-small-3, which failed on an unrelated pid-file race in plugin-gateway-gauntlet.test.ts; that flake is fixed separately in #114418.

@steipete
steipete merged commit da4ae86 into main Jul 27, 2026
158 of 160 checks passed
@steipete
steipete deleted the fix/ui-e2e-session-path-drift branch July 27, 2026 08:34
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 28, 2026
…w#114377)

* test(ui): align new-session e2e with path routes and startup transcript

* fix(ui): claim new-session handoffs on the direct chat route

Deferred session navigation can route a pane straight onto the created
session key, which never runs the switch path that admits the one-shot
handoffs. The rejected turn then expired unclaimed instead of offering a
retry, and an accepted prompt stayed hidden until the transcript bootstrap
resolved. Mirror chat-state-route's admission on the direct branch.

Fixes openclaw#114374

* fix(ui): keep the projected first prompt above the replies it started

A pane that admits the accepted prompt before its transcript bootstrap
resolves leaves that row in chatMessages while the history request is in
flight. The merge then re-placed it as a late optimistic tail, and since
openclaw#113266 stable rows keep insertion order, the first turn rendered below the
tool activity it kicked off. The handoff reconciler owns that head row, so
exclude it from the late tail.
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 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. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S 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.

Bug: #113883 dropped navigations, blank optimistic prompt, and lost rejected turn (Control UI e2e not in CI)

1 participant