Skip to content

perf(agent-pane): defer mock fixtures and preload startup module - #33740

Merged
teamleaderleo merged 5 commits into
feat-cmux-nextfrom
lane/chat-page-startup
Nov 3, 2026
Merged

teamleaderleo merged 5 commits into
feat-cmux-nextfrom
lane/chat-page-startup

Conversation

@teamleaderleo

@teamleaderleo teamleaderleo commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Native chats eagerly loaded the mock daemon and synthetic debug transcripts. Load those modules only when a mock page or an existing async debug command needs them, reducing eager JavaScript by 76,592 bytes (1.59%). Preload the module before locale scripts and styles; evaluation still follows localization.

Leo: “things should be instant and not shift layouts AND not take many resources”. This reduces bytes on the open-to-page-painted path. It does not establish a startup timing improvement or meet the under-300 ms goal by itself.

Mock gallery/dev entries prepare the daemon before mounting, preserving the ready handshake's synchronous ordering. Native connection ordering stays unchanged. The localization scanner classifies the extracted debug-fixture barrel alongside the existing debug helpers. No timers, observers, loops, warm browser, or persistent idle activity are added. No new idle memory is reserved; runtime RSS was not measured for this bundle change.

Validation at final head e0ea71b8eaa2f7faacdee2419bb9309cc06350f0:

Performance against base 2a48ef76ce442a85d2c83af440b49d13726a87d3:

Metric Before After Delta Run link
Eager JavaScript bytes, entry plus static imports 4,821,604 4,745,012 −76,592 (−1.59%) Fleet 41643000975
Big chat page-painted, native observations 663.1 ms 1182.5 ms Not comparable: different workers/load Private report
Bloated chat page-painted, native observations 700.6 ms 1095.8 ms Not comparable: different workers/load Private report

Both native arms used scripts/measure/chat-open.sh --conditions=idle --cases=big,bloated --runs=3 --turns=10000; six opens completed per arm without timeout or flash. The after arm is intermediate head 23980936ffe3ecb3897670a2584d58462823812c, not the final head. Most timing difference occurred before navigation. These observations support no causal speedup or regression claim; the demonstrated improvement is fewer eager bytes.

Final red attribution:

  • Tier routing: PullRequestTiers.test_every_routed_input_triggers_the_workflow fails on the same four skills/cmux-customization paths in the completed exact-base job at 4575ff48a5502d89384180a933114a5a3eea4e90. Test, workflow, router and input blobs match the PR merge.
  • Focused gallery comparison 41655759891 hash-verifies the complete base 4575ff48 and merge 0a34ea94 trees. All 177 emitted CSS files are byte-identical (2,441,026 bytes). Five light/dark passes per arm reproduce both exact failures on base: new-tab#suggestions-chat-url, shift 0.0473 against 0.03673 while typing; and composer-context#started-browse-error, 5,000 ms alert timeout. Both also pass in other runs. These scenes execute unchanged preview/component branches, not the changed mock/debug branches.

Nonblocking follow-ups: #33792 (broader lazy-module sentinels), #33793 (isolate preload benefit), #33794 (mock-load diagnostic).

Agent session: agent session

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

cmux status (one comment, edited in place; each line is updated by the job that owns it)

Review e0ea71b: HQ feed card · gallery before/after runs · checks

App of this head (app.zip, kept 1 day)

gh workflow run reload-build.yml -R manaflow-ai/cmux --ref feat-cmux-next -f tag=pr33740 -f ref=lane/chat-page-startup -f platform=macos -f backend_mode=local

Gallery before/after for e0ea71b: 16 states rendered, 1 images differ, 3261 more touched states not rendered. Images are in the run's artifact, not on this public PR; the independent review of this head reads them on its own, so the PR needs no hand-made screenshots of these states.

gh run download 41649027458 -R manaflow-ai/cmux -n gallery-advisory-33740-e0ea71b8eaa2f7faacdee2419bb9309cc06350f0 (then read gallery-review.json)

States
State Theme Status Diff Picked by
agent-pane.chat-width/standard Apple System Colors Light unchanged 0% own App.tsx
agent-pane.chat-width/standard Apple System Colors unchanged 0% own App.tsx
agent-pane.chat-width/wide Apple System Colors Light unchanged 0% own App.tsx
agent-pane.chat-width/wide Apple System Colors unchanged 0% own App.tsx
agent-pane.chat-width/wide-blocks Apple System Colors Light unchanged 0% own App.tsx
agent-pane.chat-width/wide-blocks Apple System Colors unchanged 0% own App.tsx
agent-pane.composer-edge/short-edge Apple System Colors changed 0% own App.tsx
agent-pane.composer-edge/short-edge Apple System Colors Light unchanged 0% own App.tsx
agent-pane.composer-edge/wide-edge Apple System Colors Light unchanged 0% own App.tsx
agent-pane.composer-edge/wide-edge Apple System Colors unchanged 0% own App.tsx
agent-pane.composer-edge/no-edge Apple System Colors Light unchanged 0% own App.tsx
agent-pane.composer-edge/no-edge Apple System Colors unchanged 0% own App.tsx
agent-pane.composer-floats/scrolled-to-end Apple System Colors Light unchanged 0% own App.tsx
agent-pane.composer-floats/scrolled-to-end Apple System Colors unchanged 0% own App.tsx
agent-pane.composer-floats/composer-grown Apple System Colors Light unchanged 0% own App.tsx
agent-pane.composer-floats/composer-grown Apple System Colors unchanged 0% own App.tsx
agent-pane.composer-rest-gap/gap-40 Apple System Colors Light unchanged 0% own App.tsx
agent-pane.composer-rest-gap/gap-40 Apple System Colors unchanged 0% own App.tsx
agent-pane.composer-rest-gap/gap-56 Apple System Colors Light unchanged 0% own App.tsx
agent-pane.composer-rest-gap/gap-56 Apple System Colors unchanged 0% own App.tsx
agent-pane.composer-rest-gap/gap-72 Apple System Colors Light unchanged 0% own App.tsx
agent-pane.composer-rest-gap/gap-72 Apple System Colors unchanged 0% own App.tsx
agent-pane.continuation-spacing/shipped Apple System Colors Light unchanged 0% own App.tsx
agent-pane.continuation-spacing/shipped Apple System Colors unchanged 0% own App.tsx
agent-pane.continuation-spacing/two-thirds Apple System Colors Light unchanged 0% own App.tsx
agent-pane.continuation-spacing/two-thirds Apple System Colors unchanged 0% own App.tsx
agent-pane.continuation-spacing/half-tucked Apple System Colors Light unchanged 0% own App.tsx
agent-pane.continuation-spacing/half-tucked Apple System Colors unchanged 0% own App.tsx
agent-pane.continuation-spacing/before Apple System Colors Light unchanged 0% own App.tsx
agent-pane.continuation-spacing/before Apple System Colors unchanged 0% own App.tsx
agent-pane.copy-controls/output Apple System Colors Light unchanged 0% own App.tsx
agent-pane.copy-controls/output Apple System Colors unchanged 0% own App.tsx

Pick other states with a Gallery: entry.id, entry.id/variant line in the PR body.

Passes: CI passes on e0ea71b8ea.

CI passes on e0ea71b8ea (run 41649028843 attempt 1).

Written by scripts/ci/classify_failures.py (ci-failure-attribution.yml); signatures are its SIGNATURES table. A machine verdict is the runner's fault, not this PR's; yours means the failing file is one this PR changes, also red on main that main's latest full suite fails the same way, seen on other PRs that it failed on another pull request's run lately.

red: cmux-next checks (god files, concurrency, crash safety, l10n); no finished base run on 45a1cec to compare; do not merge until green; see lane-rules

Shipped in:

@github-actions github-actions Bot added the risk:normal Risk tier (docs/ci/risk-tiers.md) label Nov 3, 2026

@teamleaderleo teamleaderleo left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Review (claude-opus-5-5): SHIP at a52ec71

Review (subagent claude-opus-5-5 medium): SHIP at a52ec71

Scope: eb7026a..a52ec71.

  • The real connect path is unchanged: the await only happens for the mock transport, so native and bridge handshakes start in the same turn.
  • A failed mock import lands in connectHost's existing catch and retry. The new cancelled check stops a pane that was torn down from connecting.
  • The debug fixture APIs were already async.
  • The modulepreload uses the same URL and credentials mode as the module script, never runs it, and works in a production build.
  • The tests check real behaviour, including that the mock and fixture code are missing from the eager chunk graph.

Follow-ups:

  • [follow-up] The startup-bundle test only checks the mock transport and the shared fixture. Add a sentinel string for each of streamDebug, loadDebug, synthetic and the other lazy fixtures so none of them creeps back into the eager code.
  • [follow-up] The modulepreload has no before/after number; the preload scanner may already find pane.js early. Measure it, or drop it if it shows no gain.
  • [follow-up] A failed mock-chunk import shows as a generic handshake error and retries forever (dev/mock page only). Name the failure.

@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Review (codex, router-review): SHIP at a52ec71

Reviewer: codex gpt-6.1-sol xhigh, fast tier.

Follow-ups: 1. Each lands as an issue in this repo that links this receipt; the lane that opened the PR fixes it forward.

SHIP at a52ec71
Visual verdict: no images; Leo tries the build

No correctness bugs found. Source import-graph, TS/TSX parsing, and shell syntax checks passed; Bun tests and native measurements remain unverified.

  1. [P2] [follow-up] scripts/cmux-next/build-agent-pane-web.sh:110 — After screenshots are missing; capture the built pane to complete visual verification.

Follow-ups:

  • Capture and inspect startup screenshots for finding 1.

@blacksmith-sh

blacksmith-sh Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Found 10 test failures on Blacksmith runners:

Failures

Test View Logs
/tmp/tmp2codjjnl/summary-missing.json (live):/summary-missing.json (live): View Logs
/tmp/tmpgafj9qj4/summary-fail.json (live):/summary-fail.json (live): View Logs
[new_workspaces] debug.new_workspace timed 0 of 50 new workspace rows/
[new_workspaces] debug.new_workspace timed 0 of 50 new workspace rows
View Logs
[new_workspaces] the window draws no frames/[new_workspaces] the window draws no frames View Logs
[tabs] debug.tab_switch timed 0 of 40 switches/
[tabs] debug.tab_switch timed 0 of 40 switches
View Logs
[tabs] the window draws no frames/[tabs] the window draws no frames View Logs
test_every_routed_input_triggers_the_workflow (main.PullRequestTiers.test_every_rou
ted_input_triggers_the_workflow) (path='skills/cmux-customization/SKILL.md')
View Logs
test_every_routed_input_triggers_the_workflow (main.PullRequestTiers.test_every_rou
ted_input_triggers_the_workflow) (path='skills/cmux-customization/references/
examples.md')
View Logs
test_every_routed_input_triggers_the_workflow (main.PullRequestTiers.test_every_rou
ted_input_triggers_the_workflow) (path='skills/cmux-customization/references/
local-app-views.md')
View Logs
test_every_routed_input_triggers_the_workflow (main.PullRequestTiers.test_every_rou
ted_input_triggers_the_workflow) (path='skills/cmux-customization/references/
viewer-types.md')
View Logs

Fix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@teamleaderleo teamleaderleo left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Review (claude-opus-5-5): SHIP at 2398093

Review (claude-opus-5-5 medium): SHIP at 2398093

This carries Opus review 5751700375 from a52ec71. 2398093 is a rebase onto 2a48ef7 (with #33741). git diff eb7026a1..a52ec71d and git diff 2a48ef76..23980936 have the same stable patch-id (21c51e8e…), so the reviewed change is unchanged.

Follow-ups: same as 5751700375 (sentinels for the other lazy fixtures; measure or drop the modulepreload; name the error when the mock-chunk import fails).

@teamleaderleo teamleaderleo left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Review (claude-opus-5-5): SHIP at 521e355

Review (claude-opus-5-5 medium): SHIP at 521e355

This carries review 5751865046 from 2398093. Reviewed scope: 2398093..521e355, 7 lines in 2 files.

  • gallery/frame/agentPane.ts: awaits import(".../acpmux/mock") before mounting main only when state.ready.transport === "mock". That warms the same module App.tsx's connectHost later imports, so the fixture snapshot can't race a cold chunk. Preview-transport variants are unchanged.
  • acpmux/dev.tsx: awaits the mock import at top level, inside the existing ?mock-without-host branch only. dev.tsx is the dev server's entry, and build-agent-pane-web.sh only bundles it for sheet order (--css-inputs-only, esm, so top-level await is fine). The production pane entry and its eager graph don't change, and the import stays dynamic, so the mock code stays in a lazy chunk.

Follow-ups: same as 5751700375.

@teamleaderleo teamleaderleo left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Review (claude-opus-5-5): SHIP at 7adb04b

Review (claude-opus-5-5 medium): SHIP at 7adb04b

This carries review 5752396282 from 521e355. Reviewed scope: 521e355..7adb04b, dev.tsx only. The same mock pre-import moves from inside the else if branch to just before await import("./main"). Its condition (!devHost && ?mock && no agentSession handler) matches the old branch exactly, and it still runs before main loads, so the behaviour is the same. The gallery preload and the production entry are unchanged.

Follow-ups: same as 5751700375.

@teamleaderleo teamleaderleo left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Review (claude-opus-5-5): SHIP at 9f1ce1b

Review (claude-opus-5-5 medium): SHIP at 9f1ce1b

This carries review 5752474669 from 7adb04b. Reviewed scope: 7adb04b..9f1ce1b (4 files, +23/−4).

  • New mockTransport.ts: a module-level slot holding the mock module. It references ./mock only as a type (typeof import("./mock")), so nothing from the mock enters the eager graph. The +41 bytes is the getter.
  • dev.tsx and gallery/frame/agentPane.ts: after awaiting the mock import on the existing mock conditions, they fill the slot. dev.tsx keeps main's import first in source order, which preserves the stylesheet order derived from it.
  • App.tsx connectHost: in the mock branch it reads the prepared module synchronously, and falls back to the dynamic import. So the ready reply and the connect stay in one turn with no microtask yield, which is the actual cause of the mock layout regressions. Native and bridge paths never take the mock branch, so production is unchanged. A non-mock gallery variant after a mock one never reads the slot, because it's only read when mock is set.

The fleet run 41643000975 shows the four mock regressions before and the 10 cases within limits after.

Follow-ups: same as 5751700375.

@teamleaderleo teamleaderleo left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Review (claude-opus-5-5): SHIP at e0ea71b

Review (claude-opus-5-5 medium): SHIP at e0ea71b

Visual verdict: unchanged by this diff (test classifier only).

Carried from my SHIP at 9f1ce1b. The delta 9f1ce1b..e0ea71b is one line in webviews/test/pane-english.ts: it adds debugFixtures to SKIP beside debug. That clears the one red this PR introduced in webview run 41642551521 (pane-english flagged the new lazy debugFixtures.ts re-exporting the not-shipped fixtures). On base, debug.ts imported those fixtures directly and was already skipped. No production change. The remaining session-info-overlay-toggle reds are labelled base by the verdict job.

Follow-ups: none.

@teamleaderleo
teamleaderleo merged commit 97a5806 into feat-cmux-next Nov 3, 2026
230 of 235 checks passed
@teamleaderleo
teamleaderleo deleted the lane/chat-page-startup branch November 3, 2026 14:51
teamleaderleo added a commit that referenced this pull request Nov 3, 2026
The idle probe loads on demand like the other debug fixtures (#33740).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?id=aid-cb01117327fc358e9ba1

This branch was previously deployed

1 inactive deployment
ci-routing-agent — e0ea71b8 Deployed Nov 3, 2026 by teamleaderleo via cmux-tui tree preflight #106354
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:normal Risk tier (docs/ci/risk-tiers.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant