Skip to content

The agent that grows with you

fix(browser): pass encoding to detector subprocesses and accept local_browser in test spies

Jan-Stefan Janetzkyc41562cf0ef2
diff --git a/hermes_cli/browser_connect.py b/hermes_cli/browser_connect.py
index c3f2657d2bb..25e4a5d91b6 100644
--- a/hermes_cli/browser_connect.py
+++ b/hermes_cli/browser_connect.py
@@ -250,7 +250,14 @@ def _detect_default_darwin() -> str | None:
["defaults", "read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"],
):
try:
- out = subprocess.run(reader, capture_output=True, text=True, timeout=5).stdout.lower()
+ out = subprocess.run(
+ reader,
+ capture_output=True,
+ text=True,
+ encoding="utf-8",
+ errors="replace",
+ timeout=5,
+ ).stdout.lower()
except Exception:
out = ""
for frag, browser in _DARWIN_BUNDLE_MAP:
@@ -267,7 +274,11 @@ def _detect_default_linux() -> str | None:
try:
out = subprocess.run(
["xdg-settings", "get", "default-web-browser"],
- capture_output=True, text=True, timeout=5,
+ capture_output=True,
+ text=True,
+ encoding="utf-8",
+ errors="replace",
+ timeout=5,
).stdout.strip().lower()
except Exception:
out = ""
diff --git a/tests/tools/test_browser_extension_router_wiring.py b/tests/tools/test_browser_extension_router_wiring.py
index bbdd4bf1bec..8fb7e628692 100644
--- a/tests/tools/test_browser_extension_router_wiring.py
+++ b/tests/tools/test_browser_extension_router_wiring.py
@@ -36,7 +36,11 @@ def _route_spy(monkeypatch):
monkeypatch.setattr(browser_tool, "routed_browser_handler", spy)
monkeypatch.setattr(browser_cdp_tool, "routed_browser_handler", spy)
- monkeypatch.setattr(browser_tool, "browser_navigate", lambda url="", task_id=None: "legacy-nav")
+ monkeypatch.setattr(
+ browser_tool,
+ "browser_navigate",
+ lambda url="", task_id=None, local_browser=False: "legacy-nav",
+ )
monkeypatch.setattr(browser_cdp_tool, "browser_cdp", lambda *a, **k: "legacy-cdp")
return calls
diff --git a/tests/tools/test_browser_open_timeout.py b/tests/tools/test_browser_open_timeout.py
index 6d791ee2823..570f8f9b6ac 100644
--- a/tests/tools/test_browser_open_timeout.py
+++ b/tests/tools/test_browser_open_timeout.py
@@ -96,7 +96,9 @@ class TestBrowserNavigateOpenTimeout:
monkeypatch.setattr(bt, "_is_camofox_mode", lambda: False)
monkeypatch.setattr(bt, "_is_local_backend", lambda: True)
monkeypatch.setattr(bt, "_is_local_sidecar_key", lambda key: False)
- monkeypatch.setattr(bt, "_navigation_session_key", lambda task_id, url: task_id)
+ monkeypatch.setattr(
+ bt, "_navigation_session_key", lambda task_id, url, local_browser=False: task_id
+ )
monkeypatch.setattr(bt, "_maybe_start_recording", lambda *a, **kw: None)
monkeypatch.setattr(bt, "check_website_access", lambda url: None)