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(restart): register --scope on the CLI supervisor parser + preserve ui_pid on early status writes

cyh043f40428aa7
diff --git a/tests/test_ui_server_logs.py b/tests/test_ui_server_logs.py
index c17da1c5b..19cd52ca2 100644
--- a/tests/test_ui_server_logs.py
+++ b/tests/test_ui_server_logs.py
@@ -291,4 +291,10 @@ def test_control_restart_schedules_restart_job(monkeypatch, tmp_path):
assert payload["ok"] is True
assert payload["restart"]["job_id"] == "job123"
assert runtime.read_status()["state"] == "restarting"
- assert calls == [{"delay_seconds": 0.0, "trigger": "web-ui"}]
+ # A Web-UI restart defaults to service-only so the Web UI process survives.
+ assert calls == [{"delay_seconds": 0.0, "trigger": "web-ui", "scope": "service"}]
+
+ # An explicit scope:"all" still requests a full restart (e.g. UI port change).
+ calls.clear()
+ client.post("/api/control", json={"action": "restart", "scope": "all"}, headers=csrf_headers(client))
+ assert calls == [{"delay_seconds": 0.0, "trigger": "web-ui", "scope": "all"}]
diff --git a/vibe/cli.py b/vibe/cli.py
index b12813891..e5c841289 100644
--- a/vibe/cli.py
+++ b/vibe/cli.py
@@ -5566,6 +5566,7 @@ def build_parser():
supervisor_parser.add_argument("--job-id", required=True)
supervisor_parser.add_argument("--delay-seconds", type=_non_negative_float, default=0)
supervisor_parser.add_argument("--trigger", default="cli")
+ supervisor_parser.add_argument("--scope", default="all", choices=("all", "service"))
supervisor_parser.add_argument("--vibe-path")
supervisor_parser.add_argument("--prepare-show-runtime", action="store_true")
subparsers.add_parser("status", help="Show service status")
@@ -6542,6 +6543,7 @@ def main():
str(args.delay_seconds),
"--trigger",
args.trigger,
+ *(["--scope", args.scope] if args.scope != "all" else []),
*(["--prepare-show-runtime"] if args.prepare_show_runtime else []),
*(["--vibe-path", args.vibe_path] if args.vibe_path else []),
]
diff --git a/vibe/restart_supervisor.py b/vibe/restart_supervisor.py
index 2f9cda32d..93c5e0ced 100644
--- a/vibe/restart_supervisor.py
+++ b/vibe/restart_supervisor.py
@@ -115,19 +115,23 @@ def _start_runtime_processes(start_ui: bool = True) -> tuple[int, int | None]:
paths.ensure_data_dirs()
config = settings_service.load_config(default_factory=settings_service.default_config)
+ # Service-only restart: the UI process was never stopped, so carry its
+ # existing pid through EVERY status write — including the early
+ # starting/setup writes and any failure path — so a crash mid-start can't
+ # leave the status reporting ui_pid=None while the UI is still serving.
+ preserved_ui_pid = None if start_ui else _read_recorded_ui_pid()
+
if _runtime_ready_for_config(config):
- runtime.write_status("starting")
+ runtime.write_status("starting", None, None, preserved_ui_pid)
else:
- runtime.write_status("setup", "missing platform credentials")
+ runtime.write_status("setup", "missing platform credentials", None, preserved_ui_pid)
service_pid = runtime.start_service(wait_for_ready=False, initial_ready_timeout=0)
if start_ui:
bind_host = runtime.effective_ui_bind_host(config)
ui_pid = runtime.start_ui(bind_host, config.ui.setup_port, wait_for_ready=False)
else:
- # Service-only restart: the UI process was never stopped, so keep its
- # existing pid in the status writes instead of spawning a new one.
- ui_pid = _read_recorded_ui_pid()
+ ui_pid = preserved_ui_pid
if runtime.service_pid_recorded(service_pid):
runtime.write_status("running", f"pid={service_pid}", service_pid, ui_pid)