Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion browser_use/browser/watchdogs/storage_state_watchdog.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from browser_use.browser.events import (
BrowserConnectedEvent,
BrowserStopEvent,
LoadStorageStateEvent,
SaveStorageStateEvent,
StorageStateLoadedEvent,
Expand All @@ -26,6 +27,7 @@ class StorageStateWatchdog(BaseWatchdog):
# Event contracts
LISTENS_TO: ClassVar[list[type[BaseEvent]]] = [
BrowserConnectedEvent,
BrowserStopEvent,
SaveStorageStateEvent,
LoadStorageStateEvent,
]
Expand All @@ -51,7 +53,12 @@ async def on_BrowserConnectedEvent(self, event: BrowserConnectedEvent) -> None:
await self._start_monitoring()

# Automatically load storage state after browser start
self.event_bus.dispatch(LoadStorageStateEvent())
await self.event_bus.dispatch(LoadStorageStateEvent())

async def on_BrowserStopEvent(self, event: BrowserStopEvent) -> None:
"""Stop monitoring when browser stops."""
self.logger.debug('[StorageStateWatchdog] Stopping storage_state monitoring')
await self._stop_monitoring()

async def on_SaveStorageStateEvent(self, event: SaveStorageStateEvent) -> None:
"""Handle storage state save request."""
Expand Down
Loading