Skip to content

Conversation

@shrey150
Copy link
Contributor

@shrey150 shrey150 commented Dec 18, 2025

Why

When a page closes (e.g., splash screen during auth), get_active_page() still returns the closed page instead of switching to a remaining open page.

What Changed

Added _handle_page_close() in context.py to switch active page to a remaining open page when the current active page closes.

Test Plan

Verified with multi-page script: open two pages, close active page, confirm get_active_page() returns remaining open page. Existing unit tests pass.


Summary by cubic

Fixes stale active page after a page closes. When the active page closes (e.g., splash during auth), we now switch to a remaining open page or clear the active page.

  • Bug Fixes
    • Added _handle_page_close to update the active page on close events.
    • Uses the page switch lock to avoid race conditions; 30s timeout with error logging.
    • Wired to Playwright's page "close" event; also unregisters frame IDs.
    • get_active_page() now returns the correct remaining page (or None if none remain).

Written for commit a7cb745. Summary will update automatically on new commits.

@shrey150 shrey150 requested a review from miguelg719 December 18, 2025 22:02
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

Copy link
Contributor Author

shrey150 commented Dec 18, 2025

Merge activity

  • Dec 18, 10:26 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Dec 18, 10:26 PM UTC: @shrey150 merged this pull request with Graphite.

@shrey150 shrey150 merged commit d61e118 into main Dec 18, 2025
11 of 14 checks passed
shrey150 added a commit that referenced this pull request Dec 19, 2025
<!-- This is an auto-generated description by cubic. -->
## Summary by cubic
Prepare a patch release to ship the active page context fix. Adds a changeset for stagehand to bump the version.

<sup>Written for commit f81b4bd. Summary will update automatically on new commits.</sup>

<!-- End of auto-generated description by cubic. -->
@github-actions github-actions bot mentioned this pull request Dec 19, 2025
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.

3 participants