Skip to content

"CLI-Anything: Making ALL Software Agent-Native" -- CLI-Hub: https://clianything.cc/

Python

chore(browser): R2 review triage on PR #308 — test rename + comment tighten

apirenob684732f12c9
diff --git a/browser/agent-harness/cli_anything/browser/tests/test_domshell_backend.py b/browser/agent-harness/cli_anything/browser/tests/test_domshell_backend.py
index 868e06e6b..ca0152d98 100644
--- a/browser/agent-harness/cli_anything/browser/tests/test_domshell_backend.py
+++ b/browser/agent-harness/cli_anything/browser/tests/test_domshell_backend.py
@@ -1027,8 +1027,15 @@ def test_extract_lane_id_returns_none_when_content_missing():
@patch.object(backend, "_call_execute", new_callable=AsyncMock)
-def test_first_call_omits_group_id_and_captures_lane(mock_call):
- """A session with no stored lane: first call has no group_id, captures the returned lane."""
+def test_first_call_passes_wrapper_signature_and_captures_lane(mock_call):
+ """A session with no stored lane: the wrapper passes (command,
+ use_daemon, session=sess) into ``_call_execute``; the wire-format
+ ``group_id`` selection (``"new"`` for non-daemon first calls,
+ ``"shared"`` for daemon-mode-no-session) happens inside
+ ``_call_execute`` itself and is covered by the dedicated
+ wire-payload tests below. This test only asserts the wrapper-level
+ call signature plus the ``_capture_lane`` parser hookup.
+ """
sess = Session() # domshell_lane_id starts as None
mock_call.return_value = _make_result("✓\n[lane: 12345]")
diff --git a/browser/agent-harness/cli_anything/browser/utils/domshell_backend.py b/browser/agent-harness/cli_anything/browser/utils/domshell_backend.py
index b5f6f84e8..5b60b67a5 100644
--- a/browser/agent-harness/cli_anything/browser/utils/domshell_backend.py
+++ b/browser/agent-harness/cli_anything/browser/utils/domshell_backend.py
@@ -507,14 +507,25 @@ async def _call_execute(
# fresh isolated lane and returns its id in the [lane: ...]
# marker, which `_capture_lane` stores on the session for next
# time.
- # • daemon-mode first call without a Session → group_id="shared"
- # — the daemon's persistent connection has its own default lane
- # that stays sticky across calls, so direct (sessionless) daemon
- # workflows like `open_url(use_daemon=True)` followed by
- # `ls(use_daemon=True)` share browser state naturally. Using
- # "new" here would mint a fresh isolated lane per call and lose
- # the page just opened (Codex P2 regression caught on the
- # initial 2.0.2 migration commit be62f843b5).
+ # • daemon-mode first call without a Session → group_id="shared".
+ # When the persistent daemon connection is live, the default
+ # per-connection lane stays sticky across calls — so direct
+ # (sessionless) daemon workflows like `open_url(use_daemon=True)`
+ # followed by `ls(use_daemon=True)` share browser state without
+ # needing a Session to carry a lane id.
+ #
+ # In the fall-back path (daemon dead / not started — i.e.
+ # `_daemon_session is None` below), each call spawns its own
+ # ClientSession, which triggers its own SESSION_START on
+ # DOMShell and gets its own per-connection default lane.
+ # "shared" is per-MCP-session, so it still routes correctly
+ # there — to *that spawn's* default lane — giving per-call
+ # isolation. Same outcome as omitting `group_id` would have
+ # pre-2.0.2, minus the [DEPRECATION] warning, and crucially one
+ # orphan tab-group per spawn instead of two (`group_id="new"`
+ # would create an explicit second lane on top of the
+ # SESSION_START default — the orphan flood reverted in commit
+ # 99d1182504).
if session is not None and getattr(session, "domshell_lane_id", None):
arguments["group_id"] = session.domshell_lane_id
elif use_daemon: