Skip to content

perf(ui): flip sessions instantly and drop redundant switch RPCs - #115129

Merged
steipete merged 4 commits into
mainfrom
perf/switch-client-waterfall
Jul 28, 2026
Merged

steipete merged 4 commits into
mainfrom
perf/switch-client-waterfall

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Clicking a sidebar session in the Control UI did nothing visible until a full-store sessions.list RPC resolved: the route loader re-derived the session key the sidebar already had (short-id resolution via querySessionReference → sessions.list{search:<8hex>,...}), while the router kept the old session rendered. The switch then fired redundant RPCs — a forced sessions.list that only feeds an outbox-flush no-op when the queue is empty, per-switch chat.metadata + agent.identity.get refetching identical bytes for same-agent switches, serial unsubscribe→subscribe (2×RTT), and an avatar clear followed by two serial HTTP fetches (blank flash on every switch).

Why This Change Was Made

The sidebar has the full session key at click time; blocking navigation on an RPC that re-derives it is pure waterfall. The remaining per-switch RPCs refetch agent-scoped facts that only change on config reload or reconnect.

User Impact

Sidebar clicks flip the pane immediately (cached transcript or skeleton seeded from the sidebar row's title/preview/status) instead of waiting on a list roundtrip; same-agent switches stop refetching metadata/identity/avatars, so no avatar blank-flash; subscription handoff overlaps instead of serializing.

Evidence

  • A1/D1: committed sidebar selection carries the full key via an internal query hint plus a one-shot, pathname-bound handoff for the canonical clean-URL reload; kind:"short" also gets the cached-row shortcut under the safe uuid+slugHint unique-match conditions. Cold/typed short URLs keep the authoritative RPC and ambiguity semantics (regression-tested, chooser behavior preserved).
  • A2: forced sessions.list skipped when the chat outbox is empty; still issued when non-empty (spy tests both ways).
  • A3: chat.metadata/agent.identity.get memoized per (client, agentId), invalidated on config change + reconnect, built on the existing chatMetadataRequestVersion ownership token; cross-agent-switch catalog-clear behavior from perf(ui): trust startup metadata and damp catalog polling #114837 preserved.
  • A4: unsubscribe/subscribe fire concurrently; the existing generation guard handles reordering (overlap ordering test).
  • A5/D3: bounded per-agent avatar cache; no clear-before-fetch when the cached avatar matches the agent; meta+blob fetches collapsed where possible.
  • D2: pane header/skeleton seeded from the already-looked-up sidebar row.
  • Validation: full UI e2e sweep 83/83 files, 339/339 tests; focused route/avatar/subscription/sidebar suites; UI prod+test typechecks, oxlint, oxfmt, git diff --check; autoreview clean. One pre-existing lightbox threshold flake reproduced on clean main and passed in the final sweep.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: XL maintainer Maintainer-authored PR labels Jul 28, 2026
@steipete
steipete marked this pull request as ready for review July 28, 2026 09:53
@steipete
steipete force-pushed the perf/switch-client-waterfall branch from 1fa2118 to 5fbd629 Compare July 28, 2026 09:57
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jul 28, 2026
@clawsweeper

clawsweeper Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 28, 2026, 6:09 AM ET / 10:09 UTC.

ClawSweeper review

What this changes

This PR makes Control UI sidebar session switches render from the selected row immediately while avoiding repeated same-agent metadata, identity, avatar, and subscription work.

Merge readiness

⚠️ Ready for maintainer review - 5 items remain

Keep this PR open for explicit maintainer review. It is a large, targeted Control UI performance change with tests described in the PR, but it changes session-route identity and live-subscription lifecycle behavior, and the maintainer label requires human handling rather than automated cleanup.

Priority: P2
Reviewed head: 0748004a0ab99be741d7b06c519fd9db21c36164
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The branch has focused and broad UI validation described, but its large coordinated lifecycle scope still needs maintainer review before a merge-quality rating can improve.
Proof confidence 🌊 off-meta tidepool Not applicable: The PR is labeled as maintainer-authored and the supplied checks include a successful real-behavior-proof gate; the external-contributor proof requirement does not apply.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The PR is labeled as maintainer-authored and the supplied checks include a successful real-behavior-proof gate; the external-contributor proof requirement does not apply.
Evidence reviewed 4 items PR scope and route handoff: The branch adds a short-lived navigation handoff and a query hint so a sidebar-selected full session key can bypass a redundant short-route lookup, while preserving the normal resolver for cold or ambiguous routes.
Subscription lifecycle surface: The branch changes selected-session message synchronization to overlap the next subscription with release of the previous one and retains failed releases for later retry.
Adjacent merged provenance: The PR explicitly preserves the startup-metadata behavior from the earlier merged Control UI performance change, whose merge commit is recorded as 9dddddb.
Findings None None.
Security None None.

How this fits together

The Control UI sidebar chooses a session and navigates the chat pane to that route. The route loader resolves the selected session, then the pane restores visible chat state, subscribes to live messages, and refreshes agent-scoped presentation data.

flowchart LR
  Sidebar[Sidebar session row] --> Navigation[Route navigation]
  Navigation --> Loader[Session route loader]
  Loader --> Pane[Chat pane]
  Pane --> History[Cached history and projection]
  Pane --> Live[Live message subscription]
  Pane --> AgentData[Metadata identity and avatar caches]
Loading

Decision needed

Question Recommendation
Should this large session-switch optimization land as one change after focused review of stale-route and overlapping-subscription behavior, or should those lifecycle changes be split into narrower follow-up PRs? Review and land as one change: Keep the coordinated performance work together after confirming route cleanup, subscription generation ordering, and completed UI checks.

Why: The protected maintainer label and the cross-cutting session-state changes require owner judgment about acceptable lifecycle complexity; source context alone does not establish that product and maintenance tradeoff.

Before merge

  • Add real behavior proof - Not applicable: The PR is labeled as maintainer-authored and the supplied checks include a successful real-behavior-proof gate; the external-contributor proof requirement does not apply.
  • Resolve merge risk (P1) - The full-key handoff changes how existing short chat routes are resolved during in-app navigation; maintainers should confirm it cannot retain or select stale session identity across rapid route changes.
  • Resolve merge risk (P1) - Overlapping unsubscribe and subscribe operations reduce latency but make the correctness of generation guards and retry cleanup merge-critical for live message delivery.
  • Complete next step (P2) - The protected maintainer label and cross-cutting session lifecycle behavior require focused human review rather than an automated repair or close path.
Agent review details

Security

None.

PR surface

Source +551, Tests +503. Total +1054 across 24 files.

View PR surface stats
Area Files Added Removed Net
Source 17 759 208 +551
Tests 7 528 25 +503
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 24 1287 233 +1054

Review metrics

None.

Stored data model

Persistent data-model change detected: persistent cache schema: ui/src/app/assistant-identity.ts, persistent cache schema: ui/src/pages/chat/chat-state-refresh.ts, persistent cache schema: ui/src/pages/chat/route-loader.ts, serialized state: ui/src/lib/sessions/navigation-handoff.ts, serialized state: ui/src/lib/sessions/route-navigation.ts, serialized state: ui/src/test-helpers/app-sidebar-cases/sessions.ts, and 2 more. Confirm migration or upgrade compatibility proof before merge.

Mantis proof suggestion

A web UI chat recording can directly show the claimed immediate pane transition while the list request is delayed. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis web UI chat proof: reproduce a sidebar session switch with a delayed session-list response and capture the pane changing immediately.

Merge-risk options

Maintainer options:

  1. Complete focused lifecycle review (recommended)
    Confirm the handoff is consumed only for the intended pathname and that retrying old subscription releases cannot preserve duplicate listeners before merge.
  2. Accept the coordinated optimization
    Accept the added route and subscription lifecycle complexity if maintainers judge the immediate-switch latency benefit worth the rollback surface.
  3. Split the subscription overlap
    Pause the PR and separate concurrent subscription handoff if the route and cache improvements are desirable but the release-retry lifecycle is too broad to approve together.

Technical review

Best possible solution:

Retain the bounded client-side optimization, but land it only after a maintainer confirms the route-handoff contract and overlapping subscription cleanup against the current main branch and completed UI checks.

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

No live reproduction was performed in this read-only review. The reported wait is source-reproducible from the route-resolution path described in the PR, and the branch adds focused route and browser-level coverage for it.

Is this the best way to solve the issue?

Unclear: carrying the selected full key and caching agent-scoped facts are plausible bounded fixes, but the combined route-handoff and concurrent-subscription lifecycle needs maintainer comparison with current main before it can be called the best solution.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This is a substantial but non-emergency improvement to ordinary Control UI session switching.
  • add merge-risk: 🚨 compatibility: The branch changes the in-app route-resolution handoff for existing short-form session URLs.
  • add merge-risk: 🚨 session-state: The branch changes selected-session projection and the order in which live-message subscriptions are released and acquired.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The PR is labeled as maintainer-authored and the supplied checks include a successful real-behavior-proof gate; the external-contributor proof requirement does not apply.

Label justifications:

  • P2: This is a substantial but non-emergency improvement to ordinary Control UI session switching.
  • merge-risk: 🚨 compatibility: The branch changes the in-app route-resolution handoff for existing short-form session URLs.
  • merge-risk: 🚨 session-state: The branch changes selected-session projection and the order in which live-message subscriptions are released and acquired.
  • 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 PR is labeled as maintainer-authored and the supplied checks include a successful real-behavior-proof gate; the external-contributor proof requirement does not apply.

Evidence

What I checked:

  • PR scope and route handoff: The branch adds a short-lived navigation handoff and a query hint so a sidebar-selected full session key can bypass a redundant short-route lookup, while preserving the normal resolver for cold or ambiguous routes. (ui/src/pages/chat/route-loader-short-cache.ts:1, 0748004a0ab9)
  • Subscription lifecycle surface: The branch changes selected-session message synchronization to overlap the next subscription with release of the previous one and retains failed releases for later retry. (ui/src/pages/chat/chat-history.ts:603, 0748004a0ab9)
  • Adjacent merged provenance: The PR explicitly preserves the startup-metadata behavior from the earlier merged Control UI performance change, whose merge commit is recorded as 9dddddb. (ui/src/pages/chat/chat-state-refresh.ts:50, 9dddddb94061)
  • Discussion and validation evidence: The PR body describes focused route, avatar, subscription, and sidebar coverage plus a full UI E2E sweep; the supplied check state also shows the dedicated real-behavior-proof check completed successfully, while broader UI checks were still running at review time. (0748004a0ab9)

Likely related people:

  • steipete: Steipete authored the adjacent merged session-open performance work and this PR extends the same Control UI metadata and session-switch area. (role: recent area contributor; confidence: medium; commits: 9dddddb94061, 0748004a0ab9; files: ui/src/pages/chat/chat-state-refresh.ts, ui/src/pages/chat/route-loader.ts, ui/src/pages/chat/chat-history.ts)

Rank-up moves

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

  • Confirm completed UI checks on the current head.
  • Review rapid route switching and failed-unsubscribe cleanup against the current-main lifecycle contract.

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 7f37900 into main Jul 28, 2026
102 of 108 checks passed
@steipete
steipete deleted the perf/switch-client-waterfall branch July 28, 2026 10:25
@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 29, 2026
…nclaw#115129)

* perf(ui): flip sessions instantly and drop redundant switch RPCs

* chore: revert changelog edit (release generation owns CHANGELOG.md)

* test(ui): adapt ported switch e2e tests to split-suite helpers

* chore(ui): un-export internal CachedShortSession type (knip)
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: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL 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.

1 participant