Repository navigation
perf(ui): flip sessions instantly and drop redundant switch RPCs - #115129
Conversation
1fa2118 to
5fbd629
Compare
|
Codex review: needs real behavior proof before merge. Reviewed July 28, 2026, 6:09 AM ET / 10:09 UTC. ClawSweeper reviewWhat this changesThis 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 readinessKeep 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 Priority: P2 Review scores
Verification
How this fits togetherThe 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]
Decision needed
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
Agent review detailsSecurityNone. PR surfaceSource +551, Tests +503. Total +1054 across 24 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Mantis proof suggestionA 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: Merge-risk optionsMaintainer options:
Technical reviewBest 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. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…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)
What Problem This Solves
Clicking a sidebar session in the Control UI did nothing visible until a full-store
sessions.listRPC resolved: the route loader re-derived the session key the sidebar already had (short-id resolution viaquerySessionReference→sessions.list{search:<8hex>,...}), while the router kept the old session rendered. The switch then fired redundant RPCs — a forcedsessions.listthat only feeds an outbox-flush no-op when the queue is empty, per-switchchat.metadata+agent.identity.getrefetching 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
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).sessions.listskipped when the chat outbox is empty; still issued when non-empty (spy tests both ways).chat.metadata/agent.identity.getmemoized per (client, agentId), invalidated on config change + reconnect, built on the existingchatMetadataRequestVersionownership token; cross-agent-switch catalog-clear behavior from perf(ui): trust startup metadata and damp catalog polling #114837 preserved.git diff --check; autoreview clean. One pre-existing lightbox threshold flake reproduced on clean main and passed in the final sweep.