Skip to content

perf(ci): split ui-regression.ts into 5 independent scripts for parallel execution - #806

Closed
devswha wants to merge 4 commits into
mainfrom
cursor/split-ui-regression-da36
Closed

devswha wants to merge 4 commits into
mainfrom
cursor/split-ui-regression-da36

Conversation

@devswha

@devswha devswha commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

Change

The monolithic ui-regression.ts (207-217s) was the serial bottleneck of the browser test lane—more workers couldn't help because it ran as one sequential script.

This PR splits it into 5 independent scripts (~40-55s each) that can run in parallel:

Script Description Estimated Time
ui-regression-palette.ts Palette navigation, IME handling, agent status, sidebar agents ~40s
ui-regression-terminal.ts Terminal input, paste, shortcuts, IME, touch input ~45s
ui-regression-settings.ts Settings, sidebar, alerts, updates, feature checks ~45s
ui-regression-session.ts Pending protocol, queue, session creation, worktree, tabs ~55s
ui-regression-mobile.ts Mobile viewport, prompts, suggestions, close/recovery, token gate ~45s

Shared setup/helpers are extracted to ui-regression-shared.ts:

  • createTestSession() / closeTestSession() - Session lifecycle
  • createDesktopPage() / createMobilePage() - Browser contexts
  • createWsTracker() - WebSocket message tracking
  • Common utilities (until, selectPane, reportAgent, etc.)

CI Changes

The browser lane is restructured:

  • browser-main → browser-shard-1: Runs the 5 split scripts with 2 workers
  • browser-other → browser-shard-2: Runs all other scripts with 4 workers
  • Integration and browser aggregate job updated to depend on new shard names

Expected Improvement

Based on the research data (run2 measurements on 32-core Linux PC):

  • Before: Browser lane floor = 213s (limited by single 210s sequential script)
  • After: Browser lane = ~90-120s (5 scripts × ~45s each ÷ 2+ workers)

The original ui-regression.ts has been deleted since all 38 PASS assertions are now covered in the split scripts.


Coverage Parity Mapping

All 38 PASS assertions from the original ui-regression.ts are now covered exactly once across the 5 split scripts:

ui-regression-palette.ts (5 assertions)

Original Line Assertion
179 PASS a desktop's chat offers the mic before Settings is asked
317 PASS palette buttons keep native Enter, IME keeps its keys, and arrow selection stays visible
368 PASS delayed machines poll preserves newer streamed pane status
422 PASS Agents excludes shells, survives PC folds, selects its machine target and disables offline rows
495 PASS a pane whose turn ended on its background work reads BG in the sidebar and the composer

ui-regression-terminal.ts (4 assertions)

Original Line Assertion
585 PASS terminal Shift+Enter sends a newline chord once and preserves Enter, Alt+Enter and IME
586 PASS pending IME commit precedes Shift+Enter without duplicate text
611 PASS terminal clipboard paste sends text once and preserves Ctrl+C
1857 PASS touch terminal input line sends whole lines, Enter alone, and yields to direct typing

ui-regression-settings.ts (7 assertions)

Original Line Assertion
618 PASS settings shortcut and theme
631 PASS Add PC opens from Settings, and the sidebar has no top bar
664 PASS the sidebar's edge drags, steps from the keyboard, remembers its width
681 PASS sidebar rows switch between one line and two
725 PASS an update answer that arrives while the page is hidden releases the buttons
746 PASS the Alerts item turns alerts off and on again
770 PASS a device that blocks notifications keeps the Alerts item as the switch

ui-regression-session.ts (14 assertions)

Original Line Assertion
886 PASS Send queues server-owned input, explicit Send now delivers once
990 PASS queue held through status changes and explicitly sent to its owner
1046 PASS quick replies send as typed, queue mid-turn, and leave the draft
1057 PASS the composer keeps an IME's committing Enter
1072 PASS drafts stay with their panes
1093 PASS successful sends settle after switching panes
1117 PASS upload batch cannot cross panes
1145 PASS session creation stays pending and opens one owned workspace
1270 PASS existing and new branches sit under their workspace
1345 PASS a worktree row sits under its repository's row
1403 PASS a second tab is made from the tab strip
1531 PASS a tab is renamed by a double-click, F2 and its menu
1567 PASS a pane moved into another workspace is followed under its new id
1707 PASS Send now on a server-owned pending message drops Claude's suggestion

ui-regression-mobile.ts (8 assertions)

Original Line Assertion
1600 PASS startup prompt appears and accepts an answer while the agent status is idle
1617 PASS a typed pick answered in the terminal does not wait on the same menu asked again
1673 PASS Claude's suggestion fills the composer with Tab, returns after a send
1733 PASS mobile composer with unavailable storage and no horizontal overflow
1756 PASS a pane picked on a phone waits for a tap before raising the keyboard
1787 PASS a phone offers Claude's suggestion as a chip until Settings turns it off
1918 PASS closed and obsolete saved panes recover their selection
1956 PASS token and paired-device sign out return to the access gate

Verification: 5 + 4 + 7 + 14 + 8 = 38 assertions (100% parity, no duplicates)


Validation

  • bun run typecheck passes
  • Unit tests pass (bun run test:unit)
  • 38/38 PASS assertions verified (coverage parity complete)
  • CI will validate the full browser lane with the new split scripts
  • Actual per-script durations to be reported from CI run

References research data from test-speed-research.md and gpt-6-astra.md recommendations.

Open in Web Open in Cursor 

…lel execution

The monolithic ui-regression.ts (207-217s) was the bottleneck of the browser test lane.
This change splits it into 5 independent scripts (~40-55s each):

- ui-regression-palette.ts: Palette navigation, IME handling, agent status, sidebar agents
- ui-regression-terminal.ts: Terminal input, paste, shortcuts, IME, touch input
- ui-regression-settings.ts: Settings, sidebar, alerts, updates, feature checks
- ui-regression-session.ts: Pending protocol, queue, session creation, worktree, tabs
- ui-regression-mobile.ts: Mobile viewport, prompts, suggestions, close/recovery, token gate

Shared setup/helpers are extracted to ui-regression-shared.ts.

CI workflow is updated:
- browser-main → browser-shard-1 (runs the 5 split scripts with 2 workers)
- browser-other → browser-shard-2 (runs all other scripts with 4 workers)
- Integration and browser aggregate job updated to depend on new shard names

Expected improvement: browser lane from ~210-220s to ~90-120s at 4 workers.

Co-authored-by: Hako <[email protected]>
@coderabbitai

coderabbitai Bot commented Oct 11, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

cursoragent and others added 3 commits October 11, 2026 11:41
- Add "PASS Send now on a server-owned pending message drops Claude's suggestion"
  to ui-regression-session.ts (was missing from the split)
- Delete original scripts/ui-regression.ts (all 38 assertions now in split scripts)
- Update references in docs and scripts to point to the split scripts
- Remove obsolete ui-regression.ts from ci-browser-parallel.ts evidence disable list

Coverage parity: 38/38 assertions preserved across 5 split scripts.

Co-authored-by: Hako <[email protected]>
- Add .catch() to route.continue() in ui-regression-mobile.ts to handle race
  where route is already handled
- Add waitFor() before worktree-workspace-label assertion in
  ui-regression-session.ts to ensure element is present

Co-authored-by: Hako <[email protected]>
The until() pattern with textContent() works better than waitFor()
for elements that may not be immediately visible.

Co-authored-by: Hako <[email protected]>
@cursor
cursor Bot force-pushed the cursor/split-ui-regression-da36 branch from 5d93e4b to 84ca12a Compare October 11, 2026 11:58
devswha added a commit that referenced this pull request Oct 11, 2026
## Change

`scripts/ui-regression.ts` could fail with every check passing. On #824
the first CI attempt ended with

```
451 |     await route.fulfill({ response, json: body });
error: fulfill: Route is already handled!
```

after the check that owns that route had printed PASS; a rerun of the
same commit passed.

The handlers in question await `route.fetch()` before they answer, and
the app polls `/api/machines` on its own, so a call can be in flight
whenever a check ends. `page.unroute` does not wait for it. When the
route taken away is the page's last one, Playwright drops the page's
interceptor and continues the request on the server side; the handler's
own `fulfill` then finds the route handled. The rejection travels
through Playwright's event listener, outside every assertion, and Bun
exits 1.

`scripts/drained-route.ts` adds `routeDrained(page, url, handler)`: it
registers the route and returns an unroute that first waits for the
calls in flight (15 s deadline), then removes that handler. It is used
at:

- `ui-regression.ts`: the held stale poll, the BG status check, and the
plan check on the desktop page and on the phone (its context is closed
right after).
- `tab-menu-regression.ts`: the pending-selection check, which unrouted
first and waited for its handlers afterwards.

Not used, on purpose: `unrouteAll({ behavior: "wait" })` has the same
race between two calls in flight (playwright-core 1.63) and removes
unrelated routes; `"ignoreErrors"` and a `.catch(() => {})` would hide a
handler's real failure. A handler that throws still fails the unroute
here.

Left alone: `tab-menu-regression.ts:292` and
`terminal-copy-regression.ts:176` only race in a failure's cleanup, and
five scripts close a context with a fetched route registered (a
different error, if any). #806 moves the `ui-regression.ts` sites into
`ui-regression-palette.ts`; it needs this carried over when it is
rebased.

## Validation

- Reproduction (throwaway script, local Chrome): two requests in flight,
then `page.unroute` → `fulfill: Route is already handled!` twice as
unhandled rejections; the same with `routeDrained` → both fulfilled, no
rejection; a handler that throws → the unroute rejects with that error.
- `TMPDIR=/tmp CHROME_PATH=<lockfile Chromium> bun run check run --build
bun scripts/ui-regression.ts`: exit 0, 115 PASS lines, on an isolated
herdr (this includes `checkTabMenu`).
- `bun run typecheck`: passed.
- The diagnosis and the fix were reviewed read-only against
playwright-core's source (`Route.removeHandler` continuing the request,
`_startHandling`'s assertion).

The original failure is rare (one of the last 26 failed CI runs), so a
passing run does not prove its absence; the reproduction is what shows
the race gone.

## Release

Test scripts only; no app, contract or runtime change.
@devswha

devswha commented Oct 11, 2026

Copy link
Copy Markdown
Owner Author

Closing for now: ui-regression.ts keeps changing (#839, #846 touch it), so this 2k-line split conflicts and would need redoing anyway. If the browser lane's time becomes the bottleneck again, the split should be made fresh from main at that point.

@devswha devswha closed this Oct 11, 2026
@devswha
devswha deleted the cursor/split-ui-regression-da36 branch October 17, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants