Skip to content

improve: reduce chat CPU work during reconnects - #184386

Merged
steipete merged 26 commits into
mainfrom
solid2/w-perf-reconnect-final
Oct 26, 2026
Merged

steipete merged 26 commits into
mainfrom
solid2/w-perf-reconnect-final

Conversation

@steipete

@steipete steipete commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Coordinator acceptance (October 26): The landing hold is lifted. The remote one-pane brief-drop repeat has wall p95 482.3 → 473.5 ms. The historical 664 ms task did not reproduce in 240 new observations; at least 446.907 ms was outside renderer-thread CPU. The coordinator accepts that historical task as a host/scheduling residual. Full CI on the repaired head must pass before native landing.

Round 2 status — coordinator accepted

Current head: ba9b3cf9420, merged with main 0261812512a after the cached composer-control presentation change (#184383) caused a real conflict. The one-line transcript readiness correction is committed, and the main test-fixture conflict was resolved by merging main. Direct-route Codex review of the integrated candidate is scoped-clean at P0–P2. A later one-line publication-test correction also received a fresh scoped-clean review.

Twenty untraced base/control/head triplets repeated the exact immutable production bundles for the remote one-pane brief drop, with 1,000 sessions/models, 500 automations and 100 ms RPC/HTTP delays. All 60 passed:

Metric Base median / p95 A/A median / p95 Head median / p95 Head change
Fully-live wall ms 462.70 / 482.30 465.85 / 478.70 465.90 / 473.50 +0.69% / −1.82%
Script CPU ms 148.61 / 160.36 147.68 / 154.61 143.58 / 152.05 −3.39% / −5.18%
Task CPU ms 213.28 / 229.08 213.68 / 223.28 210.12 / 216.47 −1.48% / −5.51%

No Long Tasks entry occurred in that untraced cohort. A separate 60-sample one-pane trace cohort also passed, with no task above 47 ms. A third, mixed one-/ten-pane trace cohort passed 120/120; its timings are diagnostic, never pooled with untraced acceptance. One-pane wall median/p95: base 464.85/490.90, control 470.55/506.50, head 460.70/500.70 ms. Its head script median improved 6.98%, but script p95 increased 10.59%; this is disclosed, not called a uniformly clean timing win.

The historical 664 ms task was predominantly off-CPU: the complete interval contains only 217.093 ms of renderer task CPU, so at least 446.907 ms was outside renderer-thread execution. Its synchronous stall falls between users.list and sessions.describe, the same stage as the original A/A outlier. No trace exists for that original sample, so this does not distinguish descheduling from a native wait or establish an exact source owner. The historical 59% wall-p95 result remains disclosed. It did not reproduce in 240 new observations, and the coordinator accepted the off-CPU share and non-reproduction as sufficient evidence of a host/scheduling residual; it is no longer a landing blocker.

All 120 mixed profiles were source-mapped (309,211 frames mapped, 1,018 unmapped). Largest native tasks, wall/thread CPU: one pane base 47.288/46.848 ms, control 43.874/43.258 ms, head 58.856/50.798 ms; ten panes base 121.927/121.109 ms, control 126.779/122.981 ms, head 140.906/137.626 ms. Details geometry is the dominant mapped owner for the ten-pane tasks. Screenshots show wide stacked panes with Details open/docked, so a closed-only optimization would miss this cost. The requested architectural follow-up is prepared around the existing layout read/write scheduler but has not been implemented, honoring the coordinator's after-landing ordering.

Full CI 40343803289 failed one named test: session pull request chips > drops a deferred publication result after switching to another publishing session. The latest completed scheduled main 40337335014 passed the matching UI shard; this is not treated as inherited. Publication admission moves the inline action into the branch menu, which may close during the click handoff. The test now reopens the menu before checking B's pending action, matching the neighboring test's existing contract. Both stale-A and disabled-B assertions remain. The corrected single test passed (1 passed, 9 unselected, 18.55 s); Node was used because this is Playwright E2E. One initial artifact-mode invocation selected no files and is not counted as proof. The new push requests full CI again.

Integrated-head check Result
UI typecheck Pass
Transcript readiness file 14/14 pass
Model-control file 4/4 pass
Corrected publication test 1/1 selected pass
Scoped format/lint Pass
Strict startup check 270,991 → 270,872 B gzip (−119 B), 5 JS / 1 CSS requests unchanged
Strict chat assets 1,237,877 → 1,238,363 B gzip (+486 B), 20 JS / 3 CSS requests unchanged; no budget change
Production Knip Both baseline and head exit 1 with byte-identical pre-existing findings; no ignores

The initial build/review comparison used pinned ancestor 9ce791ad051. A fresh exact merge-base build at 35bcb70f487 now confirms the same asset values with strict checks (no warnings/violations). Production head bytes are from 8104b632ba8, unchanged by the E2E-only cf3e11fec1f correction. The earlier review included the intervening main delta. Production UI LOC: 3,860 → 4,041 (+181). All 22 changed files: 11,275 → 12,889 (+1,614), mostly the benchmark/proof harness. No production code changed in the two round-2 test corrections. No active Testbox lease; the queued request was cancelled before any payload ran.

Round 3 CI repair

Run 40348263473 completed with two failed test names. Both corresponding jobs passed on latest completed scheduled main 40337335014; neither is classified inherited.

  • handleSendChat > retires a failed queued picker back to the preceding confirmed session row timed out on the one-second wait for its first patch to start. The test now awaits the admitted request event itself, preserving the held first request, second-request rejection, ordering and rollback assertions. The full file passes 108/108; corrected scoped lint, formatting, UI typecheck and independent P0–P2 review pass.
  • Daybreak through a real built Gateway > persists visible selections and refreshes queued requests on desktop and mobile received daybreak_blue while waiting for standard in the held-response case. The exact case passed unchanged with a fresh isolated runtime and matching UI build (1 selected pass, 2 unselected, 107.65 s Vitest). The failure did not reproduce; no production repair or inherited-failure claim is made. The new full CI run is required.

Commit de14ed6200e changed only the test wait. Main subsequently supplied the canonical repair in #184744, moving the regression into chat-settings-patches.test.ts and waiting for dispatch. Merge a19952a9ae6 keeps that owner test and removes this branch’s duplicate; the moved test passes (1/1). No new production change was authored in the merge. The pushed merge resolves GitHub’s conflict, which had prevented CI from attaching to de14.

Current integrated asset proof (exact base 91fa755ffd6 vs head a19952a9ae6): startup 271,105 → 271,341 B gzip (+236 B), chat 1,237,917 → 1,238,637 B (+720 B). Startup 5 JS / 1 CSS and chat 20 JS / 3 CSS requests are unchanged; strict checks pass without warnings or budget changes. Canonical production Knip exits 1 on both with byte-identical 105-byte output: one unused deferSqliteWorkerNativeCommitReceipt export in the unchanged SQLite owner. Full CI 40355643358 on a19952a9ae6 exposed the sharing test failure below. Current LOC: production 3,860 → 4,041 (+181), all 23 changed files 11,982 → 13,597 (+1,615).

What Problem This Solves

Chat model controls repeat large catalog and selection derivations when reconnect and history updates replace otherwise unchanged session data.

User Impact

Reduces renderer CPU during heavier reconnects and when reopening the model picker. In the large-catalog workload (1,000 sessions, 1,000 models, 500 automations and ten panes), reconnect script CPU medians improve 8.19–16.39% across brief drops, simulated sleep and same-build restarts on localhost and 100 ms RTT.

This is a CPU improvement, not a uniform latency improvement. The original pooled one-pane 100 ms brief-drop wall p95 worsened from 602.2 to 958.5 ms; the 20-triplet repeat improved 482.3 to 473.5 ms. The coordinator accepted the historical off-CPU outlier and non-reproduction as the residual described above. Neither the −40% recovery target nor the 100 ms maximum-task goal was reached.

Why This Change Was Made

Keep prepared model catalogs, selection facts, Fast-mode derivation and saved-model presentation stable across unrelated chat frames. Prepare searchable facts for hidden model rows and read shared search props once per catalog. Context-window controls independently read the current session/default owner, so retaining model choices cannot freeze them.

The existing Gateway/session owners retain request admission, ordering, offline queue and write authority. No production effect, listener, cache owner, dependency or configuration option is added. The type-only module is erased; the presentation helper moves the existing catalog index.

Evidence

The committed scripts/bench-control-ui-reconnect.ts runs four scenarios × two network profiles × one/ten panes with 1,000 sessions, 1,000 models and 500 automations. Each cell uses 20 serial, alternating-order base/control/head triplets: 960/960 behavior samples passed. Local load-1 median/range was 54.01 / 20.95–91.44; 100 ms profile was 39.50 / 20.56–69.83. A queued Testbox probe was cancelled before receiving a host; all measurements ran on the same Mac.

Acceptance uses the campaign's noisy-host rule: A/A control plus renderer thread CPU and work counts, with raw timings retained. Independent review found no demonstrated systematic attributable CPU regression. Small mixed cells remain disclosed: local one-pane update script p95 +5.53% (46.637→49.217 ms, A/A 48.267 ms), median −0.37%, task p95 +0.25%; remote update script medians +2.95%/+3.12% for one/ten panes.

The remote one-pane brief-drop wall p95 is +59.80%; A/A is only +4.18%, so the control does not explain that severe tail. Its longest overlapping task is 664 ms. The full 664 ms task is post-restoration: it starts 121.3 ms after the first retained reconnect RPC, around initial-history delivery. A second 480 ms outlier starts 117.5 ms after that RPC. All six base/control/head samples in those pairs have identical request counts and 248,592 delivered bytes. The 664 ms sample has script/total thread CPU 152.785/217.093 ms versus paired base 150.628/218.940 ms; the 480 ms sample has lower CPU than its base. No tail stack trace or per-task CPU breakdown was captured. Interval CPU does not explain or dismiss the wall-time regression, and the changed derivation can run during history hydration. That original cohort did not establish a scheduling cause; the later non-reproduction and off-CPU evidence above is the basis of the accepted residual. A predeclared ten-triplet extension for remote one-pane brief-drop passed 30/30 behavior samples. The primary pooled 30-triplet result retains every original sample: wall median 478.95→468.95 ms (−2.09%), p95 602.2→958.5 ms (+59.17%), A/A p95 +3.77%; script CPU median −5.26%, p95 −5.99%; task CPU median −4.47%, p95 −7.62%; request/byte medians and p95 unchanged. One original head sample (pair 6, the wall-p95 sample) starts an extra undelivered sessions.list request: 35 starts versus 34, while both deliver 31 replies / 248,592 bytes. An extension A/A sample finishes with less background work (34 starts, 29 deliveries / 198,862 bytes and two session rows); every readiness witness still passes. These exceptions prevent a per-sample identical-work claim. The extension alone observed no ≥50 ms task and wall p95 602.2→466.5 ms, but it does not erase the original tails. The earlier CPU-only acceptance was withdrawn for round-2 investigation. Following 240 new observations, the coordinator lifted that hold and accepted the historical off-CPU stall as a host/scheduling residual. The original timing and counter evidence remains retained; no exact source attribution is claimed. A separate instrumented triplet passed 3/3 behavior checks and is excluded from timing statistics. It reproduced no ≥50 ms task (largest task: base 46.781 ms, A/A 42.935 ms, head 25.252 ms); source mapping covered over 99% of sampled frames. This cannot explain the original tails. Reconnect maximum is 118 ms locally and 664 ms at 100 ms RTT; update-reload maximum is 200/448 ms. The local one-pane reload p95 is +21.77% (A/A +24.99%); remote ten-pane reload p95 is +8.94% (A/A +68.16%).

Retained-picker correctness passed 6/6 additional samples across both network profiles: the same menu node reopened after sleep, with zero session patches or message sends. A separate first-open coverage diagnostic passed 2/2 behavior checks: full model-row presentation and context metadata calls 1,043→43; reactive own-key enumeration 1,001→1, descriptor reads 28,033→33 and readonly getters 31,784→3,782. Search rows remain 1,000 and store getters 118,906. Instrumented durations are not timing evidence.

Focused proof: 60 model-selection/preference/picker tests passed; UI and script typechecks, scoped lint/format, production build and strict asset checks passed. The complete canonical production Knip scan exits 1 on both clean base 766fae46a165 and final head de52f76248d, with byte-identical output (1,272 bytes): 12 unused-export rows and four unused-exported-type rows. The earlier files/dependencies-only scan was not full-export proof; this comparison supersedes it. No new finding; those baseline findings remain unresolved by this focused change. Source and diagnostic reviews have no remaining actionable P0–P2 findings. The first ci:full run completed with formatter and test-type failures. Those two issues are repaired: the exact core UI test-type leaf and scoped formatter check pass, and independent P0–P2 review is clean. Replacement ci:full run 40294410215 exposed three additional failures. The final branch incorporates main's wait-clock repair (#184457) and canonical selected-Gateway runtime preparation (#184458). Those owners supersede the proposed local clock and three-file test-routing changes; none of those four changes remain in this PR. The only retained CI repair explicitly settles the sidebar's cold Pages import while preserving all existing DOM assertions and the one-second polling budget. Its independent P0–P2 review is clean; the intermittent timeout was not reproduced deterministically, and the available CI summary does not identify which sidebar assertion timed out.

The exact sidebar case, UI typecheck, production build and strict base/head asset check pass on final head de52f76248d. The original core UI test-type leaf proof is retained. Full PR CI 40314404359, tested as synthetic merge c92e19ee224a into main 02e6a799b59a, finished with two failures under investigation: a live transcript activity assertion and the real-Gateway queued program-selection clearing assertion. Neither is classified as inherited; the transcript case passed exact-base replay and the latest completed scheduled main run. The real-Gateway fixture changed on newer main. Its complete three-case sequence now passes on the exact synthetic CI merge after canonical matching runtime/UI preparation (375.11 s wrapper wall time; 342.09 s Vitest duration), including desktop/mobile queued clearing. The original failure remains unresolved; no selection-owner fix or inherited-failure claim is made. A separate bounded diagnostic reproduced the transcript assertion by holding its real lazy renderer after positioning settled. A one-line readiness correction passes all 14 tests (40.97 s), format and lint, and was subsequently committed with clean independent review. These initial failures are not classified as inherited. Passing files in the failed run include transport/auth, history admission/recovery, outbox/queue ownership, offline send/Stop, queue reorder/update, offline attachment recovery, split-pane reconnect, and real-Gateway catalog reconnect ordering; the failed shards are not reported green.

Asset surface Base Head Change
Startup JavaScript gzip 270,780 B 271,087 B +307 B
Startup JS / CSS requests 5 / 1 5 / 1 unchanged
Chat JavaScript gzip 1,233,456 B 1,234,132 B +676 B
Chat JS / CSS requests 20 / 3 20 / 3 unchanged

Sizes above compare fresh clean main 766fae46a165 with final head de52f76248d on the same machine. Both strict checks pass without warnings or violations. The +307 B startup delta accompanies the measured 8.19–16.39% ten-pane reconnect CPU win and stays within the existing 271,650 B baseline plus its 512 B allowance; no budget was changed. Startup raw bytes are identical. Timings retain their separately pinned original base/head provenance below. Production LOC across twelve touched modules: 3,860→4,041 (+181). All touched text, including benchmark/tests and the one-line sidebar CI repair, against integrated main 766fae46a165: 9,809→11,420 (+1,611). Solid census: memos 30→37, signals 2→2, onSettled 2→2; effects, listeners, DOM queries, flush and owner APIs remain zero in the touched production files.

The exact sharing failure was chat session sharing menu > reads people only on opening and retains the latest member rows across reopening: the popover was open but its lazy access row had not arrived inside the one-second assertion window. The corresponding job passed on the latest completed scheduled main run 40347483110, so this is not classified as inherited. The test now awaits Vitest’s dynamic-import settlement after the real opening click, then runs every original assertion. No production code, timeout, or assertion changed. The unchanged named replay passed in 418 ms, so the CI import delay itself was not independently reproduced. The corrected file passed 18/18 tests in 1.89 s; a fresh independent direct-route Codex P0–P2 review is scoped-clean. Native auto retirement was confirmed before the replacement push. Full CI 40361302770 on 19e21df2628 completed green: 46 jobs passed, 23 skipped, no failures.

The green-head native recovery stopped before dispatch because #184383 had just landed on main. The reviewed merge keeps main’s cached effort/speed display and the reconnect catalog memoization: saved thinking data now belongs to the existing saved-model memo, and the saved speed display overlays the resolved fast-mode state outside the expensive catalog selection memo. Main’s restoration assertions and the reconnect no-recompute assertion all pass (4/4). Independent direct-route P0–P2 review of the complete candidate against 0261812512a is scoped-clean; UI typecheck, scoped lint/format and both builds pass. Current strict base/head assets: startup 271,130 → 271,341 B (+211 B), Chat 1,238,764 → 1,238,637 B (−127 B), New Session 751,535 → 752,022 B (+487 B). Requests are unchanged and no budget changed. Production UI LOC 3,880 → 4,055 (+175); all 23 files 12,059 → 13,668 (+1,609). Production Knip passes on both current base and merged head. Full CI 40369680033 passed on ba9b3cf9420: 46 successful jobs, 23 skipped, zero failures (observed 18:12 UTC). No inherited-failure exception is used.

The coupled cached-control merge also passed a fresh 20-triplet remote one-pane brief-drop check: 60/60 observations, unchanged live-history/sidebar/presence/send-readiness assertions. Base/A/A/head wall median: 496.85/497.75/483.65 ms; p95: 512.00/508.40/498.00 ms. Script CPU median: 160.95/164.31/148.97 ms (head −7.44%); p95: 173.06/172.20/158.61 ms (−8.35%). Task CPU median fell 242.08 → 226.13 ms (−6.59%). No Long Tasks entry occurred. Host load ranged 26.46–49.69 (median 35.44); A/A wall median/p95 changed +0.18%/−0.70%. Inspected first-pair screenshots contain only synthetic data and show the reconciled history, current sidebar, preserved draft, and enabled send control.

Complete reconnect timing and CPU tables

Values are median / p95. Update rows measure the update prompt; their Reload columns separately measure clicking Refresh through the new document becoming live. Cross-document CPU is not measured. Human decision time is excluded.

Scenario RTT Panes Pairs Wall median / p95 (ms) Script CPU median / p95 (ms) Script Δ A/A script Δ Reload median / p95 (ms) Head max task / reload task (ms)
brief-drop 0 1 20 201.40 → 199.75 / 221.90 → 235.30 146.79 → 144.68 / 163.31 → 170.38 -1.44% +5.23% — / — 64.00 / —
brief-drop 0 10 20 1409.35 → 1279.85 / 1474.80 → 1400.30 1083.29 → 987.94 / 1145.87 → 1082.81 -8.80% +2.09% — / — 115.00 / —
long-sleep 0 1 20 206.75 → 199.55 / 238.90 → 214.70 153.79 → 143.82 / 174.24 → 156.34 -6.48% -2.64% — / — 0.00 / —
long-sleep 0 10 20 1429.65 → 1344.00 / 1558.30 → 1422.90 1116.37 → 1024.89 / 1223.04 → 1088.71 -8.19% -0.37% — / — 118.00 / —
restart 0 1 20 1075.60 → 1055.25 / 1111.70 → 1125.70 174.78 → 155.03 / 188.16 → 167.11 -11.30% -1.39% — / — 0.00 / —
restart 0 10 20 2187.10 → 2026.80 / 2296.10 → 2145.70 1160.10 → 997.26 / 1235.12 → 1078.82 -14.04% +1.16% — / — 107.00 / —
update 0 1 20 1311.30 → 1122.30 / 1348.80 → 1321.70 43.47 → 43.31 / 46.64 → 49.22 -0.37% -0.47% 467.40 → 463.10 / 739.60 → 900.60 0.00 / 189.00
update 0 10 20 860.45 → 863.70 / 1366.20 → 1403.50 111.62 → 107.40 / 117.45 → 112.74 -3.78% -0.45% 1548.80 → 1475.35 / 1710.20 → 1695.50 66.00 / 200.00
Scenario RTT Panes Pairs Wall median / p95 (ms) Script CPU median / p95 (ms) Script Δ A/A script Δ Reload median / p95 (ms) Head max task / reload task (ms)
brief-drop 100 1 20 484.95 → 476.40 / 599.80 → 958.50 155.61 → 151.25 / 170.58 → 160.37 -2.80% -0.12% — / — 664.00 / —
brief-drop 100 10 20 1588.65 → 1489.95 / 1807.10 → 1576.10 1059.22 → 959.49 / 1218.94 → 1020.53 -9.42% -1.65% — / — 135.00 / —
long-sleep 100 1 20 479.95 → 469.75 / 491.50 → 483.70 157.46 → 149.87 / 168.14 → 156.18 -4.82% +1.26% — / — 0.00 / —
long-sleep 100 10 20 1570.30 → 1468.70 / 1709.00 → 1553.40 1068.64 → 960.38 / 1168.62 → 1038.02 -10.13% +2.31% — / — 165.00 / —
restart 100 1 20 1336.25 → 1304.70 / 1395.00 → 1396.10 170.48 → 159.87 / 181.67 → 166.32 -6.23% +0.74% — / — 0.00 / —
restart 100 10 20 2361.70 → 2178.40 / 2474.80 → 2320.70 1159.77 → 969.64 / 1217.27 → 1025.77 -16.39% -1.69% — / — 161.00 / —
update 100 1 20 1320.90 → 1312.40 / 1821.60 → 1823.90 43.23 → 44.50 / 45.89 → 47.78 +2.95% +0.20% 1099.90 → 1091.35 / 1157.00 → 1141.80 159.00 / 225.00
update 100 10 20 1347.35 → 1355.70 / 1879.60 → 1875.30 108.77 → 112.16 / 137.37 → 139.16 +3.12% +0.85% 1788.60 → 1753.05 / 1888.70 → 2057.60 350.00 / 448.00

This uses the built production renderer, real browser transport client/reconnect owners, and a synthetic Gateway fixture. It does not measure a real Gateway, TCP establishment, provider latency or actual OS sleep. Sleep advances wall-clock state by 30 minutes and transitions visibility/transport; timers and performance clocks remain native. HTTP and RPC fixed delay are both 100 ms in the remote profile; bandwidth and packet loss are not modeled. Every live endpoint verifies editable composers, retained draft, refreshed history in every pane, changed presence and newly admitted sidebar membership. No chat send is issued.

Reproduction, using separately built immutable base/head directories:

NODE_DISABLE_COMPILE_CACHE=1 node --import ./scripts/tsx.mjs \
  scripts/bench-control-ui-reconnect.ts \
  --bundle-dir <base-bundle> --compare-bundle-dir <head-bundle> \
  --rtt 0 --asset-latency-ms 0 --pairs 20 --thread-cpu-time \
  --aa-control --update-reload --first-pair-screenshots --output <new-output>

Repeat with --rtt 100 --asset-latency-ms 100. Base: a8771d6f51f53a30a25ca58d26c29b6854dcea10; production head: 0cc1803ba2d12830ec740dcfefa2dca85f1a5d39; final diagnostics: c69e067192cd2c5c3bdca68a8c0f9defe452c16e; formatter/test-type repair: deb2a573293d156c3c74a1efc3dbe7316d70ed57 (no runtime production change).

Work counts and warm-picker measurements

Work is bounded by restoration-to-readiness, not the full lifetime of background traffic. Counts do not uniformly improve: all 26 local increased metric rows are below. The remote profile adds only an in-flight p95 change at ten-pane restart (3→4, matching A/A). These measurements do not establish why traffic shifted across the interval boundary. The separate automation-inventory lifetime defect identified during tracing is not changed by this PR.

Scenario RTT Panes Metric with increase Base med/p95 Head med/p95 Control med/p95
brief-drop 0 1 method.cron.list 5/7 6/12 5/7
brief-drop 0 1 responseBytes 277520/306975 291928/379015 277840/306975
brief-drop 0 1 rpcDelivered 35/38 36/43 35.5/38
brief-drop 0 1 rpcStarted 37/39 38/44 37/39
brief-drop 0 10 method.cron.list 23/26 23.5/26 23.5/25
brief-drop 0 10 responseBytes 2.14101e+06/2.18488e+06 2.14821e+06/2.18488e+06 2.14821e+06/2.16983e+06
brief-drop 0 10 rpcDelivered 171/175 171.5/175 171.5/173
brief-drop 0 10 rpcStarted 173/176 173.5/176 173.5/175
long-sleep 0 1 method.cron.list 5/7 6/8 5/8
long-sleep 0 1 responseBytes 277520/306975 291928/321383 277520/320744
long-sleep 0 1 rpcDelivered 35/38 36/39 35/38
long-sleep 0 1 rpcStarted 37/39 38/40 37/40
long-sleep 0 10 method.cron.list 24/25 24/28 23.5/26
long-sleep 0 10 responseBytes 2.15542e+06/2.17047e+06 2.15542e+06/2.21369e+06 2.14853e+06/2.18488e+06
long-sleep 0 10 rpcDelivered 172/174 172/177 172/175
long-sleep 0 10 rpcStarted 174/175 174/178 173.5/176
restart 0 1 method.cron.list 5/6 5.5/7 5/7
restart 0 1 responseBytes 277906/292315 285110/306723 277910/321134
restart 0 1 rpcDelivered 35/36 35.5/37 35/38
restart 0 1 rpcStarted 36/37 36.5/38 36/38
restart 0 10 method.cron.list 13.5/16 14/14 13/19
restart 0 10 responseBytes 2.00477e+06/2.0408e+06 2.01198e+06/2.01198e+06 1.99757e+06/2.08403e+06
restart 0 10 rpcDelivered 161.5/164 162/162 161/167
restart 0 10 rpcStarted 163.5/166 164/164 163/169
update 0 10 updateReload.responseBytes 2.04707e+06/2.04707e+06 2.04707e+06/2.06148e+06 2.04707e+06/2.06148e+06
update 0 10 updateReload.rpcCounts 139/139 139/142 139/141

The matching 20-triplet mobile first-open comparison passed 60/60 checks: task CPU 120.97→110.00 ms (−9.07%), p95 131.92→120.73 ms (−8.48%); script median −0.94%, p95 −2.16%. Raw wall/focus p95 worsened +92.75%/+46.14%; original A/A wall p95 +19.73%. Later native-input diagnostics do not retroactively explain those early tails. No general first-open latency claim.

Desktop reopen, 20 triplets and 60/60 checks: script CPU 48.45→38.00 ms (−21.57%), p95 −23.07%; task CPU 89.96→79.66 ms (−11.45%), p95 −11.31%. A/A wall timing is noisy, so no wall-time claim.

Inspected synthetic screenshots show the preserved rendering. Before and after the sleep case are byte-identical:

Before: live chat after simulated sleep
After: live chat after simulated sleep

The mobile model picker before/after is also unchanged:

Before: mobile model picker
After: mobile model picker

Keep current mutation guards while retaining model choices across unrelated frame updates. Preserve in-place session facts and locale invalidation. Add a reproducible reconnect matrix with separate update prompt and reload intervals.
Derive the selected model summary without expanding every option family. Let the retained picker panel request the full options on first open while preserving Default, runtime and context-budget semantics.
Compare the model, runtime, speed and availability fields before rescanning the catalog. Keep locale invalidation and live outer mutation guards. Narrow helper input types to the facts it reads.
Reject lazy option expansion after 20 interleaved mobile first-open pairs increased script CPU by 8.5 percent with a flat control. Keep the narrower selection and Fast-mode derivations and stable saved-model snapshot; restore the original picker API and eager option preparation.
@steipete steipete added the ci:full Keep ordinary native-locale CI selection on the next PR run. label Oct 26, 2026
@clawsweeper

clawsweeper Bot commented Oct 26, 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 26, 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-26T17:36:51.716879Z ba9b3cf 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 26, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Oct 26, 2026
@clawsweeper

clawsweeper Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR retains model-control derivations across unrelated chat updates and adds reconnect and picker performance diagnostics.

Example: Reconnect a ten-pane chat with 1,000 sessions and 100 ms simulated RTT after a same-build restart.

  • Before: Reported median renderer script CPU is 1,159.77 ms.
  • After: Reported median renderer script CPU is 969.64 ms, a 16.39% reduction.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful production-renderer evidence and coherent derivation changes support the CPU improvement, while unexplained latency tails and unclassified failing checks limit merge confidence.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied evidence exercises built production controls and browser reconnect owners against a synthetic Gateway across brief drops, simulated sleep, restart, update reload, and retained-picker reopening; reported outcomes preserve drafts, refreshed history, sidebar membership, and zero unintended sends, with inspected matching screenshots. This establishes renderer behavior and bounded CPU claims, not real Gateway, provider, TCP, or operating-system sleep performance.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Large chat layouts spend unnecessary renderer CPU rebuilding unchanged model-control presentation during reconnects and picker interactions.
Reason: The maintainer-approved direction has measured CPU value and preserves existing controls; missing aspirational speed targets does not negate the narrower improvement.

Merge readiness

⛔ Blocked before merge - 2 items remain

This PR provides a useful, maintainer-directed CPU optimization with no definite functional defect found; performance acceptance and failed CI still need resolution.

Priority: P2
Reviewed head: c69e067192cd2c5c3bdca68a8c0f9defe452c16e
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should the CPU savings ship despite the unexplained reconnect and mobile first-open latency tails exceeding the documented acceptance threshold?
  • Recommendation: Resolve the tail attribution: Hold the optimization until the affected measurements establish whether the change causes the tails, repairing or narrowing it if necessary.
  • Why: The maintainer-authored PR approves the optimization direction, but its body leaves these severe tails unresolved and does not explicitly accept their user impact.

Before merge

  • Resolve merge risk - Before merge, the feature owner must resolve or explicitly accept the unexplained reconnect and mobile first-open latency tails that exceed the documented 20% stop threshold.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

None.

Agent review details

How this fits together

Control UI model controls consume catalog, session, runtime, and permission facts to render model and effort choices; existing session and Gateway owners continue to admit mutations.

flowchart LR
  A[Gateway catalog and session owners] --> B[Chat presentation props]
  B --> C[Retained model derivations]
  B --> D[Live mutation guards]
  C --> E[Model and effort controls]
  D --> E
  E --> F[Existing session mutation owner]
Loading

Technical review

Best possible solution:

Keep the existing component-owned derivations and ship the measured CPU savings after settling latency acceptance and attributing the failed CI checks.

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

Fetched main derives selection and speed from broadly changing presentation frames; the supplied production-renderer comparisons demonstrate avoidable work, although I did not execute a current-main reproduction.

Is this the best way to solve the issue?

Narrow equality boundaries within the existing controls address the measured waste while preserving live policy and mutation guards; the smallest complete fix needs no new authoritative state or configuration.

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Resolve the affected latency tails (recommended)
    The PR author establishes attribution for remote one-pane reconnect and mobile first-open tails, then repairs or narrows the optimization if they are attributable.
  2. Accept the latency tradeoff explicitly
    The feature owner records acceptance of the disclosed tails for this change while retaining the bounded CPU claims.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Introduced change and current-main boundary: Reviewed the pinned merge-base-to-head changes. Fetched main retains the earlier model-control implementation, so this PR still contributes distinct work; the verified test merge contains the same introduced paths. (ui/src/pages/chat/components/chat-model-controls.tsx:82, c69e067192cd)
  • Live facts remain outside retained choices: Selection inputs include session identity, model/runtime facts, policy retirement, and optimistic overrides; locale explicitly invalidates derived labels. Context-window settings and mutation-disabled reasons remain live reads. (ui/src/pages/chat/components/chat-model-controls.tsx:535, c69e067192cd)
  • Supplied production-renderer evidence: The complete PR body reports 960 passing reconnect behavior samples, additional retained-picker checks, CPU tables, and work counts. Measurements use production source 0cc1803; subsequent changes affect benchmark diagnostics rather than production UI. The omitted body tail was retrieved through REST, preserving the supplied body identity 1ff60ccf9f69db2c2757aead1cc768ec733cb5f6072baf2d3af0bc2c14938763. (scripts/bench-control-ui-reconnect.ts:813, 0cc1803ba2d1)
  • Unresolved performance acceptance: The committed acceptance rule says regressions over 20% block. The body reports remote one-pane reconnect wall p95 increasing from 599.80 to 958.50 ms while A/A increases only 4.18%, plus mobile first-open wall/focus p95 increases of 92.75%/46.14%. It expressly leaves these tails unexplained rather than establishing their cause or accepting their impact. (scripts/bench-control-ui-reconnect.md:63, c69e067192cd)
  • Inspected visual evidence: Viewed all four linked GitHub images through an in-memory download after scratch writes failed. The desktop before/after images are identical 1920×1080 PNGs with SHA-256 7a61b695c89829ff95700638ada70f1963f43123f89df8a730cf506d18bd4924; the mobile pair are identical 390×844 PNGs with SHA-256 3421bf499b924d81dd59fb7c414504683831f71b987485ba0a83f60c91fcb8b8. They show retained chat content, draft, selected model, and filtered picker rendering. (c69e067192cd)
  • CI remains unclassified: Exact-head run https://github.com/openclaw/openclaw/actions/runs/40290743515 fails docs, lint, core test typing, two browser leaves, and the aggregate gate. Browser annotations expose a build timeout and a chat-stop assertion receiving two requests instead of one. Neither is proven diff-caused or inherited. Full log retrieval was blocked at the Azure artifact host; the successful base run skips at least the docs leaf and therefore does not establish equivalent coverage. (c69e067192cd)

PR surface

Source +181, Tests +135, Docs +67, Other +1223. Total +1606 across 19 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 12 459 278 +181
Tests 3 143 8 +135
Docs 1 67 0 +67
Config 0 0 0 0
Generated 0 0 0 0
Other 3 1238 15 +1223
Total 19 1907 301 +1606

Review metrics

Metric Value Why it matters
Runtime production versus tests Production +181 LOC; tests +135 LOC Growth supports narrower derivation inputs and distinct retained-session, locale, speed, and context-window contracts; the catalog helper and shared type module move existing code.

Labels

Label changes:

  • add P2: This is a bounded renderer CPU improvement without an established urgent user-facing regression.
  • add merge-risk: 🚨 other: User-facing reconnect and picker latency tails exceed the stated performance acceptance threshold, with attribution unresolved.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.

Label justifications:

  • P2: This is a bounded renderer CPU improvement without an established urgent user-facing regression.
  • merge-risk: 🚨 other: User-facing reconnect and picker latency tails exceed the stated performance acceptance threshold, with attribution unresolved.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rank-up moves

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

  • Resolve or explicitly accept the affected latency tails under the documented performance rule.
  • Attribute the failing checks using accessible job logs and equivalent coverage before selecting a repair or inherited-failure path.

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 26, 2026, 4:37 AM ET / 08:37 UTC.

@steipete
steipete enabled auto-merge (squash) October 26, 2026 16:14
@steipete
steipete disabled auto-merge October 26, 2026 16:37
…184383)

Warm reloads restored the composer's model control from the cached composer snapshot but rendered effort, fast mode and permission from live data only. Those controls changed once after first content on every reload.

The existing composer snapshot now also carries display facts for the reasoning/thinking level and profile (capped list), fast-mode presentation, and permission mode with its agent default. Until the selected session is live and its accepted history matches, the composer renders those cached facts with final geometry. The permission control stays disabled while it shows cached state, live owners supersede the snapshot once ready, and actions remain live-authorized.

Evidence, 11 interleaved pairs per route on AWS c7a.4xlarge: composer transitions after first content 1 -> 0 in 11/11 pairs on both chat and dashboard; no secondary regression under the campaign rule; snapshot +235 bytes (+0.49%). Full UI e2e: 842 files passed, 1 inherited filesystem failure. The three checks-ui (1/3) CI failures sit outside this diff and passed in matched shard replays of both main and this head (two replays), so they are classified as load-sensitive flakes. Runtime +104 LOC.
@steipete
steipete merged commit 0cbd02a into main Oct 26, 2026
134 of 135 checks passed
@steipete
steipete deleted the solid2/w-perf-reconnect-final branch October 26, 2026 18:18
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 27, 2026
* perf(ui): isolate chat model selection derivation

Keep current mutation guards while retaining model choices across unrelated frame updates. Preserve in-place session facts and locale invalidation. Add a reproducible reconnect matrix with separate update prompt and reload intervals.

* perf(ui): defer unopened model picker options

Derive the selected model summary without expanding every option family. Let the retained picker panel request the full options on first open while preserving Default, runtime and context-budget semantics.

* perf(ui): retain fast-mode derivation across unrelated frames

Compare the model, runtime, speed and availability fields before rescanning the catalog. Keep locale invalidation and live outer mutation guards. Narrow helper input types to the facts it reads.

* test(ui): cover reconnect picker and HTTP latency costs

* perf(ui): retain saved model presentation across reconnect frames

* fix(ui): preserve reconnect profiling across refresh

* refactor(ui): separate shared model control types

* perf(ui): retain eager model options after mobile measurements

Reject lazy option expansion after 20 interleaved mobile first-open pairs increased script CPU by 8.5 percent with a flat control. Keep the narrower selection and Fast-mode derivations and stable saved-model snapshot; restore the original picker API and eager option preparation.

* test(ui): add diagnostic interaction function counts

* perf(ui): limit model search to searchable presentation facts

* test(ui): collect function coverage before browser warmup

* perf(ui): narrow model selection and catalog search inputs

* test(ui): record first-open input phases

* test(ui): preserve input cadence in picker diagnostics

* test(ui): align model fixture types and benchmark formatting

* test(ui): await lazy transcript group before label assertion

* test(ui): reopen publication menu after request admission

* test(ui): await queued patch admission without polling

* test(ui): settle lazy sharing content before assertions

* perf(control-ui): restore composer controls from the cached snapshot (openclaw#184383)

Warm reloads restored the composer's model control from the cached composer snapshot but rendered effort, fast mode and permission from live data only. Those controls changed once after first content on every reload.

The existing composer snapshot now also carries display facts for the reasoning/thinking level and profile (capped list), fast-mode presentation, and permission mode with its agent default. Until the selected session is live and its accepted history matches, the composer renders those cached facts with final geometry. The permission control stays disabled while it shows cached state, live owners supersede the snapshot once ready, and actions remain live-authorized.

Evidence, 11 interleaved pairs per route on AWS c7a.4xlarge: composer transitions after first content 1 -> 0 in 11/11 pairs on both chat and dashboard; no secondary regression under the campaign rule; snapshot +235 bytes (+0.49%). Full UI e2e: 842 files passed, 1 inherited filesystem failure. The three checks-ui (1/3) CI failures sit outside this diff and passed in matched shard replays of both main and this head (two replays), so they are classified as load-sensitive flakes. Runtime +104 LOC.
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. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant