The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(bot-screen): a headless-shell AGENT_BROWSER_EXECUTABLE_PATH is not a headed browser
teknium125b5a4884c7b
diff --git a/tests/tools/test_bot_desktop_browser.py b/tests/tools/test_bot_desktop_browser.pyindex 5fdde7de366..dc1313730a9 100644--- a/tests/tools/test_bot_desktop_browser.py+++ b/tests/tools/test_bot_desktop_browser.py@@ -170,3 +170,21 @@ def test_dock_exec_line_survives_spaces_in_the_executable_and_profile_paths():assert line.startswith('Exec="/opt/Google Chrome/chrome" ')assert r'"--user-data-dir=/home/a b/.hermes/browser \\"x\\"/profile"' in line # spec: \" quoted, then \ string-escapedassert "--remote-debugging-port=0" in line+++def test_headless_shell_override_is_not_a_headed_browser(tmp_path, monkeypatch):+ """The official Docker image ships only Playwright's chrome-headless-shell and its boot hook exports it+ as AGENT_BROWSER_EXECUTABLE_PATH. That binary cannot open a window: taken at face value the dock's+ Browser icon would point at it and status would claim a headed browser exists. Live in the image:+ status.browser named the headless shell while the dock had no working Browser."""+ shell = tmp_path / "shell" / "chromium_headless_shell-1243" / "chrome-headless-shell-linux64" / "chrome-headless-shell"+ shell.parent.mkdir(parents=True)+ shell.write_text("#!/bin/sh\n", encoding="utf-8")+ shell.chmod(0o755)+ _install_browsers(tmp_path, monkeypatch, playwright=False, system=False)+ monkeypatch.setenv("AGENT_BROWSER_EXECUTABLE_PATH", str(shell))+ assert browser.executable() is None++ _, sys_exe = _install_browsers(tmp_path / "with-sys", monkeypatch, playwright=False, system=True)+ monkeypatch.setenv("AGENT_BROWSER_EXECUTABLE_PATH", str(shell))+ assert browser.executable() == sys_exe # a real headed browser elsewhere still wins over the overridediff --git a/tools/bot_desktop/browser.py b/tools/bot_desktop/browser.pyindex f92ea87fa9c..161942e3b44 100644--- a/tools/bot_desktop/browser.py+++ b/tools/bot_desktop/browser.py@@ -41,7 +41,7 @@ def executable() -> Optional[str]:icon that fails loudly beats a non-root ``--no-sandbox``."""explicit = os.environ.get("AGENT_BROWSER_EXECUTABLE_PATH", "").strip()- if explicit and os.access(explicit, os.X_OK):+ if explicit and os.access(explicit, os.X_OK) and not _is_headless_shell(explicit):return explicitfinders = [_playwright_executable, _system_executable]if not _is_root() and _userns_restricted():@@ -57,6 +57,13 @@ def _playwright_executable() -> Optional[str]:return next((exe for exe in candidates if os.access(exe, os.X_OK)), None)+def _is_headless_shell(exe: str) -> bool:+ """Playwright's ``chrome-headless-shell`` can drive pages but cannot open a window: the official Docker+ image ships only that build and its boot hook exports it as ``AGENT_BROWSER_EXECUTABLE_PATH``, so+ trusting the override blindly would pin a windowless binary to the dock's Browser icon."""+ return "headless" in os.path.basename(exe).lower() or "headless_shell" in exe++def _system_executable() -> Optional[str]:return next((shutil.which(name) for name in _SYSTEM_BROWSERS if shutil.which(name)), None)