fix(desktop): guard document at settle entry; pin rotation in concurrent test

Blind-review round 14 (Opus medium) P3s:

- settleChannelSwitchTrace guarded window but then read document
  (visibilityState, querySelector) unguarded — the document guard in
  ensureVisibilityWatcher was dead protection. The settle entry gate now
  covers both globals.
- The concurrent boundary test folded the rotated generation in behind
  if-let, so a regression where rotation never fires under contention
  would pass green with all 32 lines in the live file. The read is now
  unconditional, and the boundary comment's arithmetic is corrected
  (rotation triggers before the 23rd append).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Max Lampert <maxwell@squareup.com>
This commit is contained in:
Max Lampert
2026-08-25 02:00:20 -07:00
parent e0f4768ec7
commit 83eb45c8ee
2 changed files with 15 additions and 8 deletions

View File

@@ -416,7 +416,9 @@ export function settleChannelSwitchTrace(channelId: string): void {
return;
}
const trace = settledTrace;
if (typeof window === "undefined") {
// Both globals gate the whole settle path: the wait loop reads
// document.visibilityState and querySelector unguarded past this point.
if (typeof window === "undefined" || typeof document === "undefined") {
activeTrace = null;
return;
}