Skip to content

improve(ui): make session switching and transcript rendering faster - #129834

Merged
steipete merged 1 commit into
mainfrom
codex/control-ui-live-performance-20260825
Aug 26, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/control-ui-live-performance-20260825

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Session switching, sidebar interaction, and transcript rendering perform repeated work that grows unnecessarily with the session roster and message history. Collapsing the sidebar also rewrites persisted settings even though visibility is deliberately local to the current UI instance.

Why This Change Was Made

Index session lineage by the existing canonical session-identity contract instead of repeatedly scanning every known key; preserve main-session aliases and case-sensitive Matrix/Signal identifiers. Keep split-layout reads immutable without cloning their entire column, avoid irrelevant connected-title/outbox and roster projections, persist navigation settings only when an actually persisted preference changes, and build transcript/reply rows in their existing owner passes. Ordinary Markdown now skips block-art and disclosure processing when its required glyph/tag cannot possibly be present. Narration and sidebar categories are filtered/deduplicated before sorting.

Production code: +89/-96 (net -7 lines). Regression tests: +59/-3.

User Impact

Sessions open and switch more responsively, particularly with larger rosters or long streaming transcripts. Sidebar collapse no longer serializes and rewrites unrelated stored preferences. Existing navigation aliases, offline queued counts, Markdown details/block art, split-pane ownership, and reply navigation remain unchanged.

Evidence

Tested against a real isolated, loopback-only development Gateway serving the production-built Control UI, with 60 actual Gateway-backed sessions; Chromium alternated between the same session rows 18 times and discarded the first two warmup samples.

Live browser measurement Before After Change
Median session switch 88.9 ms 79.1 ms 11.0% faster
p95 session switch 141.6 ms 105.7 ms 25.4% faster
Median browser CPU per switch 41.55 ms 33.02 ms 20.5% less
p95 browser CPU per switch 98.96 ms 39.83 ms 59.8% less

Isolated owner microbenchmarks show why the same changes scale beyond the 60-session browser fixture: canonical lineage collection improves from 85.22 ms to 0.27 ms at 600 sessions, ordinary Markdown block-art classification from 45.46 ms to 0.28 ms across 12,000 calls, and ordinary streaming-tail repair from 312.46 ms to 3.71 ms across 300 calls. These are component measurements, not claims about end-to-end latency.

Both newly fixed ownership violations were reproduced with failing tests before the implementation: connected document-title rendering must not summarize stored outboxes, and visibility-only navigation changes must not publish persisted-settings changes. Focused owner/sibling validation: 315 passing tests. Chromium end-to-end validation: 30 passing tests across session stability, retained-pane hydration, sidebar toggling/presentation, and streaming runtime budgets. Production UI build also passes its startup-size and request-count gates.

Before (synthetic fixture data only):

Control UI session switching before optimization

After (synthetic fixture data only):

Control UI session switching after optimization

Real development Gateway session-switching recording:

control-ui-live-session-switching.webm

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: M maintainer Maintainer-authored PR labels Aug 26, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: 🎥 video Contributor real behavior proof includes video or recording evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 25, 2026, 11:47 PM ET / August 26, 2026, 03:47 UTC.

ClawSweeper review

What this changes

This PR optimizes Control UI session switching, sidebar updates, and transcript rendering while avoiding persistence writes for sidebar-only visibility changes.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open: the new lineage index is discarded before lookup, so alias and case-variant session routes still scan the full roster instead of using the intended fast path.

Priority: P3
Reviewed head: 0e2188de05379345dc4f599269ec86498d82cb8b

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The supplied real-Gateway evidence is strong, but the canonical-index defect leaves a material portion of the claimed optimization unimplemented.
Proof confidence 🦞 diamond lobster (5/6) Not applicable: The contributor-proof gate is not applicable to this maintainer-authored PR; its body nevertheless includes a real isolated Gateway and Chromium recording with before/after measurements.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The contributor-proof gate is not applicable to this maintainer-authored PR; its body nevertheless includes a real isolated Gateway and Chromium recording with before/after measurements.
Evidence reviewed 4 items Canonical index is discarded: The PR deduplicates with normalized keys, then reconstructs the returned map with raw row keys; the direct lookup therefore cannot use the canonical index for aliases.
Alias path still scans: The added main-alias case calls lineage loading with agent:main:main after the authoritative root row is main; raw-key lookup misses before the existing value scan resolves it.
Current main still needs this work: Current main uses an equivalence scan while collecting known rows and another scan for every lineage lookup, so the PR is not redundant.
Findings 1 actionable finding [P2] Preserve canonical keys for lineage lookup
Security None None.

Live Verification

Command: pnpm test:ui:e2e

Result: FAIL (failed) — step 1 run pnpm test:ui:e2e: previous terminal command was still running after 30 seconds: "pnpm test:ui:e2e"

$ node --import tsx scripts/ensure-playwright-chromium.mts && node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts --configLoader runner
[ui-e2e] Using system Chromium at /usr/bin/chromium-browser.
Downloading FFmpeg (playwright ffmpeg v1011) from https://cdn.playwright.dev/dbazure/download/playwright/builds/ffmpeg/1011/ffmpeg-linux.zip
2.3 MiB [====================] 100% 0.0s
FFmpeg (playwright ffmpeg v1011) downloaded to /tmp/clawsweeper-live-proof-129834-oylXaI/profile/cache/ms-playwright/ffmpeg-1011

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-129834-oylXaI/target

Assertions:

  • FAIL expect_output: Test Files

How this fits together

The Control UI receives Gateway session state and projects it into sidebar navigation and chat panes. Session keys identify lineage rows, which are then rendered with transcript and split-layout state in the browser.

flowchart LR
  A[Gateway session roster] --> B[Lineage row collection]
  B --> C[Session key lookup]
  C --> D[Sidebar navigation]
  E[Transcript events] --> F[Transcript projection]
  F --> G[Chat panes]
  D --> H[Control UI rendering]
  G --> H
Loading

Before merge

  • Preserve canonical keys for lineage lookup (P2) - collectKnownSessionRows deduplicates with a normalized key but rebuilds the returned map under raw keys. The direct knownRows.get(currentKey) therefore misses aliases such as the added main/agent:main:main case and falls back to scanning every row, leaving the claimed lineage optimization ineffective for those routes. Retain canonical keys and normalize reads/inserts.
  • Resolve merge risk (P1) - For main-session aliases and case-equivalent routing keys, the merged UI would retain roster-wide lineage scans, leaving the central session-switching performance goal incomplete.

Findings

  • [P2] Preserve canonical keys for lineage lookup — ui/src/components/app-sidebar-child-session-data.ts:24
Agent review details

Security

None.

PR surface

Source -7, Tests +56. Total +49 across 15 files.

View PR surface stats
Area Files Added Removed Net
Source 12 89 96 -7
Tests 3 59 3 +56
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 15 148 99 +49

Review metrics

Metric Value Why it matters
Production versus test LOC production +89/-96 (net -7); tests +59/-3 The performance refactor is net-negative in production while adding focused regression coverage.

Stored data model

Persistent data-model change detected: serialized state: ui/src/app/bootstrap.nav-visibility.test.ts, serialized state: ui/src/lib/sessions/session-key.ts, serialized state: ui/src/pages/chat/chat-page.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Preserve the canonical lineage index (recommended)
    Keep normalized map keys and normalize direct reads and inserts so aliases do not fall back to roster scans.

Technical review

Best possible solution:

Keep normalized keys through collection and normalize direct lookups and described-row inserts, then prove alias routes take the indexed path without changing session identity semantics.

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

Yes, from source: the added main-alias scenario reaches a raw-key map miss and then the existing full-map equivalence scan. The checkout is read-only, so this review did not execute the focused test.

Is this the best way to solve the issue?

No. The optimization must preserve canonical keys at both collection and lookup; rebuilding the map with raw keys defeats the intended fast path for aliases.

Full review comments:

  • [P2] Preserve canonical keys for lineage lookup — ui/src/components/app-sidebar-child-session-data.ts:24
    collectKnownSessionRows deduplicates with a normalized key but rebuilds the returned map under raw keys. The direct knownRows.get(currentKey) therefore misses aliases such as the added main/agent:main:main case and falls back to scanning every row, leaving the claimed lineage optimization ineffective for those routes. Retain canonical keys and normalize reads/inserts.
    Confidence: 0.95

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a targeted Control UI responsiveness improvement rather than an availability, security, or message-delivery regression.
  • add merge-risk: 🚨 other: The canonical-index defect can leave the intended large-roster performance gain absent for alias-based session routes.
  • add proof: 🎥 video: Contributor real behavior proof includes video or recording evidence. The contributor-proof gate is not applicable to this maintainer-authored PR; its body nevertheless includes a real isolated Gateway and Chromium recording with before/after measurements.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The contributor-proof gate is not applicable to this maintainer-authored PR; its body nevertheless includes a real isolated Gateway and Chromium recording with before/after measurements.

Label justifications:

  • P3: This is a targeted Control UI responsiveness improvement rather than an availability, security, or message-delivery regression.
  • merge-risk: 🚨 other: The canonical-index defect can leave the intended large-roster performance gain absent for alias-based session routes.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The contributor-proof gate is not applicable to this maintainer-authored PR; its body nevertheless includes a real isolated Gateway and Chromium recording with before/after measurements.
  • proof: 🎥 video: Contributor real behavior proof includes video or recording evidence. The contributor-proof gate is not applicable to this maintainer-authored PR; its body nevertheless includes a real isolated Gateway and Chromium recording with before/after measurements.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main blame for the lineage collector and the proposed optimization both attribute this owner boundary to Peter Steinberger. (role: current implementation author and recent area contributor; confidence: high; commits: 4048b57b7d25, 0e2188de0537; files: ui/src/components/app-sidebar-child-session-data.ts, ui/src/lib/sessions/session-key.ts)

Rank-up moves

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

  • Retain canonical lineage keys and normalize alias reads and inserts.
  • Rerun the supplied Gateway-backed session-switch scenario after the alias fast path is covered.

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 215de48 into main Aug 26, 2026
129 checks passed
@steipete
steipete deleted the codex/control-ui-live-performance-20260825 branch August 26, 2026 04:23
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: 🎥 video Contributor real behavior proof includes video or recording evidence. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M 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.

1 participant