From bbe8af9378ea666f0296dc7f36395348d7396ae9 Mon Sep 17 00:00:00 2001 From: Dennis V <2119348+dzianisv@users.noreply.github.com> Date: Tue, 23 Jun 2026 00:06:32 +0000 Subject: [PATCH] fix(cua): pre-create API call must use 127.0.0.1 not 10.0.2.2 on host MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The CUA script runs on the CI runner (host), not inside the emulator. 10.0.2.2 is the emulator's special address for the host — it is only reachable FROM INSIDE the emulator. Calling it from the runner always fails, so _precreate_test_session returned None, and the session_list phase fell back to the weak 'screen visible' assertion instead of the strong 'pre-created session must appear' check. Fix: replace 10.0.2.2 → 127.0.0.1 before making the pre-create call. Localhost URLs (100.x.x.x, custom dev server) pass through unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- scripts/android-cua-smoke.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/android-cua-smoke.py b/scripts/android-cua-smoke.py index 00c233a..1e2dc7f 100755 --- a/scripts/android-cua-smoke.py +++ b/scripts/android-cua-smoke.py @@ -621,7 +621,12 @@ def _precreate_test_session(opencode_url: str, title: str = "cua-smoke-sessions- pre-existing sessions from the server on connect (not just an empty screen). """ import urllib.request - url = f"{opencode_url.rstrip('/')}/session" + # The CUA script runs on the HOST machine, not inside the emulator. + # When opencode_url uses the Android emulator's host-route (10.0.2.2), + # translate it to localhost for this pre-create call — 10.0.2.2 is + # only reachable from *inside* the emulator, not from the host/CI runner. + api_base = opencode_url.replace("10.0.2.2", "127.0.0.1") + url = f"{api_base.rstrip('/')}/session" data = json.dumps({"title": title}).encode() req = urllib.request.Request( url, data=data, method="POST", @@ -631,10 +636,10 @@ def _precreate_test_session(opencode_url: str, title: str = "cua-smoke-sessions- with urllib.request.urlopen(req, timeout=10) as resp: body = json.loads(resp.read()) session_id = body.get("id", "unknown") - print(f" [pre-create] session created via API: id={session_id!r}, title={title!r}") + print(f" [pre-create] session created via API ({api_base}): id={session_id!r}, title={title!r}") return title except Exception as exc: - print(f" [pre-create] WARNING: could not pre-create session: {exc}") + print(f" [pre-create] WARNING: could not pre-create session at {api_base}: {exc}") print(f" [pre-create] session_list phase will skip the 'must show sessions' assertion") return None