Skip to content

feat: don't close new opened tabs #161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

arunpatro
Copy link
Contributor

@arunpatro arunpatro commented Jul 22, 2025

Address Feature Parity from JS -> Python: #131

why

what changed

test plan

- Add live page proxy that dynamically tracks the focused page
- Implement context event listener to initialize new pages automatically
- Remove automatic tab closing behavior in act_handler_utils and cua_handler
- Keep both original and new tabs open when new pages are created
- Ensure stagehand.page always references the current active page

This implementation matches the behavior of browserbase/stagehand#844
@arunpatro arunpatro changed the title feat: port new page handling from JS Stagehand PR #844 feat: don't close new opened tabs Jul 22, 2025
@miguelg719
Copy link
Collaborator

this will close #131

@miguelg719 miguelg719 changed the base branch from main to contrib/161 July 25, 2025 04:50
@miguelg719 miguelg719 merged commit 78525a7 into browserbase:contrib/161 Jul 26, 2025
miguelg719 added a commit that referenced this pull request Aug 9, 2025
* feat: don't close new opened tabs (#161)

* feat: port new page handling from JS Stagehand PR #844

- Add live page proxy that dynamically tracks the focused page
- Implement context event listener to initialize new pages automatically
- Remove automatic tab closing behavior in act_handler_utils and cua_handler
- Keep both original and new tabs open when new pages are created
- Ensure stagehand.page always references the current active page

This implementation matches the behavior of browserbase/stagehand#844

* Update stagehand/handlers/cua_handler.py

* Update stagehand/handlers/act_handler_utils.py

---------

Co-authored-by: Arun Patro <[email protected]>
Co-authored-by: Miguel <[email protected]>

* formatting, logs

* changeset

* fix: update mock_stagehand_client fixture to set internal page properties

The page property is now read-only (returns LivePageProxy), so tests need to set the internal _original_page and _active_page properties instead

* feat: add page stability check to LivePageProxy for async operations

Ensures async operations wait for any pending page switches to complete

* formatting

* fix: prevent deadlock in page navigation and add page stability tests

- Initialize _page_switch_lock in Stagehand constructor
- Skip page stability check for navigation methods (goto, reload, go_back, go_forward)
- Use lock when switching active pages in context
- Add comprehensive tests for LivePageProxy functionality

* consolidate original and active page to just one page

* Update stagehand/context.py

* Update .changeset/gorilla-of-strongest-novelty.md

* timeouts

* python 3.10 or less compatibility

---------

Co-authored-by: Arun Patro <[email protected]>
Co-authored-by: Arun Patro <[email protected]>
Co-authored-by: Filip Michalsky <[email protected]>
@github-actions github-actions bot mentioned this pull request Aug 9, 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.

2 participants