Skip to content

perf(ui): defer chat header menu contents - #180886

Merged
steipete merged 3 commits into
mainfrom
solid2/w-perf-chat-header
Oct 22, 2026
Merged

steipete merged 3 commits into
mainfrom
solid2/w-perf-chat-header

Conversation

@steipete

@steipete steipete commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Opening a Chat transcript currently downloads the session-menu builders, sharing panel, and their dependencies before either menu is opened.

User Impact

Chat boot downloads 21,346 fewer gzip bytes with the same 26 JavaScript requests. New Session also sheds 2,174 bytes, and startup remains unchanged within the 64-byte build variance. The existing header triggers, menus, selectors, keyboard behavior, and actions stay available.

Why This Change Was Made

Keep the native menu shell and trigger eager; load the session-menu content and desktop sharing body when opened. The shared empty session data now has a lightweight owner, and direct fact imports avoid bringing the sharing implementation back into boot through a facade. Nine Settings-only English strings also remain behind the Settings boundary.

This is a focused follow-up to the module attribution in #180852 (the top-30 tables for both boot graphs are in that PR). It does not claim the campaign's full 15% Chat / 10% New Session target. The route caps are ratcheted using the same relative headroom as before; startup is updated through the canonical baseline command.

Evidence

Same-machine production builds and strict performance comparison, using shipped gzip sidecars:

Surface Base Head Change
Startup JS 315,820 B / 7 requests 315,852 B / 7 requests +32 B, within 64 B variance
Startup CSS 41,124 B / 1 request 41,124 B / 1 request 0
Chat boot JS 1,443,067 B / 26 requests 1,421,721 B / 26 requests −21,346 B (−1.48%)
Chat boot CSS 148,481 B 146,899 B −1,582 B
New Session boot JS 1,018,405 B / 21 requests 1,016,231 B / 21 requests −2,174 B (−0.21%)

Cold-reload synthetic production-preview measurement, 10 interleaved before/after pairs: transcript median/p95 522.0 / 1397.6 ms → 530.5 / 1202.9 ms; composer 521.4 / 1397.0 ms → 529.8 / 1202.3 ms. Median +1.6%, p95 −13.9%, within the preregistered 20% nonregression rule. This is no speedup claim. The initial 10-pair dataset showed a +24.9% p95 regression during network waits/overlapping review; the controlled repeat removed that overlap. Both datasets are retained in the task evidence.

Timing uses Vite's production HTTP preview with synthetic bootstrap, WebSocket RPC, and media, not a live Gateway: 390 sessions (200 first page, 30 pinned), 34 owners, 120 people, 6 agents, 7 plugins, 120 cron jobs, 54 child sessions, 240 transcript messages and 12 inline widgets; cold HTTP cache, CPU throttle 1, simulated RPC latency 35 ms.

Check Result
UI typecheck Passed
Header session menu 25 tests passed
Sharing 16 tests passed
Cold header load 1 test passed; covers deferred import, trigger/focus retention, and pin action
Targeted lint/format and diff check Passed
Production Knip Passed
English catalog verification Passed
Independent review No actionable P0–P2 findings

The focused header test runs emitted Solid untracked-read diagnostics. The eager initial reads were subsequently removed; no diagnostic-free rerun is claimed. CI with ci:full supplies the broad UI, E2E, extension and real-Gateway proof.

The initial full run (39832022427) exposed supporting tests that treated the visible native menu shell as completed lazy content. They now wait for the actual rows; the shared unit helper waits for Vitest import settlement before its DOM deadline. Original row counts, placement, action, and focus assertions are preserved. The synthetic chunking fixture now explicitly groups its shared modules/styles independently of the production capture. Focused repair proof: 107/107 tests across five unit files; after helper refinement, 83/83 across its two consumers; 5/5 E2E tests across the two failed files. Typecheck and targeted lint pass.

That initial run also fails Control UI catalog publication with a real Gateway > opens Settings pickers from publication and acquires only on Refresh or Retry, matching scheduled-main run 39832966696. Its separate repair is #180899; it is distinct from the header readiness fixes.

All changed-file LOC: 17,569 → 17,934 (net +365, including tests, locale files and generated metadata). Header implementation production only: 5,657 → 5,937 (+280, excluding tests, locale relocation, generated manifest and tooling). The Settings-copy relocation adds no lines; the remaining growth is focused test/fixture coverage. Most churn moves existing menu bodies into their lazy modules.

The simplification pass retained the existing native Menu owner, removed facade imports that reintroduced eager dependencies, and found no further safe cut. The remaining production growth implements late focus handoff, loading/retry rendering, and retained item/action lookup across the lazy boundary. The one new cold-load test covers that boundary; existing tests only await the newly asynchronous entries. No domain owner, cache, or duplicate menu implementation was added.

Before / after

All captures use synthetic data. The first visible transcript/composer and the opened menus preserve their layout.

State Before After
Transcript Transcript before Transcript after
Session menu Session menu before Session menu after
Sharing menu Sharing menu before Sharing menu after

header-before-transcript

header-after-transcript

header-before-session-menu

header-after-session-menu

header-before-sharing-menu

header-after-sharing-menu

@steipete steipete added the ci:full Keep ordinary native-locale CI selection on the next PR run. label Oct 22, 2026
@clawsweeper

clawsweeper Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T19:05:25.322184Z b316449 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui scripts Repository scripts size: XL labels Oct 22, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9a713bdc5c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

"ui/src/pages/chat/components/chat-composer-slash-menu-dom.tsx",
"ui/src/pages/chat/components/chat-composer-slash-menu.tsx",
"ui/src/pages/chat/components/chat-effort-picker.tsx",
"ui/src/pages/chat/components/chat-lazy-boundary.tsx",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep chat-only code out of the shared boot graph

When loading /new, this regenerated shared capture now fetches chat-lazy-boundary.tsx, even though a repo-wide search shows every importer is under ui/src/pages/chat. This is part of a measurable New Session regression recorded in the same diff—from 1,000,561 B to 1,016,231 B gzip—so the chat-only additions should remain in the chat-exclusive chunk rather than being accepted by lowering the route budget.

AGENTS.md reference: ui/AGENTS.md:L76-L79

Useful? React with 👍 / 👎.

@steipete
steipete enabled auto-merge (squash) October 22, 2026 18:36
@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Oct 22, 2026
@steipete
steipete disabled auto-merge October 22, 2026 18:51
@clawsweeper

clawsweeper Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR loads chat header session and sharing menu bodies on first open and moves Settings-only English copy out of boot.

Example: Open Chat without opening either header menu.

  • Before: The reported production build downloads 1,443,067 gzip bytes of JavaScript.
  • After: The reported production build downloads 1,421,721 bytes, with menu bodies loaded when opened.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The measurements and inspected browser captures support the useful direction, but recovery and affected-consumer failures prevent readiness.
Proof confidence 🐚 platinum hermit (4/6) This maintainer-authored PR is outside the ordinary contributor proof gate; six inspected production-preview screenshots show the transcript and opened menus, while the body reports paired byte measurements and synthetic reload timings.
Patch quality 🦪 silver shellfish (2/6) 3 actionable review findings remain.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Opening Chat downloads optional header-menu implementations before the user opens those menus.
Reason: The maintainer-authored direction removes measured boot bytes while retaining existing controls and action owners.

Merge readiness

⛔ Needs changes before merge - 3 items remain

Keep this useful, maintainer-directed performance PR open; stale-chunk recovery and three failing UI check shards need focused repairs.

Priority: P2
Reviewed head: 9a713bdc5cccae0e1dede25406c7dac3fc89932c

Before merge

  • Recover stale menu chunks through the guarded reload owner (P2) - When a tab survives a Gateway update, first opening either deferred menu can request a removed hashed chunk. If automatic recovery cannot proceed, such as when session storage is unavailable, this Retry callback only resets rendering and leaves the failed module URL unchanged. The same defect exists in chat-session-sharing.solid.tsx:87-90. Detect isStaleChunkImportError, present the stale state, and call retryStaleChunkReloadWhenReachable with a current-menu check; retain reset for ordinary render errors, as the nearby mobile boundary does.
  • Await loaded entries in the remaining menu consumer tests (P2) - The shell now becomes visible before its optional entries load, but remaining consumers still treat visibility or fixed microtask settlement as content readiness. Pinned-head CI consequently fails mobile menu tests, pane-header quick actions, public-link copying, people search, and the lineage/render-storm E2E assertions. Update their existing helpers and assertions to await the specific loaded action or control before using it, preserving the behavior assertions and cold-load coverage.
  • Give the chunking fixture explicit stylesheet membership (P2) - This regenerated manifest removes sidebar-reorder.css from shared boot membership. The synthetic chunking test imports that stylesheet and select-picker.css but inherits production membership while asserting that both emit as one asset; CI now gets two stylesheets at control-ui-chunking.test.ts:156. Assign the fixture's shared modules and styles explicitly in its test configuration rather than restoring an obsolete production capture or weakening the assertion.

Findings

  • [P2] Recover stale menu chunks through the guarded reload owner — ui/src/pages/chat/components/chat-header-session-menu.tsx:183-186
  • [P2] Await loaded entries in the remaining menu consumer tests — ui/src/pages/chat/components/chat-pane-header.test-support.ts:87-91
  • [P2] Give the chunking fixture explicit stylesheet membership — ui/config/control-ui-boot-modules.json:1251-1252

Tests

  • Missing end-to-end proof: The supplied evidence does not show stale-import Retry recovery, a real-Gateway performance comparison, or the new cold-load regression failing on the base.
Agent review details

How this fits together

The Control UI header receives session facts and callbacks from existing pane owners; native Menu shells handle interaction while deferred components construct entries and forward actions to those owners.

flowchart LR
  A[Chat pane owner] --> B[Header menu shells]
  B --> C[Native Menu]
  C --> D[Lazy menu bodies]
  D --> E[Existing session actions]
  E --> F[Gateway]
Loading

Technical review

Best possible solution:

Keep the existing Menu shells and domain owners, add guarded stale-chunk recovery to both deferred bodies, and migrate affected tests to their new readiness boundaries.

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

Current-main static imports establish eager menu dependencies, and the new retry callbacks establish the stale-chunk recovery failure without executing target code.

Is this the best way to solve the issue?

Deferring the existing menu bodies is a focused solution that preserves ownership; reuse the established reload recovery operation instead of leaving Retry unable to recover removed assets.

Full review comments:

  • [P2] Recover stale menu chunks through the guarded reload owner — ui/src/pages/chat/components/chat-header-session-menu.tsx:183-186
    When a tab survives a Gateway update, first opening either deferred menu can request a removed hashed chunk. If automatic recovery cannot proceed, such as when session storage is unavailable, this Retry callback only resets rendering and leaves the failed module URL unchanged. The same defect exists in chat-session-sharing.solid.tsx:87-90. Detect isStaleChunkImportError, present the stale state, and call retryStaleChunkReloadWhenReachable with a current-menu check; retain reset for ordinary render errors, as the nearby mobile boundary does.
    Confidence: 0.98
  • [P2] Await loaded entries in the remaining menu consumer tests — ui/src/pages/chat/components/chat-pane-header.test-support.ts:87-91
    The shell now becomes visible before its optional entries load, but remaining consumers still treat visibility or fixed microtask settlement as content readiness. Pinned-head CI consequently fails mobile menu tests, pane-header quick actions, public-link copying, people search, and the lineage/render-storm E2E assertions. Update their existing helpers and assertions to await the specific loaded action or control before using it, preserving the behavior assertions and cold-load coverage.
    Confidence: 0.99
  • [P2] Give the chunking fixture explicit stylesheet membership — ui/config/control-ui-boot-modules.json:1251-1252
    This regenerated manifest removes sidebar-reorder.css from shared boot membership. The synthetic chunking test imports that stylesheet and select-picker.css but inherits production membership while asserting that both emit as one asset; CI now gets two stylesheets at control-ui-chunking.test.ts:156. Assign the fixture's shared modules and styles explicitly in its test configuration rather than restoring an obsolete production capture or weakening the assertion.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against ce9941f4db62.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test ui/src/pages/chat/components/chat-header-session-menu-loading.test.tsx ui/src/pages/chat/components/chat-header-session-menu.test.ts ui/src/pages/chat/components/chat-header-session-menu-mobile.test.tsx ui/src/pages/chat/components/chat-pane-header.test.tsx --maxWorkers=1
  • pnpm test ui/src/pages/chat/components/chat-session-sharing.test.tsx ui/src/pages/chat/chat-pane-sharing.test.ts ui/src/components/session-people-search.test.ts --maxWorkers=1
  • pnpm test ui/src/app/control-ui-chunking.test.ts ui/src/app/stale-chunk-reload.test.ts --maxWorkers=1
  • pnpm tsgo:ui
  • git diff --check

What I checked:

PR surface

Source +272, Tests +64, Other 0. Total +336 across 27 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 17 1416 1144 +272
Tests 8 90 26 +64
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 7 7 0
Total 27 1513 1177 +336

Labels

Label changes:

  • add P2: A measured boot-size improvement with limited menu recovery and test-integration defects; no urgent widespread runtime regression is established.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🐚 platinum hermit and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: A measured boot-size improvement with limited menu recovery and test-integration defects; no urgent widespread runtime regression is established.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🐚 platinum hermit and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 22, 2026, 2:56 PM ET / 18:56 UTC.

@steipete
steipete merged commit 0653000 into main Oct 22, 2026
112 of 114 checks passed
@steipete
steipete deleted the solid2/w-perf-chat-header branch October 22, 2026 19:23
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with prior CI and scoped validation.

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 ci:full Keep ordinary native-locale CI selection on the next PR run. clawsweeper:intake:feature Preliminary submission classification; full source review pending. scripts Repository scripts size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant