Skip to content

fix active page handling - #2458

Merged
seanmcguire12 merged 2 commits into
v4-spikefrom
fix-multi-tab-handling
Jul 27, 2026
Merged

seanmcguire12 merged 2 commits into
v4-spikefrom
fix-multi-tab-handling

Conversation

@seanmcguire12

@seanmcguire12 seanmcguire12 commented Jul 27, 2026

Copy link
Copy Markdown
Member

why

  • when new tabs were opened via a popup, chromeTabs.activeTargetId() was pointing to the correct target ID, but stagehand didn't have time to register that target in its registry
  • this caused lookup to fail, and activePage() to return undefined

what changed

  • added polling with a max of 3 seconds inside activePage()

test plan

  • added tests for delayed page registration

Summary by cubic

Fixes a race where popups activated by user gesture were not returned by activePage(). The method now polls for up to 3s for Chrome’s active target to be registered and throws a clear timeout if it never is.

  • Bug Fixes
    • V3Context.activePage() polls until the active target’s Page is registered; returns undefined when Chrome has no active target; throws a TimeoutError after 3s if never registered.
    • Added tests for delayed registration, no-active-target, and timeout; updated the SDK smoke test to use context.activePage() and removed the custom waitForNewPage helper.

Written for commit 7361091. Summary will update on new commits.

Review in cubic

@changeset-bot

changeset-bot Bot commented Jul 27, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 7361091

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@seanmcguire12
seanmcguire12 merged commit 66739a2 into v4-spike Jul 27, 2026
10 checks passed
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