Repository navigation
test(scripts): settle four flaky browser checks on what they test - #2632
Conversation
- chat-local-send-follow: a wheel notch away from the end is measured as the distance from the end. LegendList keeps the reader's rows in place as rows above the view are measured, which can undo a notch's move in scrollTop (traced: scrollBy(+103) with scrollHeight +103, the distance from the end unchanged). - file-viewer: transcript links right after a reload, a goto or a panel closing are activated where they are, as the script's own header asks; the framed page's table-of-contents click is dispatched to its link. - files-prompt: the Escape after a pane switch stays, and its failure now writes what decided it (keydown probe, focus, modal stack, FilesDialog's stand-down state) to the log and evidence (#2631). - relay-media: Copy link is clicked on the button, not at where a forced click aims.
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
|
Test-only fix for four browser scripts that rotated failures across main's CI runs (lane browser-flakes; no product code). Merge-pass read of the whole diff:
Each script ran 20+ times in a row under load on the lane's side; omo approved (LOW only). A test-only change gets no CodeRabbit round; it merges on its checks. |
…#3026) Fixes #2631 ## Cause The `files-prompt-regression.ts` Escape flake is a product bug. The diagnostics added in #2632 caught it 5 times on CI since then (runs 41935003970, 41942082835, 41959283541, 41980051339, 41985349024). Every time, the Escape reached `window` in the capture and bubble phases, focus was on `body`, no file viewer, diff or native modal was open, and Files stayed open. A local run with an init script that logs every window `keydown` listener add, remove and call showed what happened in the stuck rounds: 1. `useSplitView`'s bubble listener `cancel` (registered at startup, so before FilesDialog's) runs first and calls `clearDropPreview()`, which sets `paneDragging` and `dropAt` state. 2. When React does not bail out of that set, the microtask after that listener renders App before the next listener runs. 3. FilesDialog's `onClose` is an inline arrow in App, so its effect (`[onClose, viewing, docked]`) removes its window listener and adds a new one during that render. 4. A listener removed during dispatch is skipped, and one added during it is not called, so FilesDialog never sees that Escape. In the log: FilesDialog's listener was attached at 1430.9 ms, `cancel` ran at 1542.8 ms, then FilesDialog's listener was removed at 1550.1 ms and re-added at 1550.3 ms, with no call in between. ## Change - `FilesDialog` reads its latest props (`onClose`, `docked`) through `useEffectEvent`. Its window listener now changes only with `viewing`, so a render inside the same key press no longer swaps it out. - With the listener in place, Files also stands down when the focus is in another modal, and when another dialog already took the key (`preventDefault`). Each Escape closes one dialog, the one holding the keyboard, as main did. Without this, opening Settings with Files open and pressing Escape once closed both (review finding, reproduced). - `files-prompt-regression.ts` (desktop) adds a deterministic step. Files is reopened, and a pane `dragstart` shows the split guide, so the next Escape's `clearDropPreview` is a real state change and always re-renders App inside the key press. Escape must then put away both the guide and Files. A second step opens Settings over Files with its shortcut: one Escape must close Settings alone, the next Files. ## Validation - Review round (omo + Codex MEDIUM: one Escape closed Files and Settings together). A throwaway probe, 8 rounds per order at 1280 px: main left Files open after one Escape in both orders (Files over Settings, and Settings opened over Files). The first head closed both, 16/16. This head leaves Files open in both orders, 16/16, matching main. The new Settings step fails on the first head ("one Escape closed both Settings and Files") and passes now. - Failing first: with the new step and no product change, `bun run check run --build bun scripts/files-prompt-regression.ts` failed at that step (`.files-dialog` still visible after the split guide went away). With the fix, 8/8 scenarios pass. - Local stress repro (throwaway, instrumented script, Node PTY host, same flow as the check on fresh pages): 23 stuck out of 98 rounds before the fix, 0 out of 100 after. - `bun run check fast` on the merged head b7d3e06: success (typecheck, build, 12212 unit tests, 0 failures). - Browser regressions, `bun run check run` (files-prompt on b7d3e06, the rest on the round's commit before the last main merge, which touched FilesDialog only in #3028's Changes scope): `files-prompt-regression`, `files-panel-demo-regression`, `diff-find-demo-regression`, `diff-line-notes-demo-regression`, `deep-link-demo-regression`, `file-viewer-regression`, `ui-regression`, all passing. - Skipped: `bun run check full`, Windows VM, Mac. No UI change, so no screenshots. --------- Co-authored-by: sisyphus-dev-ai <[email protected]>
Change
Four browser scripts failed now and then in "Browser regression (other scripts)" on main (run 41558343287 on c0cdc8e, and later runs). The take-over failure was a product race, fixed in #2630. This PR fixes the other three, plus the relay-media failure seen on bef2be1. Test-only: no product code changes.
chat-local-send-follow-demo-regression.ts:95: "the reader moves away"wheelUpwaited for each wheel notch to lowerscrollTopby more than 20 px. A write trace on the page showed every notch moving the view 120 px. Then, as a row above the view was measured, LegendList'sScrollAdjustcalledscrollBy(+103)to keep the reader's rows in place, withscrollHeightgrowing by the same 103 px. That undid the notch inscrollTop, but the distance from the end stayed exactly 600 px before and after. The reader had moved away; the wait could not see it. The wait now measures the distance from the end, which that adjustment leaves alone.Not a #2624 regression. An A/B of the unmodified script, alternating commits under
dori heavy, gave passes/runs of: 05c9133 (before #2624) 5/7, 9ef34f8 (#2624) 5/6, main 2/6. The step fails before #2624 too; #2624 changes when rows get measured, so it lands more often. NoscrollToEndor follow write appears in the trace.file-viewer-regression.ts: "video not visible"The CI failure came right after
setFileOpen("panel")reloads the page:videoLink.click()was a pointer click on a transcript link while the reloaded chat followed to its end, so the click landed on nothing and no popup opened (0 "locator resolved" lines on CI and locally). The script's own header comment describes this trap, and its other steps already useactivateInTranscript. Under load, three more steps hit the same trap: after agoto(big code), after the panel closes (the extensionless and unknown-text loop, which keeps the link focused so the focus-return assertion still holds), and after a reload and Back at 390 px. The click on the framed page's table-of-contents link is dispatched to the link: the frame's own navigation is under test, not where the panel lays the frame out.files-prompt-regression.ts:71: Escape left Files open after a pane switchNot reproduced in about 435 local attempts (15 per run, fresh pages, 6x CPU throttle, load up to 92), and nothing found by reading the code. The Escape check stays: it is the only place a script checks Escape closing Files. When it fails now, the script writes what decided it to the log and to
files-<page>-escape-diagnostics.jsonin the browser-evidence artifact: whether a window keydown probe saw the key, the focused element, the modal and dialog stack, whether FilesDialog stood down (file or diff over it, native modal), and any open picker. Tracked as #2631.relay-media-browser-qa.ts:44: "Timed out: copied-link clipboard event"Seen inside
relay-e2e-regression.tson bef2be1 (run 41568570526). The stubbedwriteTextalways resolves, so the click never reached Copy link.copy.click({ force: true })is aimed at where the button was, under a frozen browser clock, while the viewer may still move it. The click is now dispatched to the button itself; the clipboard listener is still subscribed before it.Validation
All runs went through
dori heavy; host load ranged from about 4 to 92 (70 CPU hogs for part of it).bun run check run, isolated herdr session). Earlier rounds under load caught the other lost-click steps fixed here.bun run check fast: success on 6069b0a. An earlier run caught a regression in this branch:ci-browser.test.tsforbids??on evidence dirs (The browser lane loses its evidence folder before omo-plan-browser-regression in bun run check full #1554). Fixed with||.activateInTranscriptwaits for a frame that section lacks; thewheelUpcallers assert the distance afterwards.No changelog fragment: test-only.