Repository navigation
fix(chat): clear the chat position save timer without the window (main red) - #4349
Conversation
…as set on A save that came due after the window was gone (a test's afterEach deleting its window stub) threw 'window is not defined' between tests, failing ChatView.scrollInput.test.tsx on main (CI run 44778206654).
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 2 minutes. View limit details
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. |
The gate review found the test cleared timer ID 1 in the test process and deleted any window that was there before; it now clears a timer it created and restores the original window descriptor.
|
Merged through CodeRabbit skipped this PR. Reviews of record: omo review (dori review) CLEAR at 980ea33 (the production change is unchanged since); omo gate reviewer (GPT-6.2 Astra) BLOCK at 980ea33 on two test-isolation MEDIUMs, fixed in 4c724b1, then CLEAR at 4c724b1. Main-red fix, merged by lane main-red under the brief's merge override. One unrelated browser flake (relay-dashboard-browser-qa pair-dialog-name-390) needed a rerun; recorded on #4026. |
…s opened what it opens (#4365) ## Summary `scripts/relay-dashboard-browser-qa.ts` failed once and passed on the retry in two CI runs (a FLAKY script fails the lane): `pair-dialog-name-390` (PR #4349, run 44789770257) and `details-forget-unlisted-last-390` (main d6a1e2c, run 44799381849), both with ``` reload: net::ERR_ABORTED; maybe frame was detached? ``` Closes #4358. ## Cause `open()` signs in, waits for the account key's commit (`data-qa-account-key-committed`), seeds pairings and reloads. The sign-in's return keeps going after that commit: once `account.load` resolves, `mountRelayShell` runs `showFront()` again with `signedInNow`, which reads the saved PCs and opens the last one by itself (`launchPc(..., signedIn)`). When the seeding landed before that read, the shell navigated to a seeded PC and that navigation aborted the test's reload. Only checks that open a fleet with seeds can hit it (FREADY in both CI failures). ## Fix - `src/lib/relay/boot.ts`: once `mountRelayShell` resolves (the entry read to the end, a sign-in's return included), boot marks the container `data-relay-shell="mounted"`. No behaviour changes. - `open()` waits for that marker before seeding, so the shell's own open-a-PC decision is made on the PCs it had, and nothing navigates under the reload. - Two boot unit tests pass a stub container; it now has a `dataset`, as a real container does. ## Validation - `scripts/relay-dashboard-browser-qa.ts` in the CI runner image on hosthatch, 4 at a time: 20/20 passed. - Same script locally, 6 at a time under load: 18/18 passed. - `bun test src/lib/relay/`: 564 pass, 0 fail. - `bun run check fast`: all steps ok, unit 21,066 pass, 0 fail. - Gate reviewer (omo, GPT-6.2 Astra): CLEAR at e2cbc1d; it reproduced the competing navigation in Chromium (seeding before a delayed devices read made the shell navigate to `/s/<seeded-pc>/` with no click on the old order, none with the wait), and ran 10/10 browser checks including both reported failures. - Not reproduced on demand here: holding `/v1/pcs` to widen the window also holds the dashboard the test waits for before seeding, so the cause is from the code path above plus the two CI logs.
Summary
main is red since CI run 44778206654 (40b79ff):
src/components/ChatView.scrollInput.test.tsxpassed all 14 tests but bun reported 1 unhandled error between tests:rememberChatPositionschedules a 250 ms save withwindow.setTimeout. When the save came due after the test'safterEachhad removed itswindowstub,save()calledwindow.clearTimeoutand threw. This was a timing flake in place since 7e0ee08 (2026-11-09), not a regression from #4335; the previous 14 main CI runs were green.Fix
save()clears the timer with the globalclearTimeout(the same function the window exposes), so a save that runs after the window is gone writes nothing and does not throw.Test
src/lib/chatScrollMemory.test.tsgets one test that does not depend on timing: it captures the scheduled save, removeswindow, then runs the save. On origin/main it fails with the sameReferenceError; with the fix it passes.Validation
bun test src/lib/chatScrollMemory.test.ts src/components/ChatView.scrollInput.test.tsx: 25 pass, 0 fail (and the new test fails on origin/main without the fix).bun run check fast(local, P620): all steps ok, unit 20814 pass, 0 fail.