ci: warm Vite before browser tests, per-file limits, 40 min cap (cx-v6fbz)

Merged
TE
22d ago
+339-17

Summary

web / react-apps-check flaked on PRs (e.g. #20697 at 3764122b82, and the gallery-frame tests #20681 hit). Three causes, all from load on the 8 vCPU runner, none in the code under test:

  • Cold Vite servers. Vite prints its port before it has transformed a module, so a browser test's first page load paid for the whole module graph inside its 30 s navigation timeout. chat-find and text-field-focus failed that way: first load past 30 s, the second load 10-27 s, the rest about 2 s. The gallery frame starts every *.gallery.tsx load on first paint (src/gallery/entryStore.ts), about 2,300 modules, so the gallery-frame and agent-pane browser warm-ups hit the same wait.
  • editor-page's own size. 24 browser tests in two engines take about 115 s on CI, against the runner's 120 s per-file limit. The kill at 120 s closed the browser under the remaining WebKit tests ("Target page, context or browser has been closed").
  • The job cap. The test step alone took 22 min (277 files, about 90 of them dev-server files two at a time). The --with-deps engine install took 2.5 min on one attempt and 11.5 on the next, which left the tests 17 min, so the rerun was cancelled at 30.

Fixes, no assertion changed or loosened:

  • test/support/warmDevServer.ts: warmDevServer(base, page) / warmViteServer(vite, page) request the page and every module it imports, as the browser will, so the server caches each transform before a test's own timeouts start. 80 test files call it once their server listens (70 in-process servers, 10 spawned vp dev).
  • scripts/check-browser-test-lanes.ts (run by bun run check) now fails a test that starts a dev server without warming it. On base it flags 80 of 240 test files; on this head none.
  • scripts/ci/run-webviews-tests.sh: a file may declare a longer limit with a // cmux-web-test-timeout: SECONDS header line; editor-page declares 240.
  • diff-virtualization: the tree-row click checks the row is still under the pointer after the 150 ms settle, else finds it again (the WebKit failure read null for a header the click never opened).
  • The react-apps-check job cap raise (30 -> 40 min) moved to #20854, so this PR does not run the web/ unit shards, which are red on base.

Measured on the private Linux builder (idle 96 cores), cold then warm:

pagemodulescoldwarm
agent pane /8027.1 s0.17 s
gallery frame2,32535.4 s4.4 s
editor1,5522.8 s0.36 s
diff test page4852.8 s0.13 s

Verification

  • Runner: python3 -m unittest tests.test_webviews_tests_per_file (7 tests). The new per-file limit test was committed first and failed (TIMEOUT test/slow-declared.test.ts at the 2 s default), then passed.
  • Warm rule: red on base (80 files flagged), and bun run check passes on this head with the rule (format, lint, types on 1,379 files, plus layers, type scale, focus rings). Both ran on the Linux builder.
  • warmDevServer: checked against real Vite (table above) and a local fixture with an import cycle, a relative entry and a lazy import.

Not verified locally: the browser test files themselves. Big-red may not run browser suites; this PR's react-apps-check run is their first run with the change.

Follow-up

The gallery frame loads every entry to find one; loading only the requested entry would cut a cold gallery load from about 2,300 modules. That is a gallery change, not part of this fix.

Changelog

none

Bead: cx-v6fbz

🤖 Generated with Claude Code


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


Summary by cubic

Fixes flaky browser and webviews CI tests that timed out or failed because the cold Vite dev server compiled the whole module graph during a test's first page load. Tests now warm the server before launching browsers, can declare a longer per-file limit, and the diff-virtualization test no longer clicks a tree row that has moved.

  • Added warmDevServer/warmViteServer to request a page and its imports before the first navigation; called in 81 test files (settings-scroll warms only after its readiness poll).
  • check-browser-test-lanes now fails any test that starts a dev server without warming it.
  • Test files can set a // cmux-web-test-timeout: SECONDS header for a longer per-file limit; editor-page, text-field-focus, chat-find, diff-virtualization, files-panel-coverage, ime-composition-keys, menu-focus, settings-scroll, and ui-a11y declare longer limits.
  • Fixed diff-virtualization to click a tree row only while it is still under the pointer after the 150 ms settle, climbing out of shadow roots, and re-find it when it moved.
  • Spawned-server tests and menu-focus now warm the whole gallery graph, so dev-server files declare 240 s limits; failed warm-up visits no longer leave unhandled rejections.