Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(show): prefer loopback for session prewarm
cyh16d57e87f531
diff --git a/tests/test_show_pages.py b/tests/test_show_pages.pyindex bb29b8bbf..abdb7079c 100644--- a/tests/test_show_pages.py+++ b/tests/test_show_pages.py@@ -315,6 +315,45 @@ def test_show_path_cli_keeps_page_when_prewarm_fails(monkeypatch, tmp_path, capsassert (tmp_path / "show" / "ses123" / "index.html").exists()+def test_show_path_cli_prewarm_falls_back_to_configured_ui_host(monkeypatch, tmp_path, capsys):+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))+ paths.ensure_data_dirs()+ config = _save_config()+ config.ui.setup_host = "192.168.2.3"+ config.ui.setup_port = 15130+ config.save()+ attempted = []++ class _Response:+ def __enter__(self):+ return self++ def __exit__(self, *_args):+ return None++ def read(self):+ return json.dumps({"ok": True}).encode("utf-8")++ def _urlopen(request, timeout):+ attempted.append((request.full_url, timeout))+ if request.full_url.startswith("http://127.0.0.1:15130/"):+ raise OSError("loopback unavailable")+ return _Response()++ monkeypatch.setattr(cli.runtime, "read_status", lambda: {"ui_pid": 123})+ monkeypatch.setattr(cli.urllib.request, "urlopen", _urlopen)++ args = cli.build_parser().parse_args(["show", "path", "--session-id", "ses123", "--json"])+ assert cli.cmd_show_path(args) == 0++ payload = json.loads(capsys.readouterr().out)+ assert payload["ok"] is True+ assert attempted == [+ ("http://127.0.0.1:15130/api/show/sessions/ses123/prewarm", 3),+ ("http://192.168.2.3:15130/api/show/sessions/ses123/prewarm", 3),+ ]++def test_show_list_cli_json_reports_existing_pages(monkeypatch, tmp_path, capsys):monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))paths.ensure_data_dirs()diff --git a/vibe/cli.py b/vibe/cli.pyindex 15959525f..d0f497908 100644--- a/vibe/cli.py+++ b/vibe/cli.py@@ -4642,6 +4642,25 @@ def _ui_show_events_host(config: V2Config) -> str:return host+def _local_show_events_urls(session_id: str) -> list[str]:+ from urllib.parse import quote++ try:+ config = V2Config.load()+ except Exception:+ return []+ status = runtime.read_status()+ port = getattr(config.ui, "setup_port", None)+ if not status.get("ui_pid") or not port:+ return []+ path = f"/api/show/sessions/{quote(session_id, safe='')}/events"+ configured_host = _ui_show_events_host(config)+ hosts = ["127.0.0.1"]+ if configured_host not in hosts:+ hosts.append(configured_host)+ return [f"http://{host}:{int(port)}{path}" for host in hosts]++def _local_show_events_url(session_id: str) -> str | None:from urllib.parse import quote@@ -4656,38 +4675,32 @@ def _local_show_events_url(session_id: str) -> str | None:return f"http://{_ui_show_events_host(config)}:{int(port)}/api/show/sessions/{quote(session_id, safe='')}/events"-def _local_show_prewarm_url(session_id: str) -> str | None:- events_url = _local_show_events_url(session_id)- if not events_url:- return None- return f"{events_url.rsplit('/', 1)[0]}/prewarm"+def _local_show_prewarm_urls(session_id: str) -> list[str]:+ return [f"{events_url.rsplit('/', 1)[0]}/prewarm" for events_url in _local_show_events_urls(session_id)]def _request_show_page_prewarm_best_effort(session_id: str, *, base_path: str | None = None) -> dict | None:from core.show_pages import SHOW_CLI_EVENT_TOKEN_HEADER, show_cli_event_token- url = _local_show_prewarm_url(session_id)- if not url:+ urls = _local_show_prewarm_urls(session_id)+ if not urls:return Nonepayload = {"base_path": base_path} if base_path else {}body = json.dumps(payload).encode("utf-8")- request = urllib.request.Request(- url,- data=body,- method="POST",- headers={- "Content-Type": "application/json",- "X-Vibe-Show-Client": "cli",- SHOW_CLI_EVENT_TOKEN_HEADER: show_cli_event_token(),- },- )- try:- with urllib.request.urlopen(request, timeout=3) as response:- data = json.loads(response.read().decode("utf-8") or "{}")- return data if isinstance(data, dict) else None- except Exception:- logger.debug("Failed to request Show Page prewarm from live UI", exc_info=True)- return None+ headers = {+ "Content-Type": "application/json",+ "X-Vibe-Show-Client": "cli",+ SHOW_CLI_EVENT_TOKEN_HEADER: show_cli_event_token(),+ }+ for url in urls:+ request = urllib.request.Request(url, data=body, method="POST", headers=headers)+ try:+ with urllib.request.urlopen(request, timeout=3) as response:+ data = json.loads(response.read().decode("utf-8") or "{}")+ return data if isinstance(data, dict) else None+ except Exception:+ logger.debug("Failed to request Show Page prewarm from live UI at %s", url, exc_info=True)+ return Nonedef _post_show_event_to_live_ui(session_id: str, payload: dict) -> dict | None: