Skip to content

Cover window promotion across chromium restarts - #505

Merged
robertjamesprior merged 2 commits into
mainfrom
hypeship/window-promotion-restart-test
Nov 6, 2026
Merged

robertjamesprior merged 2 commits into
mainfrom
hypeship/window-promotion-restart-test

Conversation

@robertjamesprior

@robertjamesprior robertjamesprior commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds the missing coverage that the window is promoted again on a chromium restart, not just once at boot: a restart produces a new devtools upstream URL, and promoteWindowsLoop must promote that URL too.

Why

Promotion is keyed on the upstream URL changing, so the restart path is the whole mechanism for a browser that restarts mid-session — a profile load onto a warm browser, or a crash. A window left in normal state by a restart is exactly the state a --window-size chromium starts in, so a regression here puts the window back to a partially covered desktop without any client involvement.

The existing tests cover promoteWindowMaximized against a single URL (happy path, refused dial, dropped transport). Nothing covered the loop reacting to a second URL.

Changes

  • newPromotionServiceForLog splits the log-writing step out of newPromotionService, so a test can keep appending to the log and signal a restart the way supervisord does. newPromotionService keeps its signature.
  • fakeDevTools.maximizedCalls reads the counter the way the other assertions do.
  • New test starts the loop against a first URL, appends a second URL to the log, and asserts each fake is maximized exactly once.

Testing

  • go test ./cmd/api/api/ passes
  • go build ./... clean
  • Note: gofmt -l flags this file on main as well, on the fakeDevTools counter fields, which this change does not touch. Left as-is to keep the diff scoped.

Note

Low Risk
Test-only changes with no production or security impact; low risk of false positives if loop timing flakiness appears in CI.

Overview
Adds regression coverage for promoteWindowsLoop when Chromium restarts (new DevTools URL in the supervisord-style log). The test boots the loop on a first URL, appends a second listening line, and asserts each fake DevTools endpoint is asked to maximize exactly once—including an immediate promotion for the URL already current at loop start.

Test helpers: newPromotionService now delegates to newPromotionServiceForLog so callers can own the log file and append restart lines; fakeDevTools.maximizedCalls() exposes the maximize counter for assertions.

Reviewed by Cursor Bugbot for commit 25364f6. Bugbot is set up for automated code reviews on this repo. Configure here.

robertjamesprior and others added 2 commits November 6, 2026 04:23
The trailing Equal ran immediately after the Eventually that already
waited for exactly one call, so it could only catch a duplicate that
landed in the gap between them. Never gives it a real settle window, and
covers the first url not being promoted again after it is replaced.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@robertjamesprior
robertjamesprior marked this pull request as ready for review November 6, 2026 17:31
@robertjamesprior

Copy link
Copy Markdown
Contributor Author

Picked chruffins to review: reviewed the related window-promotion restart and reconnection paths in #503.

@chruffins chruffins left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the head commit. The new test covers promotion on a second devtools URL, and it fails when the loop ignores restart notifications. Ran it under -race (30x), the full server unit suite, and vet. No issues found.

@robertjamesprior
robertjamesprior merged commit 1af94b1 into main Nov 6, 2026
12 checks passed
@robertjamesprior
robertjamesprior deleted the hypeship/window-promotion-restart-test branch November 6, 2026 17:43
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.

2 participants