Skip to content

perf(ui): avoid speculative history reads on connect - #167906

Merged
steipete merged 1 commit into
mainfrom
steipete/perf-micro-control-ui-connect-fanout-20260919
Oct 9, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/perf-micro-control-ui-connect-fanout-20260919

Conversation

@steipete

@steipete steipete commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Opening a conversation automatically warmed two unopened histories; the sidebar, composer apps, and resource picker also issued overlapping discovery requests for the same session.

User Impact

Connecting no longer reads unopened conversations. Hovering or keyboard-focusing another conversation still warms it after visible history is ready. Concurrent UI surfaces share MCP discovery while keeping their own presentation state.

Why This Change Was Made

The navigation prefetch owner now serves explicit intent, removing automatic recent-session warming, browser-idle scheduling, sorting, and multi-candidate selection. Pending MCP discovery is shared by connection scope and target. Config events, explicit retries, and successful session creation invalidate pending work; settled results leave the registry. Existing history limits and lazy older-page behavior are preserved. Production delta: −62 lines.

Evidence

Headless Chromium against a built Control UI and real isolated Gateway, with 900 synthetic messages in the selected conversation, 900 in Home, and three unopened 150-message conversations. The fixture configures no live provider; “Models unavailable” is intentional. Before/after captures used the same AWS Crabbox lease, cbx_42d0efd1de6c.

Cold connect metric Before After
RPC response bytes 442,309 313,853 (−29.0%)
RPC count 52 48
History reads (selected + unopened) 3 1
Unopened-history requests / bytes 2 / 128,238 0 / 0
Selected-history reply bytes / messages 262,964 / 59 262,964 / 59
MCP discovery calls 4 2
HTTP request count 59 59
Measured inbound HTTP + WebSocket bytes 2,233,377 2,104,944 (−5.8%)
Conversation and composer visible 2,445 ms 1,826 ms
Draft edit completed 2,476 ms 1,857 ms
Observed aborted HTTP requests 0 0

These are paired samples, not a latency distribution. The repeat on Blacksmith also reduced RPC bytes by 29%, while its timing was approximately flat. Each capture continues for three seconds after a draft edit. All HTTP requests are counted; byte totals exclude two fixture error responses (session-entry 401 and missing workspace-icon 404) whose sizes Chromium did not report. No fetch/abort churn was reproduced.

The served entry changed from index-8m44svMD.js to index-C9xNAMYp.js. Both versions loaded the same initial 59 messages and reached all 900 through eight older-page commits. Older-page rendering was 2,556 → 2,439 ms. The flow also verifies restored Home ordering, narrow layouts, identity reconciliation, and avatar caching.

Validation:

  • Two owner regressions fail against unchanged production: unsolicited warming and duplicate discovery. A third regression fails on the coalescer without post-creation invalidation, then passes with the fix.
  • AWS cbx_42d0efd1de6c: 55 focused tests across four prefetch/MCP files passed with --maxWorkers=1 in 3.76s. Both rebuilt real-Gateway runs passed; final Vitest wall time was 63.40s, including the temporary measurement instrumentation. The committed E2E test adds no case or timer; it records all RPCs in its existing report.
  • AWS cbx_42d0efd1de6c: node scripts/check-changed.mjs --staged passed, including all nine selected core-test graphs, UI typechecking, i18n, dead exports, core lint, UI style lint, and other selected guards. Source hashes and the eight staged paths were verified before execution.
  • Blacksmith Testbox tbx_01m4grcjmv4p1crvemc2k5avtb (lease workflow): 313 history/pagination/prefetch/MCP sibling tests passed during development. Its later lease ended at its one-hour limit during a gate, so final validation moved to AWS; the interrupted gate is not counted as passing.
  • Hosted CI passed for af123d11e45c. Full UI shard wall times were 339s / 329s / 248s; the UI E2E job took 163s and the Control UI performance job 115s.
  • Fresh independent Codex review: scoped clean through P2. Both leases stopped after collecting proof.
Remote command details

All heavy commands ran remotely through the installed Crabbox CLI, one at a time per lease. No local test suites, builds, or typechecks ran.

node scripts/run-vitest.mjs run --config ui/vitest.config.ts --configLoader runner \
  ui/src/pages/chat/session-prefetch ui/src/components/mcp-app-catalog.test.ts \
  ui/src/components/mcp-app-resources.test.ts --maxWorkers=1
pnpm ui:build
node scripts/run-vitest.mjs run --config test/vitest/vitest.ui-e2e.config.ts \
  --configLoader runner ui/src/e2e/chat-loading-performance.real-gateway.e2e.test.ts
node scripts/check-changed.mjs --staged

The gate's initial development failure was one shadowed callback name, now fixed. An early browser attempt reused the old bundle; explicit UI builds and served asset hashes corrected that before measurement. Raw Testbox sync does not copy the local index, so gates explicitly stage the hash-verified candidate paths.

Before: synthetic cold connect

After: synthetic cold connect with intent-only prefetch

Warm unopened conversations only after pointer or keyboard navigation intent.
Share pending MCP discovery across surfaces, invalidating reads on config
changes, explicit retries, and session creation while keeping view ownership.

Synthetic cold connect: 52 to 48 RPCs and 29% fewer RPC response bytes.
Preserve existing history budgets and lossless lazy pagination.
@clawsweeper

clawsweeper Bot commented Oct 9, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui size: L labels Oct 9, 2026
@steipete
steipete marked this pull request as ready for review October 9, 2026 18:18
@steipete
steipete enabled auto-merge (squash) October 9, 2026 18:22
@clawsweeper

clawsweeper Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The Control UI warms unopened conversations only after hover or keyboard focus and shares pending Model Context Protocol (MCP) app-discovery requests across UI surfaces.

Example: A user opens the synthetic 900-message conversation.

  • Before: Cold connect reads two unopened histories and transfers 442,309 bytes in RPC responses.
  • After: Cold connect reads no unopened histories and transfers 313,853 bytes in RPC responses.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, net-smaller implementation with real browser/Gateway before-and-after evidence and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied paired Chromium captures exercise the rebuilt Control UI against an isolated real Gateway, showing prefetch history reads fall from three to one and MCP discovery calls from four to two while initial history and all 900 paginated messages remain intact; inspected screenshots corroborate the rendered conversation.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes
User problem: Opening a conversation transfers unopened histories and repeats app discovery while the selected conversation is loading.
Reason: The paired runs establish avoidable traffic, and the change reduces production code. Prior merged area work establishes the author's ownership context for replacing automatic warming with explicit intent.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main still performs the redundant work, the direction is supported by prior area ownership, and no actionable introduced defect was found.

Priority: P2
Reviewed head: af123d11e45c9d8147ccb3ef2e26adae4f9e7d92

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Control UI requests conversation history and available plugin apps from the Gateway. Its prefetch and discovery controllers prepare data for navigation, the composer, and the resource picker.

flowchart TD
  A[Connect or navigate] --> B[Selected conversation history]
  C[Hover or keyboard focus] --> D[Visible transcript ready]
  D --> E[Intended conversation prefetch]
  F[Sidebar composer and resource picker] --> G[Shared pending app discovery]
  E --> H[Gateway responses and scoped UI caches]
  G --> H
Loading

Technical review

Best possible solution:

Keep intent-driven warming and pending discovery sharing in their existing controllers.

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

Not applicable as a correctness-bug reproduction; the supplied paired Chromium runs demonstrate the performance problem through the built UI and a real isolated Gateway.

Is this the best way to solve the issue?

Yes. Removing speculative selection at the existing prefetch owner and sharing only pending discovery avoids another cache or policy owner while preserving foreground loading and pagination.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit e906068 adds ui/src/lib/mcp-app-catalog.ts:130 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e9060685284b; files: ui/src/lib/mcp-app-catalog.ts)

PR surface

Source -62, Tests +166, Docs +4. Total +108 across 8 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 82 144 -62
Tests 4 342 176 +166
Docs 2 5 1 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 429 321 +108

Review metrics

Metric Value Why it matters
Production versus tests production −62 LOC; tests +166 LOC Production becomes smaller while added coverage protects request sharing and retained lifecycle behavior.

Labels

Label changes:

  • add P2: The measured improvement reduces cold-connect traffic without addressing an urgent availability or delivery failure.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: The measured improvement reduces cold-connect traffic without addressing an urgent availability or delivery failure.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

Reviewed October 9, 2026, 2:24 PM ET / 18:24 UTC.

@steipete
steipete merged commit b0fb3ac into main Oct 9, 2026
133 of 134 checks passed
@steipete
steipete deleted the steipete/perf-micro-control-ui-connect-fanout-20260919 branch October 9, 2026 18:27
steipete added a commit that referenced this pull request Oct 9, 2026
Follow the intent-only prefetch contract from b0fb3ac (#167906):
hover or focus the unopened session before expecting its warm history read.
Preserve foreground-load gating, roster-refresh cache reuse, and mixed-history
recovery assertions without changing production behavior or timeouts.

The three failures reproduce on current main and pass at the producer parent.
All eight cases pass with the fixture update; removing only the navigation
intent reproduces all three failures. P2 review is clean.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 10, 2026
Warm unopened conversations only after pointer or keyboard navigation intent.
Share pending MCP discovery across surfaces, invalidating reads on config
changes, explicit retries, and session creation while keeping view ownership.

Synthetic cold connect: 52 to 48 RPCs and 29% fewer RPC response bytes.
Preserve existing history budgets and lossless lazy pagination.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 10, 2026
Follow the intent-only prefetch contract from 75e0819 (openclaw#167906):
hover or focus the unopened session before expecting its warm history read.
Preserve foreground-load gating, roster-refresh cache reuse, and mixed-history
recovery assertions without changing production behavior or timeouts.

The three failures reproduce on current main and pass at the producer parent.
All eight cases pass with the fixture update; removing only the navigation
intent reproduces all three failures. P2 review is clean.
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 docs Improvements or additions to documentation size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant