Skip to content

perf(ui): parallelize session-switch hydration - #114338

Merged
steipete merged 3 commits into
mainfrom
perf/ui-session-switch-waterfall
Jul 27, 2026
Merged

steipete merged 3 commits into
mainfrom
perf/ui-session-switch-waterfall

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Switching sessions in the Control UI triggers a burst of RPCs whose server-side costs stack when serialized. Production averages on team.openclaw.ai: chat.startup 436ms, sessions.branches.list 341ms, session.discussion.info 312ms, sessions.messages.subscribe 292ms, sessions.companion.state 212ms, chat.metadata 137ms. With the previous await structure, secondary hydration gated on earlier calls, so perceived switch latency trended toward the sum (~1.7s) rather than the max (~450ms).

Why This Change Was Made

Hydration is now split into a critical path and a deferred set:

  • chat.metadata starts concurrently with chat.startup instead of after it, with coordination so startup-provided metadata and the parallel fetch cannot fight (including the compatible model/command fallback path in chat-state-refresh.ts).
  • Discussion info, branch listing, companion state, and PR suggestions defer until after the transcript commits, so first render is gated only by the transcript-critical calls.
  • Fast-switch safety keeps every existing per-surface version guard (history, branch, metadata, discussion, companion, PR); deferred work re-checks session and connection identity before applying, so a stale response can never clobber the newly selected session.

No server, protocol, or config changes.

User Impact

Session switching renders the chat pane on the critical path only — roughly the slowest single call instead of the whole chain. Deferred panels hydrate immediately after, without blocking input.

Evidence

  • New regressions: reversed PR responses, stale deferred hydration, parallel startup metadata coordination, fallback ordering, same-client reconnects; hydration await-graph test proves chat.metadata starts while chat.startup is held open.
  • Suites: chat metadata/state 281 passed; pane lifecycle 18; pane integration/discussion/PR 73; chat history 14; mocked-browser E2E on Testbox 1 passed (UI usable while chat.startup held open).
  • Focused re-run post-handoff: hydration/lifecycle/PR/send suites green (1 shard). Type-aware oxlint clean; no new exports (knip-safe); no CHANGELOG edit.
  • Autoreview (Codex gpt-5.6-sol, xhigh): three fallback/reconnect findings accepted and fixed during the work; final pass clean, "patch is correct (0.9)".

@steipete
steipete marked this pull request as ready for review July 27, 2026 05:25
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: M maintainer Maintainer-authored PR labels Jul 27, 2026
@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. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. 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, 1:36 AM ET / 05:36 UTC.

ClawSweeper review

What this changes

This PR starts Control UI chat metadata alongside transcript startup and defers branches, discussion, companion, and pull-request hydration until the transcript has committed, aiming to make session switching responsive sooner.

Merge readiness

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

Keep this PR open for explicit maintainer handling and real browser behavior proof. The patch has focused concurrency guards and contributor-reported automated coverage, but the available evidence only demonstrates mocked-browser behavior rather than an inspectable after-fix Control UI session-switch run; the maintainer label also requires human handling.

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

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The patch is focused and regression-tested, but mock-only evidence leaves the required real browser behavior proof unresolved.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR body reports a mocked-browser Testbox E2E result and focused tests, but the provided context contains no inspectable after-fix run of a real Control UI session switch. Please add redacted recording, terminal/live output, or runtime logs; after updating the PR body, a maintainer can request @clawsweeper re-review if a fresh review does not trigger automatically. 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 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR body reports a mocked-browser Testbox E2E result and focused tests, but the provided context contains no inspectable after-fix run of a real Control UI session switch. Please add redacted recording, terminal/live output, or runtime logs; after updating the PR body, a maintainer can request @clawsweeper re-review if a fresh review does not trigger automatically. 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 5 items Deferred hydration implementation: The PR adds a post-transcript scheduling path that checks request version, connection generation, client identity, and session key before starting secondary session hydration.
Parallel startup metadata coverage: The PR adds tests asserting that chat metadata starts while the startup transcript request remains unresolved, plus fallback-ordering coverage.
Stale-response coverage: The PR adds a regression test for a previous session's pull-request response arriving after a newer session has become active.
Findings None None.
Security None None.

How this fits together

When a user switches sessions in the Control UI, the chat pane loads the transcript and then refreshes optional session-specific panels. This PR keeps transcript-critical startup on the first-render path while scheduling optional panels after the render commit and rejecting stale responses from prior sessions or connections.

flowchart LR
  A[User switches session] --> B[Start transcript and metadata requests]
  B --> C[Commit transcript render]
  C --> D[Check session and connection identity]
  D --> E[Hydrate branches and discussion]
  D --> F[Hydrate companion and pull requests]
  E --> G[Updated session panels]
  F --> G
Loading

Decision needed

Question Recommendation
Should this session-state scheduling change land after the contributor supplies inspectable real Control UI proof for rapid switching and same-client reconnect behavior on the refreshed head? Request live UI proof: Require a redacted recording, runtime trace, or terminal-backed demonstration showing transcript-first rendering and correct deferred panels across rapid session changes and reconnects.

Why: The patch changes ordering across several per-session UI surfaces, and the protected maintainer label plus absent inspectable live proof make this a human merge decision rather than an automated repair decision.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR body reports a mocked-browser Testbox E2E result and focused tests, but the provided context contains no inspectable after-fix run of a real Control UI session switch. Please add redacted recording, terminal/live output, or runtime logs; after updating the PR body, a maintainer can request @clawsweeper re-review if a fresh review does not trigger automatically. 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 change deliberately reorders four session-scoped hydrations around transcript commits; mocked tests cover important stale-response paths, but an inspectable real Control UI rapid-switch and reconnect run is still needed to confirm no visible panel remains stale or delayed indefinitely.
  • Resolve merge risk (P1) - The branch is behind current main; although GitHub reports it mergeable, the final three-way merge should be refreshed against the current lifecycle code before landing.
  • Complete next step (P2) - The remaining merge gate is contributor-supplied real behavior proof plus maintainer review of the refreshed lifecycle ordering, not a narrow mechanical code repair.
Agent review details

Security

None.

PR surface

Source +98, Tests +255. Total +353 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 8 161 63 +98
Tests 5 256 1 +255
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 417 64 +353

Review metrics

Metric Value Why it matters
Session hydration ordering 4 secondary panel hydrations deferred; 1 metadata request parallelized The PR changes when several session-scoped surfaces may apply state, so reviewers need to assess transcript-first responsiveness against stale-state protections.

Stored data model

Persistent data-model change detected: migration/backfill/repair: ui/src/pages/chat/chat-pane-lifecycle.test.ts, vector/embedding metadata: ui/src/e2e/chat-flow.e2e.test.ts, vector/embedding metadata: ui/src/pages/chat/chat-send.test.ts. Confirm migration or upgrade compatibility proof before merge.

Proof path suggestion

Mantis can provide targeted web UI chat proof that the transcript becomes usable before the deferred session panels finish hydrating. Mantis is proof-only, so it must not be asked to change code or mutate GitHub state.
Use ClawSweeper's repair, apply, or automerge lanes for code changes, branch updates, labels, comments, PR repair, closes, or merges.

Merge-risk options

Maintainer options:

  1. Prove rapid-switch safety before merge (recommended)
    Refresh the branch against current main and provide redacted real UI evidence covering transcript-first paint, rapid session changes, and same-client reconnect before merge.
  2. Accept the residual lifecycle risk
    Land with the existing mocked regression coverage while accepting that real browser scheduling across reconnects was not independently demonstrated.

Technical review

Best possible solution:

Retain the guarded deferred-hydration design, rebase or refresh it against current main, and attach a redacted real Control UI session-switch recording, terminal trace, or runtime log that shows transcript-first rendering plus correct branch, discussion, companion, and pull-request updates after rapid switching and reconnect.

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

Not applicable: this PR targets responsiveness rather than a separately specified broken behavior. The reported performance path is concrete, but the supplied evidence does not include an inspectable live reproduction or after-fix trace.

Is this the best way to solve the issue?

Unclear: deferring non-transcript hydration behind the render commit is a plausible bounded solution, but it needs real Control UI proof on a refreshed head to establish that this is the safest ordering across reconnect and fast-switch paths.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This is a bounded Control UI responsiveness improvement with meaningful but non-emergency user impact.
  • add merge-risk: 🚨 session-state: The patch changes scheduling and stale-response guards for session-specific branches, discussion, companion, and pull-request state.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports a mocked-browser Testbox E2E result and focused tests, but the provided context contains no inspectable after-fix run of a real Control UI session switch. Please add redacted recording, terminal/live output, or runtime logs; after updating the PR body, a maintainer can request @clawsweeper re-review if a fresh review does not trigger automatically. 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.

Label justifications:

  • P2: This is a bounded Control UI responsiveness improvement with meaningful but non-emergency user impact.
  • merge-risk: 🚨 session-state: The patch changes scheduling and stale-response guards for session-specific branches, discussion, companion, and pull-request state.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body reports a mocked-browser Testbox E2E result and focused tests, but the provided context contains no inspectable after-fix run of a real Control UI session switch. Please add redacted recording, terminal/live output, or runtime logs; after updating the PR body, a maintainer can request @clawsweeper re-review if a fresh review does not trigger automatically. 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:

  • Deferred hydration implementation: The PR adds a post-transcript scheduling path that checks request version, connection generation, client identity, and session key before starting secondary session hydration. (ui/src/pages/chat/chat-pane-session.ts:43, 03ea1bdc54d2)
  • Parallel startup metadata coverage: The PR adds tests asserting that chat metadata starts while the startup transcript request remains unresolved, plus fallback-ordering coverage. (ui/src/pages/chat/chat-send.test.ts:533, 03ea1bdc54d2)
  • Stale-response coverage: The PR adds a regression test for a previous session's pull-request response arriving after a newer session has become active. (ui/src/pages/chat/chat-pane-pull-requests.test.ts:10, 03ea1bdc54d2)
  • Contributor-reported validation: The PR body reports focused UI suites, a mocked-browser Testbox E2E check, lint, and an autoreview pass; no inspectable live after-fix session-switch artifact was included in the provided context. (03ea1bdc54d2)
  • Human-review signal: The PR carries the repository maintainer label, which requires explicit maintainer handling rather than automated cleanup.

Likely related people:

  • steipete: The visible branch history attributes the session-hydration implementation and its follow-up regression coverage to this contributor; current-main ownership could not be independently established from the available read-only inspection results. (role: recent hydration-path contributor; confidence: low; commits: ca2343667e8b, 49a9ee7dc6e9, 03ea1bdc54d2; files: ui/src/pages/chat/chat-pane-session.ts, ui/src/pages/chat/chat-state-refresh.ts, ui/src/pages/chat/chat-pane-session-hydration.test.ts)

Rank-up moves

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

  • Attach redacted real Control UI proof showing transcript-first rendering during a session switch.
  • Include a rapid-switch and same-client reconnect case in that proof after refreshing the branch against current main.

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.

@steipete
steipete merged commit e154330 into main Jul 27, 2026
124 of 128 checks passed
@steipete
steipete deleted the perf/ui-session-switch-waterfall branch July 27, 2026 05:43
@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 27, 2026
* perf(ui): parallelize session switch hydration

* test(ui): cover reconnect session hydration

* test(ui): give hydration request mocks real signatures
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: M 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.

1 participant