Skip to content

test(newtab): count only frames the page sent on an open socket - #3788

Merged
devswha merged 1 commit into
mainfrom
test/newtab-count-sent-frames
Nov 12, 2026
Merged

devswha merged 1 commit into
mainfrom
test/newtab-count-sent-frames

Conversation

@devswha

@devswha devswha commented Nov 12, 2026

Copy link
Copy Markdown
Owner

Summary

scripts/newtab-typeahead-regression.ts:149 (via ui-contexts-regression) timed out twice on the merge pass's mesh VM gate (4 vCPU) for #3787's tree:

dialog: the page's frames for the new tab are all heard; expected "echo ahead-dialog\r", heard "echo ahead-dialog\r"

The text heard equals the text expected, but heard.count >= sentByPage never held.

Cause

The page-side counter, added in #3713, raised sentByPage on every WebSocket.send() of an input or keys frame, before send ran.

src/lib/ws.ts rawSend() calls socket.send with no readyState check. Input goes through it directly (ws.ts 1043, 1136), and send() gates on this.connected, which can still be true while the socket is closing.

The browser discards a frame sent on a CLOSING/CLOSED socket, and a send on a CONNECTING one throws, so neither fires Playwright's framesent. The page counted a frame the listener could never hear, and the wait could not end.

Fix (test only, no sleeps)

The page counts a frame only when its socket was OPEN and send returned. The wait still covers every frame that actually left, an unexpected extra one included.

Validation

  • HERDR_TEST_MODE=integration bun scripts/newtab-typeahead-regression.ts (after bun run build): 3/3 pass at load 61-64.
  • bun run check fast: pass.

No changelog fragment: this changes a test only.

Not in this PR: ws.ts handing input to a socket that is no longer open may lose a key. Reported to the lead as a product question.

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Tests
    • Improved regression checks for browser frame events by counting only eligible messages sent through an open connection. Messages that fail during connection setup or are dropped after the connection begins closing no longer affect the count.

The regression script now counts string input and keys messages only when the WebSocket is open. It increments the counter before calling the original send and returns that call’s result.

Changes: WebSocket frame counting

Layer / File(s) Summary
Qualify counted sends
scripts/newtab-typeahead-regression.ts
The send wrapper checks that the socket is open and the string message type is input or keys before incrementing sentByPage. It then calls and returns the original send result.

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

Change: Other

Possibly related PRs

Merge Risk: Minimal · up to 74d72

This is a test-only change that makes a regression script count only frames actually sent on an open socket. It does not affect production behavior, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the test now counts only frames the page sent on an open socket. It is specific, concise, and matches the summary and objectives.
Description check Passed The description follows the template's Change and Validation sections. It explains the problem (the page counter raised sentByPage before send ran, so frames discarded on CLOSING/CLOSED sockets were c…
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 follows the template's Change and Validation sections. It explains the problem (the page counter raised sentByPage before send ran, so frames discarded on CLOSING/CLOSED sockets were counted), the fix (count only OPEN-socket sends that return), and the validation commands and results. It does not link an issue, which the template asks for only for features. It also does not mention contract-test coverage, which the template asks for on HTTP/WS changes; this PR changes only a test, so that omission is minor. The changelog note is included, which matches the template's reference to changelog.d/.

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 dda4939 and 74d723a.

Files selected for processing: 1

  • scripts/newtab-typeahead-regression.ts

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

@devswha

devswha commented Nov 12, 2026

Copy link
Copy Markdown
Owner Author

Local merge gate: PASS

Local merge gate: PASS #3788 merge=6df2c9b35902 head=74d723aa38d0 main=dda493926324 on herdr-ci-runner:local on devswha-ThinkStation-P620 CPUs 64-127 in 507s, reruns=0

The Linux suites of the required checks (Fast checks, Integration and browser), run on main dda4939 with this PR's head 74d723a merged in (local merge 6df2c9b35902, not pushed), as groups side by side in the self-hosted CI runner image on herdr-ci-runner:local on devswha-ThinkStation-P620 CPUs 64-127 (24% busy before the start, host load 47.19; shards=4 unit_workers=8 browser_main_workers=2 browser_other_workers=16). Scope: full. Native Windows install and the macOS checks are not part of this gate.

Step Command Result Seconds Counts
fast-install bun install --frozen-lockfile pass 0 -
release-guards bun scripts/release-guards.ts --base dda493926324 pass 0 -
fast bun run check fast pass 168 tests 16713 pass / 0 fail; check steps 6 ok / 0 failed
integration-install bun install --frozen-lockfile pass 0 -
integration bun run check integration pass 204 tests 1431 pass / 0 fail; check steps 3 ok / 0 failed
browser-main-install bun install --frozen-lockfile pass 0 -
browser-main-build bun run build pass 10 -
browser-main BROWSER_SCRIPTS=ui-regression,ui-contexts-regression bun run check run -- bun scripts/ci-browser-parallel.ts pass 301 browser scripts 2/2 passed
browser-other-install bun install --frozen-lockfile pass 0 -
browser-other-build bun run build && bun run build:shell pass 13 -
browser-other BROWSER_EXCLUDE=<those two> bun run check run -- bun scripts/ci-browser-parallel.ts pass 476 browser scripts 207/207 passed

Total 507s.

@devswha
devswha merged commit 806ef76 into main Nov 12, 2026
11 of 12 checks passed
@devswha
devswha deleted the test/newtab-count-sent-frames branch November 12, 2026 17:50
@devswha

devswha commented Nov 12, 2026

Copy link
Copy Markdown
Owner Author

Merge pass

Merged head 74d723aa38d0 as 806ef76ad382 on the local merge gate, with no unresolved review threads.

Reviewer Verdict Note
codex CLEAR

One reviewer: test-only PR (scripts/newtab-typeahead-regression.ts).

Test-only PR (scripts/newtab-typeahead-regression.ts), so one reviewer: Codex Terra, CLEAR.

The script counted every frame the page asked to send and then waited to hear that many; a frame sent on a socket that was already closing is dropped by the browser, counted, and never heard, so the wait timed out while the text heard was right (:149; it failed twice on the mesh VMs' gate of #3787). The page now counts only frames sent on an open socket.

The merge pass gated this head with the local merge gate (its comment has the result). The VM merge gate ran beside it for comparison only.

devswha added a commit that referenced this pull request Nov 16, 2026
…d its foot is the gear alone (#3961)

## Change

The maintainer asked that a phone's workspace list not spend rows on
**Open agent inbox** and **Change PC** ("모바일의 경우 왼쪽 사이드바에 많은 줄을 차지하지
않았으면해. PC 바꾸기도 마찬가지야"). He compared three variants on a preview, then
picked the Ovis mark in the drawer's head with the gear alone at its
foot, without a Change PC icon ("pc 바꾸기 필요한가? 어차피 사이드바에 머신별로 나오는거아니야?").

On a phone (below 769px):

- **The drawer's head.** With the drawer open, the toggle's place holds
the Ovis mark (`.drawer-toggle.is-mark`, `OvisMark`) instead of the X.
It is a button named and titled **Open agent inbox**, and it opens the
inbox mode. The setup guide's shell offers no inbox, so it keeps the X.
The design follows the app mark at the head of the Codex and Claude
apps' sidebars, which is their way home.
- **The drawer's foot is the gear alone.** Neither the Open agent inbox
row nor the Change PC row is drawn there.
- **Change PC** is now the last row of Settings' page list at the
drawer's widths (`.settings-change-pc`, `DRAWER_QUERY`, below 769px),
only where the page shows one PC of a list: the phone app or the relay
shell. Getting back to the list of PCs is drawer → gear → Change PC,
three taps. The row sits under the pages and needs no scrolling at 390
(picture below). Before, Settings' Change PC was under Devices and PCs →
More → This app, five taps deep, so I put a row on the list rather than
moving it within its section. That row stays, and so does the access
gate's.
- **Closing without the X.** The drawer closes by a tap on the dimmed
pane beside it, a swipe, Back, or Escape. It also starts with **Close
workspace list** (`.drawer-close`), a named control that a screen reader
reads; it is drawn as a button only while the keyboard is on it.
- **A double tap on the menu button.** I chose a time guard over moving
the mark. The mark sits exactly where the menu button was, so a tap on
it within 400 ms of the click that opened the drawer is that double
tap's second half and does nothing. The guard compares the two clicks'
own `timeStamp`s (`SECOND_TAP_MS` in lib/useSidebarLayout.ts), so there
is no timer. I kept the mark in place because the header row over the
drawer has no other free spot: moving it would put it on the pane's
title, whose tap opens the tab list.

Wide layouts are unchanged. From 769px, the sidebar's foot still has the
phone app's or relay's Change PC row, and a collapsed sidebar's hover
peek keeps its Open agent inbox row.

Also, from the review of #3954:
- `inbox-mode-demo-regression`'s stale PASS wording is fixed.
- `sidebar-peek-demo-regression` now checks the peek's Open agent inbox
row, the only sidebar way in there.

## After the first review (second commit)

- **641-768px gap:** at those widths the drawer had no Change PC row and
Settings' list had none either, because the list's row followed the
dialog's 640px narrow width. It now follows the drawer's own width.
`drawer-modal-regression` checks it at 700px, where the row sits under
the page list beside the open page.
- **Deterministic guard test:** the guard is `secondTapOf` in
`lib/useSidebarLayout.ts`. `useSidebarLayout.hook.test.ts` drives
`toggleDrawerByButton` and `secondTapOfOpening` with fixed timestamps:
within the window, at its edge, and after a close by another way. The
browser test no longer has to rely on two real taps landing close
together.
- **Stale stamp:** the opening stamp is cleared whenever the drawer
closes.
- **Comment:** MachineSidebar's comment now says "last row".

## After GitHub's browser run (third and fourth commits)

- **The open drawer lost its disclosure state.** The X carried
`aria-controls="workspace-drawer"` and `aria-expanded="true"`. The Ovis
mark in its place opens the inbox and rightly carries neither, so with
the drawer open nothing said it was expanded. The named **Close
workspace list** carries both now.
- Four browser scripts on GitHub waited on that control:
sidebar-activity, pane-mute-captures (through pane-mute-demo-run),
workspace-touch-reorder and sidebar-agent-tree. With the attributes back
they find it again.
- The two places that tapped the old X to close the drawer
(sidebar-activity, ui-regression) tap beside it instead.
- omp-question-compat reads the drawer's `is-open` state and closes it
through the named close.
- **The double-tap check asserts or fails.** drawer-modal's double-tap
check no longer skips itself when its two taps land 400 ms or more
apart. It fails with the gap, and the guard's edges are the hook test's.

## Pictures (demo build, 390×844, dark, drawer open)

The phone app with several PCs, before and after:

<img
src="https://raw.githubusercontent.com/devswha/ovis/6d7401b437ab8c146597bdcafc9d7aff3421d553/before-app-several-pcs-390-dark.png"
width="240"> <img
src="https://raw.githubusercontent.com/devswha/ovis/6d7401b437ab8c146597bdcafc9d7aff3421d553/after-app-several-pcs-390-dark.png"
width="240">

The phone app with one PC, before and after:

<img
src="https://raw.githubusercontent.com/devswha/ovis/6d7401b437ab8c146597bdcafc9d7aff3421d553/before-app-one-pc-390-dark.png"
width="240"> <img
src="https://raw.githubusercontent.com/devswha/ovis/6d7401b437ab8c146597bdcafc9d7aff3421d553/after-app-one-pc-390-dark.png"
width="240">

A phone browser (no Change PC anywhere, as before), before and after:

<img
src="https://raw.githubusercontent.com/devswha/ovis/6d7401b437ab8c146597bdcafc9d7aff3421d553/before-browser-390-dark.png"
width="240"> <img
src="https://raw.githubusercontent.com/devswha/ovis/6d7401b437ab8c146597bdcafc9d7aff3421d553/after-browser-390-dark.png"
width="240">

The gear's Settings in the phone app, before and after: Change PC at the
end of the list.

<img
src="https://raw.githubusercontent.com/devswha/ovis/6d7401b437ab8c146597bdcafc9d7aff3421d553/before-app-several-pcs-settings-390-dark.png"
width="240"> <img
src="https://raw.githubusercontent.com/devswha/ovis/6d7401b437ab8c146597bdcafc9d7aff3421d553/after-app-several-pcs-settings-390-dark.png"
width="240">

The phone app is a stand-in `window.Capacitor` on the demo build, the
same one the new test uses.

## Validation

On cc19360 (the fourth commit):
- `bun run check fast`: exit 0, every step ok (unit tests 538.3 s).
- In the CI runner image, every lane script that uses the drawer's
`aria-controls` or pane-mute-demo-run passed: herdr-profiles,
pane-mute-captures, pane-mute, phone-worktree-sheet, recent-folders,
sidebar-activity, sidebar-agent-tree, workspace-touch-reorder and
drawer-modal. ui-regression failed in that batch, at its desktop reorder
step (line 1788, after the drawer step it changes at line 588, which ran
and passed). Alone it failed once more, on a different step (a split's
route handled twice). Then side by side it passed, on this head and on
main.

On the second commit (64c84a2):
- `bun run check fast`: exit 0, every step ok (unit tests 519.5 s). This
includes the new `useSidebarLayout.hook.test.ts` case.
- In the CI runner image: drawer-modal (with the 700px check),
settings-pages, phone-back and inbox-mode passed, 4/4 in 110.8 s.

On the first commit (7a889c9):
- `bun run check fast` (TMPDIR under ~/.cache/ovis-tmp, heavy slot) on
the pushed head: exit 0. Every step ok: workflow syntax, generated types
and themes, typecheck, build, unit tests (542.8 s). An earlier run
caught App.tsx going one hook over `app-hooks.test.ts`'s ceiling, so the
double-tap stamp moved into `lib/useSidebarLayout.ts`.
- `scripts/drawer-modal-regression.ts` (extended), run locally and in
the CI runner image:
- the open drawer's head is the mark (named and titled Open agent inbox,
no `aria-expanded`);
- the drawer holds the named close, and its foot is the gear's row
alone;
- it closes by a tap outside, Back (staying on the pane), Escape, a
swipe, and the named close reached by Tab (drawn while focused, focus
back to the toggle);
- a double tap on the menu button (the two clicks' timeStamps 132-148 ms
apart) opens the drawer and not the inbox, and a tap past 400 ms (waited
for on `performance.now()` against that click's timeStamp, no sleep)
opens the inbox;
- with a stand-in phone app, the drawer has no Change PC row, the gear's
Settings list ends in Change PC, which calls `HerdrShell.disconnect`,
and a 1440 window keeps its Change PC row.
- In the CI runner image (`herdr-ci-runner:local`, `heavy-run.sh`,
ci.yml's `ci-browser-parallel.ts` step with `BROWSER_SCRIPTS` and
`BROWSER_RETRY=0`), these passed, 19/19 in 513.6 s: drawer-modal,
phone-back, sidebar-declutter, sidebar-filter, render-crash, pc-load,
deep-link, workspace-rows, tap-targets, agent-state-groups,
sidebar-machine-layout, sidebar-spacing, phone-safe-area,
terminal-autoswitch, settings-pages, sidebar-peek, sidebar-split,
setup-row and hide-pc. These passed too: ui-regression,
ui-contexts-layout, and the three inbox-mode scripts.
- `ui-contexts-regression`: three failures, then two passes, all on the
branch's head.
- The three failures were all in `newtab-typeahead-regression.ts`'s
frame count: "the page's frames for the new tab are all heard". The
typed text was heard intact each time, in its touch case twice and its
dialog case once. Three of the script's last five commits worked on that
comparison (#3691, #3713, #3788).
- Then on the pushed head it passed twice, and origin/main (bcc55ef)
passed three times, all alone in their own slots.
- This change sends no terminal frames. I count it as that known flake,
not a regression.
- Scripts that closed the drawer by its X (deep-link, pc-load,
sidebar-filter, render-crash, sidebar-declutter, workspace-rows) now tap
outside it or wait on `#workspace-drawer.is-open`. inbox-mode's drawer
block enters by the mark, past the double-tap window.
- `sidebar-peek-demo-regression` (new check, from #3954's review):
passes light and dark, locally and in the image.
- Not run: `bun run check full`, the integration lane, Windows, macOS,
and a real iOS/Android app (the app is a `window.Capacitor` stand-in).
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