fix active page handling
Merged
SE
3mo ago+54+54+01234567890123456789-20-20-01234567890123456789
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.