Skip to content

armgit / avibe

Public Imported from GitHub
0

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.

fix(upgrade): bridge legacy delayed restart

cyhc6a7c3109203
diff --git a/tests/test_vibe_cli.py b/tests/test_vibe_cli.py
index ee70b7ff1..b88897b5c 100644
--- a/tests/test_vibe_cli.py
+++ b/tests/test_vibe_cli.py
@@ -176,6 +176,46 @@ def test_cmd_restart_runs_synchronously_by_default(monkeypatch):
assert calls == ["stop", ("sleep", 3), "start"]
+def test_cmd_vibe_treats_legacy_delayed_helper_as_restart(monkeypatch):
+ calls = []
+ config = SimpleNamespace(
+ has_configured_platform_credentials=lambda: True,
+ ui=SimpleNamespace(setup_host="127.0.0.1", setup_port=5123, open_browser=False),
+ )
+
+ monkeypatch.delenv(cli.LEGACY_DELAYED_RESTART_HANDLED_ENV, raising=False)
+ monkeypatch.setattr(cli.paths, "ensure_data_dirs", lambda: None)
+ monkeypatch.setattr(cli, "_ensure_config", lambda: config)
+ monkeypatch.setattr(cli, "_write_status", lambda *args, **kwargs: calls.append(("status", args)))
+ monkeypatch.setattr(cli, "cmd_stop", lambda: calls.append("stop") or 0)
+ monkeypatch.setattr(cli.time, "sleep", lambda seconds: calls.append(("sleep", seconds)))
+ monkeypatch.setattr(cli.runtime, "start_service", lambda: calls.append("start_service") or 1234)
+ monkeypatch.setattr(cli.runtime, "effective_ui_bind_host", lambda cfg: "127.0.0.1")
+ monkeypatch.setattr(cli.runtime, "start_ui", lambda host, port: calls.append(("start_ui", host, port)) or 5678)
+ monkeypatch.setattr(cli.runtime, "write_status", lambda *args: calls.append(("runtime_status", args)))
+ monkeypatch.setattr(cli, "_open_browser", lambda url: calls.append(("open", url)) or True)
+ monkeypatch.setattr(
+ cli.runtime,
+ "get_process_command",
+ lambda pid: "python -c \"import subprocess, time; time.sleep(2); subprocess.Popen(['vibe'], "
+ "stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)\"",
+ )
+
+ assert cli.cmd_vibe() == 0
+
+ assert calls[:2] == ["stop", ("sleep", 3)]
+ assert "start_service" in calls
+ assert ("start_ui", "127.0.0.1", 5123) in calls
+ assert os.environ[cli.LEGACY_DELAYED_RESTART_HANDLED_ENV] == "1"
+
+
+def test_legacy_delayed_helper_detection_ignores_normal_parent(monkeypatch):
+ monkeypatch.delenv(cli.LEGACY_DELAYED_RESTART_HANDLED_ENV, raising=False)
+ monkeypatch.setattr(cli.runtime, "get_process_command", lambda pid: "zsh")
+
+ assert cli._launched_by_legacy_delayed_restart_helper() is False
+
+
def test_restart_parser_accepts_delay_seconds():
parser = cli.build_parser()
args = parser.parse_args(["restart", "--delay-seconds", "60"])
diff --git a/vibe/cli.py b/vibe/cli.py
index 805b7ba08..41df316a0 100644
--- a/vibe/cli.py
+++ b/vibe/cli.py
@@ -52,6 +52,7 @@ logger = logging.getLogger(__name__)
WATCH_STARTUP_STABLE_RUNNING_SECONDS = 1.5
WATCH_STARTUP_JITTER_BUFFER_SECONDS = 1.0
+LEGACY_DELAYED_RESTART_HANDLED_ENV = "VIBE_LEGACY_DELAYED_RESTART_HANDLED"
class VibeArgumentParser(argparse.ArgumentParser):
@@ -1813,6 +1814,11 @@ def cmd_vibe():
paths.ensure_data_dirs()
config = _ensure_config()
+ if _launched_by_legacy_delayed_restart_helper():
+ os.environ[LEGACY_DELAYED_RESTART_HANDLED_ENV] = "1"
+ logger.info("Bare vibe command launched by legacy delayed restart helper; running explicit restart")
+ return _cmd_restart_with_delay(0.0)
+
has_configured_platform_credentials = getattr(config, "has_configured_platform_credentials", None)
if callable(has_configured_platform_credentials):
ready = bool(has_configured_platform_credentials())
@@ -1850,6 +1856,20 @@ def cmd_vibe():
return 0
+def _launched_by_legacy_delayed_restart_helper() -> bool:
+ if os.environ.get(LEGACY_DELAYED_RESTART_HANDLED_ENV):
+ return False
+ parent_command = runtime.get_process_command(os.getppid())
+ if not parent_command:
+ return False
+ return (
+ "subprocess.Popen" in parent_command
+ and "time.sleep(" in parent_command
+ and "stdout=subprocess.DEVNULL" in parent_command
+ and "stderr=subprocess.DEVNULL" in parent_command
+ )
+
+
def _stop_opencode_server():
"""Terminate the OpenCode server if running."""
pid_file = paths.get_logs_dir() / "opencode_server.json"