Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
test(browser): verify installed-browser session reuse and isolation contract
trohitg37d4f64796d3
diff --git a/docs-internal/browser.md b/docs-internal/browser.mdindex 9bccd97c..1b84cd0e 100644--- a/docs-internal/browser.md+++ b/docs-internal/browser.md@@ -67,6 +67,20 @@ debugging endpoint.## Profiles, ownership and control+OpenCompany reuses the user's installed browser executable and its normal+update mechanism. It launches a separate OpenCompany process with a dedicated+data directory, then reuses that running process for agent actions and the+workspace viewer. Opening the same profile again does not launch another browser;+concurrent opens share one startup task. Cookies and local storage persist across+restarts of that profile and remain separate from other profiles and personal+browsing. Sessions intentionally assigned the same saved profile share its logins.++This is installed-browser reuse, not attachment to the user's everyday running+browser. Chrome's CDP debugging switches require a non-default data directory+since Chrome 136 ([Chrome documentation](https://developer.chrome.com/blog/remote-debugging-port)).+Using the existing executable with separate persistent profiles retains the+workspace live view without an extension or personal-profile migration.+Profile metadata is stored in the `browser_profiles` table. Chrome state isunder `<DATA_DIR>/browser/profiles/<profile-id>/user-data/`, with generateddirectory IDs rather than user-supplied names. A saved `profile_id` selects andiff --git a/server/tests/nodes/browser/test_system_browser.py b/server/tests/nodes/browser/test_system_browser.pyindex d9b71483..143bcb2f 100644--- a/server/tests/nodes/browser/test_system_browser.py+++ b/server/tests/nodes/browser/test_system_browser.py@@ -190,6 +190,48 @@ async def test_runtime_preserves_system_user_agent(monkeypatch, provider, expectassert ("Network.setUserAgentOverride" in methods) is expected+async def test_open_reuses_running_profile_for_agent_and_viewer(monkeypatch):+ from nodes.browser import _runtime as module++ runtime = module.BrowserRuntime()+ existing = SimpleNamespace(running=True)+ runtime._profiles["shared"] = existing+ start = AsyncMock(side_effect=AssertionError("must reuse the profile's browser"))+ monkeypatch.setattr(runtime, "_start", start)+ profile = SimpleNamespace(id="shared")+ assert await runtime.open(profile) is existing+ assert await runtime.open(profile) is existing+ start.assert_not_awaited()+++async def test_concurrent_opens_share_one_browser_start(monkeypatch):+ import asyncio+ from nodes.browser import _runtime as module++ runtime = module.BrowserRuntime()+ entered, release = asyncio.Event(), asyncio.Event()+ existing = SimpleNamespace(running=True)++ async def launch(profile):+ entered.set()+ await release.wait()+ return existing++ start = AsyncMock(side_effect=launch)+ monkeypatch.setattr(runtime, "_start", start)+ monkeypatch.setattr(runtime, "_ensure_reaper", Mock())+ profile = SimpleNamespace(id="shared")+ first = asyncio.create_task(runtime.open(profile))+ await asyncio.wait_for(entered.wait(), timeout=1)+ second = asyncio.create_task(runtime.open(profile))+ await asyncio.sleep(0)+ release.set()+ assert await asyncio.gather(first, second) == [existing, existing]+ start.assert_awaited_once_with(profile)++@pytest.mark.asyncioasync def test_start_records_connected_version_and_passes_actual_major(monkeypatch):import asyncio