Skip to content

Commit be49fea

Browse files
authored
Merge branch 'main' into restructure-examples-docs
2 parents 4356f65 + 7b3cbc6 commit be49fea

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

browser_use/agent/service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@ async def take_step(self, step_info: AgentStepInfo | None = None) -> tuple[bool,
13121312
Returns:
13131313
Tuple[bool, bool]: (is_done, is_valid)
13141314
"""
1315-
if len(self.history.history) == 0:
1315+
if step_info is not None and step_info.step_number == 0:
13161316
# First step
13171317
self._log_first_step_startup()
13181318
await self._execute_initial_actions()

browser_use/browser/watchdogs/downloads_watchdog.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
from browser_use.browser.events import (
1818
BrowserLaunchEvent,
19+
BrowserStateRequestEvent,
1920
BrowserStoppedEvent,
2021
FileDownloadedEvent,
2122
NavigationCompleteEvent,
@@ -34,6 +35,7 @@ class DownloadsWatchdog(BaseWatchdog):
3435
# Events this watchdog listens to (for documentation)
3536
LISTENS_TO: ClassVar[list[type[BaseEvent[Any]]]] = [
3637
BrowserLaunchEvent,
38+
BrowserStateRequestEvent,
3739
BrowserStoppedEvent,
3840
TabCreatedEvent,
3941
TabClosedEvent,
@@ -81,6 +83,26 @@ async def on_TabClosedEvent(self, event: TabClosedEvent) -> None:
8183
"""Stop monitoring closed tabs."""
8284
pass # No cleanup needed, browser context handles target lifecycle
8385

86+
async def on_BrowserStateRequestEvent(self, event: BrowserStateRequestEvent) -> None:
87+
"""Handle browser state request events."""
88+
cdp_session = self.browser_session.agent_focus
89+
if not cdp_session:
90+
return
91+
92+
url = await self.browser_session.get_current_page_url()
93+
if not url:
94+
return
95+
96+
target_id = cdp_session.target_id
97+
self.event_bus.dispatch(
98+
NavigationCompleteEvent(
99+
event_type='NavigationCompleteEvent',
100+
url=url,
101+
target_id=target_id,
102+
event_parent_id=event.event_id,
103+
)
104+
)
105+
84106
async def on_BrowserStoppedEvent(self, event: BrowserStoppedEvent) -> None:
85107
"""Clean up when browser stops."""
86108
# Cancel all CDP event handler tasks

browser_use/dom/serializer/serializer.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,6 @@ def _is_interactive_cached(self, node: EnhancedDOMTreeNode) -> bool:
127127
def _create_simplified_tree(self, node: EnhancedDOMTreeNode, depth: int = 0) -> SimplifiedNode | None:
128128
"""Step 1: Create a simplified tree with enhanced element detection."""
129129

130-
# Prevent infinite recursion by limiting depth to 30 levels
131-
if depth > 30:
132-
return None
133-
134130
if node.node_type == NodeType.DOCUMENT_NODE:
135131
# for all cldren including shadow roots
136132
for child in node.children_and_shadow_roots:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "browser-use"
33
description = "Make websites accessible for AI agents"
44
authors = [{ name = "Gregor Zunic" }]
5-
version = "0.7.5"
5+
version = "0.7.6"
66
readme = "README.md"
77
requires-python = ">=3.11,<4.0"
88
classifiers = [

0 commit comments

Comments
 (0)