Skip to content

fix(chat): clear the chat position save timer without the window (main red) - #4349

Merged
devswha merged 2 commits into
mainfrom
fix/chat-scroll-save-timer
Nov 20, 2026
Merged

devswha merged 2 commits into
mainfrom
fix/chat-scroll-save-timer

Conversation

@devswha

@devswha devswha commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Summary

main is red since CI run 44778206654 (40b79ff): src/components/ChatView.scrollInput.test.tsx passed all 14 tests but bun reported 1 unhandled error between tests:

ReferenceError: window is not defined
      at save (src/lib/chatScrollMemory.ts:71:29)

rememberChatPosition schedules a 250 ms save with window.setTimeout. When the save came due after the test's afterEach had removed its window stub, save() called window.clearTimeout and 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 global clearTimeout (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.ts gets one test that does not depend on timing: it captures the scheduled save, removes window, then runs the save. On origin/main it fails with the same ReferenceError; 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.
  • No changelog fragment: users won't notice the change.

…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).
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used all 8 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 40b79ff and 4c724b1.

Files selected for processing: 2

  • src/lib/chatScrollMemory.test.ts
  • src/lib/chatScrollMemory.ts
  • 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

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.
@devswha
devswha merged commit 5cc9726 into main Nov 20, 2026
25 of 27 checks passed
@devswha

devswha commented Nov 20, 2026

Copy link
Copy Markdown
Owner Author

Merged through pr-merge at head 4c724b1f5. 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.

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.

@devswha
devswha deleted the fix/chat-scroll-save-timer branch November 20, 2026 18:49
devswha added a commit that referenced this pull request Nov 20, 2026
…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.
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