Skip to content

test(relay): assert every sign-in poll is aborted on close, however many began - #3873

Merged
devswha merged 1 commit into
mainfrom
test/relay-signin-extra-poll
Nov 15, 2026
Merged

devswha merged 1 commit into
mainfrom
test/relay-signin-extra-poll

Conversation

@devswha

@devswha devswha commented Nov 15, 2026

Copy link
Copy Markdown
Owner

What

src/components/RelaySignIn.test.tsx "the relay tab's Sign in > ends the waiting sign-in when the sheet closes, keeping no session" failed on main b44aebe (CI 43676219681, Fast checks, 14 ms): expect(polls.map((signal) => signal.aborted)).toEqual([false]) received one more element.

Cause

The test's fetch stand-in answers the sign-in's start with interval: 0.001 so the first poll comes at once. After await firstPoll, deviceSignIn.finish waits that 1 ms and sends the next /v1/token poll, which can already be in polls when the assertion reads it: an ordering race inside the test, on any runner.

Fix (test-only)

finish hands every poll the sign-in's one signal, so the test asserts what closing the sheet must do whatever the number of polls: at least one poll began, none was aborted before the close, and every one is aborted after it (and, as before, no session is kept). No wait or timeout is added.

Validation

  • bun test ./src/components/RelaySignIn.test.tsx: 20 of 20 passed.
  • bun run check fast: passed (exit 0).

@coderabbitai

coderabbitai Bot commented Nov 15, 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
    • Updated sign-in sheet close coverage to verify that all token polls remain active before unmount and are aborted afterward.

The sheet-close test now allows multiple token polls. It checks that every recorded poll signal is active before unmount and aborted afterward.

Changes: Relay sign-in poll cleanup

Layer / File(s) Summary
Poll cancellation assertions
src/components/RelaySignIn.test.tsx
The test accepts one or more polls and verifies that all recorded signals are un-aborted before unmount and aborted afterward.

Estimated code review effort: 1 (Trivial) | ~4 minutes

Change: Other

Merge Risk: Minimal · previous review c3b99

This is a test-only change that removes a timing race in the sign-in poll cancellation test. It does not affect runtime behavior and is low risk to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the relay sign-in test now asserts that every poll is aborted on close, regardless of how many polls began. It is specific and matches the changeset and objectives.
Description check Passed The description covers the failing test, the root cause (an ordering race from a 1 ms poll interval), the test-only fix, and validation results. It does not follow the repository template's headings, …
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: Description check

Explanation

The description covers the failing test, the root cause (an ordering race from a 1 ms poll interval), the test-only fix, and validation results. It does not follow the repository template's headings, since it lacks a '## Change' and '## Validation' structure and omits a changelog reference and contract-test note. The template's Change and Validation content is mostly present, so the check passes.

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 2349b2d and c3b99a0.

Files selected for processing: 1

  • src/components/RelaySignIn.test.tsx

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

devswha added a commit that referenced this pull request Nov 15, 2026
…nstead of racing its timer (#3879)

## What

Several browser scripts fail now and then on loaded runners, each twice
in a job, in runs whose PR touches none of them: #3873's run 43679950388
(attempt 2) failed agent-groups, agent-helpers-fold, chat-working-line,
omo-question-wheel, phone-glass-header, prompt-card-lifetime and
sidebar-peek; the private repository saw sidebar-peek's hover time out
the same way.

## Cause

The demo opens with its Claude pane mid-turn, and
`site/demo/transport.ts` ends that turn with `setTimeout(…, 4500)`: 4.5
s of real time after the transport loads. Scripts that check that pane
while it works (its `working` status in the sidebar, the live work block
in its chat, the row a peek opens) race that timer. On a busy runner the
page reaches those checks after 4.5 s, the turn has ended, and the check
waits out its timeout. `scripts/inbox-mode-demo-regression.ts` already
avoids it with its own fixture.

## Fix (test-only)

- `site/demo/transport.ts`: the turn's end moves into
`finishOpeningTurn()`. When a script sets `__ovisDemoHoldTurn` before
the transport loads, no timer starts and `window.__ovisDemoFinishTurn`
ends the turn when the script wants it; a visitor's demo keeps the 4.5 s
timer exactly as before.
- The five scripts that need the pane working set the flag in their
browser contexts (one `addInitScript` each): agent-groups,
agent-helpers-fold, chat-working-line, phone-glass-header and
sidebar-peek.
- omo-question-wheel and prompt-card-lifetime failed in the same run but
do not run on the demo (no `buildDemoApp`; omo-question-wheel's working
dot is its own fixture's), so they are unchanged and stay separate
goals.

No fixed wait is added, no timeout is raised, no assertion changes.

## Validation

All in the CI runner image, one heavy slot each:
- agent-groups, agent-helpers-fold, chat-working-line,
phone-glass-header, sidebar-peek: each passed alone.
- Forced delay (temporary copies, not in this PR, that reach the working
check after 6 s): chat-working-line and phone-glass-header each failed
without the hold and passed with it.
- `bun run typecheck`: passed. `bun run check fast`: passed (exit 0).
…any began

The fetch stand-in sets a 1 ms poll interval, so a second /v1/token poll could already be listed when the test asserted exactly one (main b44aebe, Fast checks). Every poll carries the sign-in's one signal; the test now checks that none is aborted before the close and all are after it.
@devswha
devswha force-pushed the test/relay-signin-extra-poll branch from c3b99a0 to 9522984 Compare November 15, 2026 09:32
@devswha
devswha merged commit 1f97f60 into main Nov 15, 2026
20 of 23 checks passed
@devswha
devswha deleted the test/relay-signin-extra-poll branch November 15, 2026 11:44
@devswha

devswha commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Merge pass

Merged head 95229845b8b1 as 1f97f601ec22 on GitHub's checks, with no unresolved review threads.

Reviewer Verdict Note
claude CLEAR

One reviewer: test-only.

Left open, not blocking (owner PR; MEDIUM and LOW do not block):

  • LOW (claude; not run): the final "no session kept" check cannot fail even if polling outlived the close; it predates this PR and the abort assertion covers the regression (RelaySignIn.test.tsx:258)
    CodeRabbit did not review this head.
    Review reports: ~/.cache/ovis-tmp/reports/

devswha added a commit that referenced this pull request Nov 15, 2026
… lane's limit (#3892)

## What

`scripts/ui-regression.ts` ends at the browser lane's limit for one
script (600 s, exit 124) on loaded runners and so reddens "Browser
regression (ui-regression)": main (run 43685347171, and df92f77's
run), #3876, #3873 (run 43699760401, `FAIL scripts/ui-regression.ts
(600.6s) exit=124`). It is not hung: it passes check after check until
the limit stops it.

Alone in the CI runner image on one 6-CPU slot it takes **331.1 s** for
its 85 checks. CI's browser jobs run about 2.4x slower than that, about
795 s, well past 600 s.

## Fix (test-only)

The script runs in four parts, each from its own server and browser:
- `main` (`scripts/ui-regression.ts` itself): the desktop page's
stateful flow and the phone pages after it;
- `terminal` (`scripts/ui-terminal-regression.ts`): the terminal's keys
(`checkCommandBackspace`, `checkCtrlEnter`, `checkCommandArrows`),
`checkTerminalInput`, the held drafts, a phone's input line and the
attach;
- `ime` (`scripts/ui-ime-regression.ts`): the Safari, iPad and Linux IME
replays;
- `access` (`scripts/ui-access-regression.ts`): sign out on a server
with a token, and the relay panel.

No check is dropped, and no check's code changes except the helper fix
below. Each part's code is wrapped in `if (part === …)` and indented by
two spaces (no multi-line string sits inside, so no text changes). **The
order of the main flow changes.** Three groups of checks move:
- the closed-pane, row-menu and selection checks ("closed and obsolete
saved panes recover their selection") now run right after the phone's
suggestion-chip check, not after the terminal and IME checks;
- the three key checks (`checkCommandBackspace`, `checkCtrlEnter`,
`checkCommandArrows`) leave their place between the Shift+Enter check
and the pane-shortcut check for the `terminal` part;
- `checkTerminalInput`, the held drafts, a phone's input line and the
attach go to `terminal`, the IME replays to `ime`, and sign out and the
relay panel to `access`.

The moved checks open pages of their own; `browser`, `origin` and the
two panes are all they take. The PASS-line comparison under Validation
(53 + 27 + 3 + 2 = 85, each exactly once, all passing) is the evidence
that no later step depended on state the moved checks left behind.
Review with `git diff -w`, or `--color-moved` for the moved blocks. The
new entry files are 10 lines each. No wait or timeout is added to
`ui-regression.ts`, and `scripts/fixed-sleeps.json` is unchanged.

One helper needed a fix: `checkCommandBackspace` pressed its first key
as soon as the page was live. In the unsplit script the desktop page had
attached that pane 17 s before, so the key was always taken. On a fresh
server (the `terminal` part) the first Backspace went out before the
pane's `input-ready` and was not sent. It now waits for `input-ready`
(bounded at 15 s) before its first key, in both of its contexts, as
`checkCtrlEnter` and `checkCommandArrows` already do. Its watcher is
attached before the page loads and only records the frame. The promise
and its timer exist only inside the wait that is awaited, so a failed
load leaves nothing to reject unhandled. Settling clears the timer and
takes off the page's and the sockets' listeners. No fixed sleep is
added.

### Herdr sessions: parts side by side share none

`BROWSER_WORKERS: 2` runs two of these scripts at once, and
`ci-browser-parallel.ts` spawns each with the lane's whole environment.
That includes the `HERDR_TEST_SESSION` and `HERDR_SOCKET` of the job's
one `bun run check run`, so as first pushed, every part joined that one
herdr session and made the same `ovis-test-browser-a`/`-b` workspaces
(CodeRabbit's finding on ci.yml). A run of `main` and `terminal` side by
side the CI way (`bun run check run -- bun
scripts/ci-browser-parallel.ts`, two workers) at d3af150 showed it.
Mid-run, the lane's session `check-99f883` listed
`["ovis-test-resident","ovis-test-browser-a","ovis-test-browser-a","ovis-test-browser-b","ovis-test-browser-b"]`,
and `main` failed after 19.8 s with `Timed out: the other pane is the
palette's only result`: its palette search for `ovis-test-browser-b`
found `terminal`'s workspace too. Before, only the scripts' timings kept
the two apart.

Now:
- `scripts/ui-regression.ts` run itself is always `main`
(`import.meta.main`), on the session the environment names: the lane's.
- Each other part's entry file runs it on a herdr session, config and
state of its own and stops that session after, through
`scripts/own-herdr.ts` (`runOnOwnHerdr`). That helper is the UI context
scripts' isolation, moved out of `scripts/ui-contexts-run.ts` unchanged,
and `runIsolatedUiContextChecks` now calls it. So at most one script in
the job (`main`) uses the lane's session.
- The entry files pass their part explicitly, and an inherited
`UI_REGRESSION_PART` cannot make `bun scripts/ui-regression.ts` skip the
main flow. The script's first line names its part, session and socket,
e.g. `ui-regression part terminal: herdr session check-1a8332, socket
/tmp/hwc-8d8pQi/config/herdr/sessions/check-1a8332/herdr.sock` beside
`ui-regression part main: herdr session check-3220a8, …`.
- `scripts/pages-gate.test.ts`'s guard test (refuses unit and live runs
before touching herdr) now covers the three entry files too.

### This PR touches `.github/` and `package.json`

- `.github/workflows/ci.yml`: the three new scripts are added to
browser-main's `BROWSER_SCRIPTS` (so that job still runs all of
ui-regression) and to browser-other's `BROWSER_EXCLUDE` (so nothing runs
twice). `BROWSER_WORKERS` stays 2.
- `package.json`: `test:ui` runs the three new parts too, so the local
UI command stays complete.

The other option was having the parallel runner expand one entry into
parts. It would still have needed `test:ui` changed, and it would change
how the runner reads `ci-browser.sh` and the timings table. So this PR
follows #3865 instead. **It touches a workflow and `package.json`, so it
waits for GitHub's own checks and a real review.**

Also updated: `scripts/ui-contexts-run.ts` (now calls
`scripts/own-herdr.ts`), `scripts/ci-browser.sh` (the new scripts, and
the list that runs without evidence capture), the same list in
`scripts/ci-browser-parallel.ts`, `scripts/pages-gate.test.ts` and
`scripts/ci-browser.test.ts` (the lists they pin), and
`docs/development.md`. `scripts/ci-browser-timings.json` is not edited:
the new parts start first until `bun scripts/ci-browser-timings.ts`
takes their seconds from CI runs.

## Validation

All runs are in the CI runner image (`herdr-ci-runner:local`, own
network namespace), pinned to one heavy slot, built with `bun install
--frozen-lockfile && bun run build`, with `CI=true
RUNNER_ENVIRONMENT=self-hosted BROWSER_RETRY=0`. The timings table is
from the first push, on 6-CPU slots, running `bun
scripts/ci-browser-parallel.ts` without `check run`.

| script | before (alone) | after (alone) |
|---|---|---|
| `scripts/ui-regression.ts` | 331.1 s (85 PASS) | 98.1 s (`main`, 53
PASS) |
| `scripts/ui-terminal-regression.ts` | – | 52.7 s (27 PASS) |
| `scripts/ui-ime-regression.ts` | – | 98.0 s (3 PASS) |
| `scripts/ui-access-regression.ts` | – | 34.5 s (2 PASS) |

53 + 27 + 3 + 2 = 85. The sorted PASS lines of the unsplit run equal the
union of the four parts' PASS lines, each exactly once. The only textual
difference is a pasted screenshot's timestamped file name. At CI's
observed 2.4x, the slowest part comes to about 235 s against the 600 s
limit.

At this push, on 4-CPU slots (2 cores, both threads), as the job runs
it: `CHECK_DIR=… BROWSER_SCRIPTS=… BROWSER_WORKERS=2 bun run check run
-- bun scripts/ci-browser-parallel.ts`:
- `main` and `terminal` side by side
(`BROWSER_SCRIPTS=scripts/ui-regression.ts,scripts/ui-terminal-regression.ts`):
at d3af150 **1/2 passed** (`main` failed after 19.8 s on the shared
session, as above). At this head, **3 runs, 2/2 passed each** (167.0 s,
131.7 s and 132.5 s). In each run, the lane's session listed one
`ovis-test-browser-a`/`-b` mid-run, and `terminal` named a session of
its own.
- browser-main's whole script set (the six scripts,
`BROWSER_WORKERS=2`): **6/6 passed in 472.0 s** (ui-regression 118.8,
terminal 65.3, ime 132.6, access 48.4, ui-contexts 345.8,
ui-contexts-layout 143.2 s). One earlier run failed in
`checkUpdateNotice` only because `dist/` had been built at an older
commit: that check compares the client's built-in revision with `git
rev-parse HEAD`. Rebuilt at the commit, it passed.
- At the first push: the same set, 6/6 in 553.5 s.
- `bun run check fast`: passed (exit 0), including
`scripts/pages-gate.test.ts`, `scripts/ci-browser.test.ts`,
`scripts/ci-browser-parallel.test.ts`,
`scripts/ci-browser-timings.test.ts` and `scripts/conventions.test.ts`.
- Skipped: `bun run check full` and the integration lane (no server,
shared or src code changes), browser-other's scripts (none changed),
Windows/macOS.

## Not in this PR: `scripts/ui-contexts-regression.ts` is next

It takes **276.5 s alone** in the same image (over the ~250 s line) and
414.8 s beside one other script. In CI it was seen at 565 s. Its slowest
helpers are `checkTabMenu` 42.2 s, `checkUpdateNotice` 31.4 s,
`checkNewTabTypeAhead` 21.0 s, `checkMobileTabs` 16.5 s, `checkDroplet`
14.4 s, `checkUsageMeters` 12.9 s and `checkAlertSound` 12.3 s. A third
group in `ui-contexts-checks.ts`, as `layout` was split off in #3242,
would bring it well under. It is left out so this PR stays small.
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