Skip to content

test(browser): wait on the state three flaky scripts raced - #4757

Merged
devswha merged 4 commits into
mainfrom
fix/browser-flakes-1125
Nov 25, 2026
Merged

devswha merged 4 commits into
mainfrom
fix/browser-flakes-1125

Conversation

@devswha

@devswha devswha commented Nov 25, 2026

Copy link
Copy Markdown
Owner

What changed

Three browser scripts that failed once and passed on their second run in CI (#4747, #4748 and others) now wait on the state they need instead of racing it. Only the scripts change; no app code.

  • scripts/chat-reading-position-demo-regression.ts ("older"): presses Earlier messages from the keyboard where it is, and waits for the exact number of page reads.
  • scripts/palette-machines-demo-regression.ts (Back/Forward to a creation link): never leaves a history entry it pushed as the current entry.
  • scripts/pending-pane-switch-regression.ts (lost connection): awaits the close of a refused WebSocket before its route handler returns.

Why

Each cause was found from a failed run's state, then forced to show it is the one CI hit.

  • chat-reading-position. A click scrolls the button to the top first, and the top reads an earlier page by itself. So the click raced a second read. Either the button re-rendered under the click (CI: click: Timeout 6000ms exceeded, a row "intercepts pointer events", then "element was detached"), or two pages arrived at once and the next height wait was already met before the test's wheel landed.
  • palette-machines. The app writes its own address over the history entry it is on whenever the two differ, and a roster update reruns that write. A failed run's history log shows the write landing on the name=Forward entry the test had just pushed, 300 ms before its Back. Forward then reached the pane's address, and no dialog opened (CI: waitFor: Timeout 30000ms exceeded on dialog /^New workspace/).
  • pending-pane-switch. The route handler refused a reconnect with an unawaited socket.close(). Playwright opens a routed socket the handler did not connect as soon as the handler returns. When that open landed first, every refused attempt opened and closed on the page, each one restarted the client's reconnect grace, and the connection chip stayed live past the 10 s wait (CI: waiting for locator('.conn-live') to be hidden, 23× visible).

Failure rates (CI runner image herdr-ci-runner:local)

Script Condition Before After
chat-reading-position 2 CPUs, 3 runs at once 11/30 0/30
palette-machines the app's address write forced right after the test's push 30/30 0/30
palette-machines 2 CPUs, 3 runs at once 0/30 0/30
pending-pane-switch Playwright's open forced before the close 28/30 -
pending-pane-switch 2 CPUs, 3 runs at once 0/30 0/30
pending-pane-switch lost connections repeated in one run (queue, lose, Send now), no CPU limit 1 in 617 1 in 3,203

The forced rows reproduce the exact order a failed run showed, inside the real script. The fix for pending removes that order, so it has no forced "after" row.

Not fixed here

  • portal-regression (focus: Timeout 10000ms exceeded on Private link for alice). Both CI failures (runs 45327133346 and 45630135993) were on the HostHatch runners, and the field was missing for the whole 10 s. The WebSocket close in those logs is the test's own teardown: Bun prints the uncaught error only after finally has run. Other scripts in the same job kept logging every 1–2 s, so the machine did not stall. Not reproduced in about 600 runs: locally (CPU-capped and uncapped, with herdr workspace churn in the same session), on HostHatch (portal alone), and with CI's own shard 1/3 under bun run check run on both machines. No speculative change is made.
  • pending-pane-switch, a rarer second path: 1 failure in 3,203 lost connections after the fix. Both failed runs had the same page: the header chip and the sidebar said live/Connected while the terminal-view panes showed "Reconnecting to Ovis…". In the second, a dump of the React props shows the pane that feeds the header is the active pane, in chat view, and it was still reporting the connection as up more than 10 s after the drop. This is app behaviour: a chat-view pane can miss a drop that terminal-view panes see. It needs its own fix in the app, not in this script.

Validation

  • bun run check fast in the CI runner image, on this head rebased on main: typecheck, build and generated files pass. The unit run's only failures came from how the image was run locally, not from this branch (which changes three browser scripts only). server/ssh-account-add.test.ts fails as uid 1000 (ubuntu, no home directory) and passes 3/3 as uid 1001 (runner, as in CI). scripts/plugin.test.ts fails when the clone's owner is not the user running the tests.
  • The runs in the table above.

… it into view

A click scrolls the button to the top first, and the top reads an earlier
page by itself, so the click raced a second read: the button re-rendered
under the click, or two pages arrived and the next wait was already met
before the test's wheel landed. Press it from the keyboard where it is and
wait on the exact number of page reads.
…ent entry

The app writes its own address over the entry it is on whenever that
differs (a roster update reruns the write), and a failed run showed that
write landing on the Forward link the test had just pushed, 300 ms before
its Back: Forward then reached the pane's address and no dialog opened.
Push the current address back on top of the link in the same task, step
back past both and go forward onto the link. Also wait for the app's
first address write before reading it as the page's own.
…ndler returns

The handler refused a reconnect with an unawaited close. Playwright opens a
routed socket the handler did not connect as soon as the handler returns,
so when that open landed before the close the page saw a socket open and
close on every refused attempt: each one restarted the reconnect grace,
and the connection chip stayed live past the 10 s wait for it to hide.
Forcing that order fails the script at its first lost connection every
time, as CI did; awaiting the close leaves the socket closed before
Playwright looks at it.
@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Tests
    • Improved browser regression checks for loading earlier chat messages, navigating between workspace-creation pages, and handling pending pane switches.
    • The updated checks verify expected message counts and transcript growth, exercise keyboard activation and browser navigation, and wait for refused connections to close before continuing.

Three browser regression scripts change how tests load earlier chat messages, navigate to workspace-creation links, and close refused WebSockets.

Changes: Chat reading position

Layer / File(s) Summary
Keyboard page loading
scripts/chat-reading-position-demo-regression.ts
The older-message scenario focuses the “Earlier messages” button without scrolling and activates it with Enter. The waits check expected read counts and transcript growth.

Palette history navigation

Layer / File(s) Summary
Creation-link history navigation
scripts/palette-machines-demo-regression.ts
The test adds linkAhead to place a target URL ahead in browser history. The remote and local creation-link checks use this helper.

Pending pane socket handling

Layer / File(s) Summary
Awaited socket cleanup
scripts/pending-pane-switch-regression.ts
The route callback becomes asynchronous and awaits closing a refused socket.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Possibly related PRs

  • devswha/ovis#3614: Changes address-write handling during popstate, which relates to the palette regression’s browser-history navigation.

Suggested reviewers: christso, yulong-ge

Merge Risk: Minimal · previous review 92f7a

This change only adjusts browser regression test scripts to wait on the state they need instead of racing browser behavior. It has no production impact, and no concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the test(browser) change and the core intent: waiting on state that three flaky scripts were racing. It is specific enough for a teammate scanning history. It is a single sentence, und…
Description check Passed The description follows the template. It has a Change section that describes the problem and the resulting behaviour, with a per-script breakdown and root causes. It has a Validation section that list…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the test(browser) change and the core intent: waiting on state that three flaky scripts were racing. It is specific enough for a teammate scanning history. It is a single sentence, under 60 characters, and matches the objectives: the three scripts now wait for state instead of racing browser behaviour.

Full details: Description check

Explanation

The description follows the template. It has a Change section that describes the problem and the resulting behaviour, with a per-script breakdown and root causes. It has a Validation section that lists the checks run (bun run check fast), the results, and the failure-rate runs. It names the skipped or out-of-scope items (portal-regression, the app-side chat-view issue). The template asks for a linked issue for features only; this is a test fix, so that does not apply. The Change section links the CI runs by PR number (#4747, #4748) rather than an issue. Overall the description is mostly complete.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • 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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 97772af and 92f7a9e.

Files selected for processing: 3

  • scripts/chat-reading-position-demo-regression.ts
  • scripts/palette-machines-demo-regression.ts
  • scripts/pending-pane-switch-regression.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

page.evaluate runs without a timeout, so awaiting popstate inside it
could hang the script past every bound. The page marks the landing and
page.waitForFunction waits for the mark.
@devswha

devswha commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Gate review (omo) at 92f7a9e: one MEDIUM, linkAhead awaited popstate inside page.evaluate, which has no timeout. Fixed in 23e7d4c: the page sets a mark on popstate and page.waitForFunction waits for it. Palette script re-run in the runner image: 3/3 plain, amplified runs passing; conventions 40/0, typecheck green.

@devswha
devswha merged commit 673ba83 into main Nov 25, 2026
14 of 15 checks passed
@devswha

devswha commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Merged through pr-merge at head 23e7d4cb5. Seen before the merge was asked for: required checks green, no unresolved thread, no conflict, no hold, main not red, no release in progress. CodeRabbit said it did not review (a limit or a skip) since this head.

main moved but untouched: merged without update. Its new commits up to b661f80cf change no file of this pull request, none imported by one, and nothing that decides which checks run.

CodeRabbit did not review this head (limit). Reviews: one omo gate reviewer at 92f7a9e (one MEDIUM: an unbounded popstate wait in linkAhead, fixed in 23e7d4c and re-run in the runner image). Merged on the lead (Dori)'s word. Test-only change to three browser scripts. The failed herdr-core live contract is the known intermittent with-core dump-WASM test, not a required check.

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.

1 participant