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
feat: service-only restart keeps the Web UI up + confirm before disabling a platform
cyh35d1f2d2809c
diff --git a/tests/test_restart_supervisor.py b/tests/test_restart_supervisor.pyindex 3b9ed9b5a..51c400c53 100644--- a/tests/test_restart_supervisor.py+++ b/tests/test_restart_supervisor.py@@ -121,8 +121,8 @@ def test_restart_job_stops_and_starts_service(monkeypatch, tmp_path):paths.get_runtime_pid_path().write_text("111", encoding="utf-8")calls = []- monkeypatch.setattr(restart_supervisor, "_stop_runtime_for_restart", lambda: _fake_stop_runtime(calls))- monkeypatch.setattr(restart_supervisor, "_start_runtime_processes", lambda: _fake_start_runtime(calls))+ monkeypatch.setattr(restart_supervisor, "_stop_runtime_for_restart", lambda stop_ui=True: _fake_stop_runtime(calls))+ monkeypatch.setattr(restart_supervisor, "_start_runtime_processes", lambda start_ui=True: _fake_start_runtime(calls))monkeypatch.setattr(restart_supervisor, "_wait_for_service_lock_release", lambda: True)monkeypatch.setattr(runtime, "pid_alive", lambda pid: pid == 222)monkeypatch.setattr(runtime, "service_pid_recorded", lambda pid: pid == 222)@@ -156,8 +156,8 @@ def test_restart_job_prepares_show_runtime_after_service_start(monkeypatch, tmp_paths.get_runtime_pid_path().write_text("111", encoding="utf-8")calls = []- monkeypatch.setattr(restart_supervisor, "_stop_runtime_for_restart", lambda: _fake_stop_runtime(calls))- monkeypatch.setattr(restart_supervisor, "_start_runtime_processes", lambda: _fake_start_runtime(calls))+ monkeypatch.setattr(restart_supervisor, "_stop_runtime_for_restart", lambda stop_ui=True: _fake_stop_runtime(calls))+ monkeypatch.setattr(restart_supervisor, "_start_runtime_processes", lambda start_ui=True: _fake_start_runtime(calls))monkeypatch.setattr(restart_supervisor, "_wait_for_service_lock_release", lambda: True)monkeypatch.setattr(restart_supervisor, "get_safe_cwd", lambda: str(tmp_path))monkeypatch.setattr(restart_supervisor, "get_restart_command", lambda vibe_path=None: ["/bin/vibe"])@@ -197,7 +197,7 @@ def test_restart_job_aborts_when_stop_fails(monkeypatch, tmp_path):monkeypatch.setattr(restart_supervisor,"_stop_runtime_for_restart",- lambda: _fake_stop_runtime(calls, service_stopped=False),+ lambda stop_ui=True: _fake_stop_runtime(calls, service_stopped=False),)monkeypatch.setattr(runtime, "pid_alive", lambda pid: pid == 111)monkeypatch.setattr(restart_supervisor, "_wait_for_service_lock_release", lambda: True)@@ -222,9 +222,9 @@ def test_restart_job_continues_when_old_pid_already_exited(monkeypatch, tmp_pathmonkeypatch.setattr(restart_supervisor,"_stop_runtime_for_restart",- lambda: _fake_stop_runtime(calls, service_stopped=False),+ lambda stop_ui=True: _fake_stop_runtime(calls, service_stopped=False),)- monkeypatch.setattr(restart_supervisor, "_start_runtime_processes", lambda: _fake_start_runtime(calls))+ monkeypatch.setattr(restart_supervisor, "_start_runtime_processes", lambda start_ui=True: _fake_start_runtime(calls))monkeypatch.setattr(restart_supervisor, "_wait_for_service_lock_release", lambda: True)monkeypatch.setattr(runtime, "pid_alive", lambda pid: pid == 222)monkeypatch.setattr(runtime, "service_pid_recorded", lambda pid: pid == 222)@@ -242,9 +242,9 @@ def test_restart_job_adopts_slow_starting_service_pid(monkeypatch, tmp_path):paths.get_runtime_pid_path().write_text("111", encoding="utf-8")calls = []- monkeypatch.setattr(restart_supervisor, "_stop_runtime_for_restart", lambda: _fake_stop_runtime(calls))+ monkeypatch.setattr(restart_supervisor, "_stop_runtime_for_restart", lambda stop_ui=True: _fake_stop_runtime(calls))monkeypatch.setattr(restart_supervisor, "_wait_for_service_lock_release", lambda: True)- def slow_start_runtime():+ def slow_start_runtime(start_ui=True):calls.append("start_runtime")runtime.write_status("starting", "service process is still starting", 222, 333)try:@@ -276,12 +276,12 @@ def test_restart_job_marks_start_runtime_failed(monkeypatch, tmp_path):paths.ensure_data_dirs()paths.get_runtime_pid_path().write_text("111", encoding="utf-8")- monkeypatch.setattr(restart_supervisor, "_stop_runtime_for_restart", lambda: _fake_stop_runtime([]))+ monkeypatch.setattr(restart_supervisor, "_stop_runtime_for_restart", lambda stop_ui=True: _fake_stop_runtime([]))monkeypatch.setattr(restart_supervisor, "_wait_for_service_lock_release", lambda: True)monkeypatch.setattr(restart_supervisor,"_start_runtime_processes",- lambda: (_ for _ in ()).throw(RuntimeError("service refused to start")),+ lambda start_ui=True: (_ for _ in ()).throw(RuntimeError("service refused to start")),)rc = restart_supervisor._run_restart_job(job_id="jobtimeout", delay_seconds=0, vibe_path="/bin/vibe", trigger="test")@@ -300,8 +300,8 @@ def test_restart_job_waits_for_service_lock_release_before_start(monkeypatch, tmpaths.get_runtime_pid_path().write_text("111", encoding="utf-8")calls = []- monkeypatch.setattr(restart_supervisor, "_stop_runtime_for_restart", lambda: _fake_stop_runtime(calls))- monkeypatch.setattr(restart_supervisor, "_start_runtime_processes", lambda: _fake_start_runtime(calls))+ monkeypatch.setattr(restart_supervisor, "_stop_runtime_for_restart", lambda stop_ui=True: _fake_stop_runtime(calls))+ monkeypatch.setattr(restart_supervisor, "_start_runtime_processes", lambda start_ui=True: _fake_start_runtime(calls))lock_checks = iter([(False, 111), (True, None)])@@ -327,12 +327,12 @@ def test_restart_job_fails_when_service_lock_does_not_release(monkeypatch, tmp_ppaths.get_runtime_pid_path().write_text("111", encoding="utf-8")calls = []- monkeypatch.setattr(restart_supervisor, "_stop_runtime_for_restart", lambda: _fake_stop_runtime(calls))+ monkeypatch.setattr(restart_supervisor, "_stop_runtime_for_restart", lambda stop_ui=True: _fake_stop_runtime(calls))monkeypatch.setattr(restart_supervisor, "_wait_for_service_lock_release", lambda: False)monkeypatch.setattr(restart_supervisor,"_start_runtime_processes",- lambda: (_ for _ in ()).throw(AssertionError("start should wait for lock release")),+ lambda start_ui=True: (_ for _ in ()).throw(AssertionError("start should wait for lock release")),)monkeypatch.setattr(runtime, "pid_alive", lambda pid: False)@@ -432,3 +432,63 @@ def test_stop_runtime_for_restart_stops_ui_and_service(monkeypatch, tmp_path):assert stop_service_seconds >= 0assert ui_pid is Noneassert sorted(calls) == ["stop_service", "stop_ui"]+++def test_schedule_restart_service_scope_adds_flag(monkeypatch, tmp_path):+ """A service-only restart passes ``--scope service`` to the supervisor job;+ the default ``all`` scope adds no flag (back-compat for CLI/upgrade)."""+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))+ paths.ensure_data_dirs()++ commands: list[list[str]] = []+ monkeypatch.setattr(restart_supervisor, "get_restart_invocation_command", lambda vibe_path=None: ["/bin/vibe", "restart"])+ monkeypatch.setattr(restart_supervisor, "get_restart_environment", lambda vibe_path=None: {"PATH": "/bin"})+ monkeypatch.setattr(restart_supervisor, "get_safe_cwd", lambda: str(tmp_path))+ monkeypatch.setattr(restart_supervisor, "_prune_restart_logs", lambda: None)++ def fake_popen(command, **kwargs):+ commands.append(command)+ return SimpleNamespace(pid=4242)++ monkeypatch.setattr(restart_supervisor.subprocess, "Popen", fake_popen)++ restart_supervisor.schedule_restart(delay_seconds=0, vibe_path="/bin/vibe", trigger="web-ui", scope="service")+ assert "--scope" in commands[-1] and commands[-1][commands[-1].index("--scope") + 1] == "service"++ restart_supervisor.schedule_restart(delay_seconds=0, vibe_path="/bin/vibe", trigger="web-ui")+ assert "--scope" not in commands[-1]+++def test_restart_job_service_scope_keeps_ui(monkeypatch, tmp_path):+ """scope='service' restarts only the service: the UI is neither stopped nor+ started, so its recorded pid is preserved across the restart."""+ monkeypatch.setenv("VIBE_REMOTE_HOME", str(tmp_path))+ paths.ensure_data_dirs()+ paths.get_runtime_pid_path().write_text("111", encoding="utf-8")+ calls = []+ captured: dict[str, bool] = {}++ def stub_stop(stop_ui=True):+ captured["stop_ui"] = stop_ui+ return _fake_stop_runtime(calls)++ def stub_start(start_ui=True):+ captured["start_ui"] = start_ui+ return _fake_start_runtime(calls)++ monkeypatch.setattr(restart_supervisor, "_stop_runtime_for_restart", stub_stop)+ monkeypatch.setattr(restart_supervisor, "_start_runtime_processes", stub_start)+ monkeypatch.setattr(restart_supervisor, "_wait_for_service_lock_release", lambda: True)+ monkeypatch.setattr(runtime, "pid_alive", lambda pid: pid == 222)+ monkeypatch.setattr(runtime, "service_pid_recorded", lambda pid: pid == 222)++ rc = restart_supervisor._run_restart_job(+ job_id="jobsvc", delay_seconds=0, vibe_path="/bin/vibe", trigger="web-ui", scope="service"+ )++ assert rc == 0+ # The UI was deliberately left running on both the stop and start sides.+ assert captured == {"stop_ui": False, "start_ui": False}+ status = runtime.read_json(runtime.get_restart_status_path())+ assert status["ok"] is True+ assert status["scope"] == "service"diff --git a/ui/src/components/settings/SettingsPlatformsPage.tsx b/ui/src/components/settings/SettingsPlatformsPage.tsxindex db0552748..4218a5834 100644--- a/ui/src/components/settings/SettingsPlatformsPage.tsx+++ b/ui/src/components/settings/SettingsPlatformsPage.tsx@@ -20,6 +20,15 @@ import { LarkConfig } from '@/components/steps/LarkConfig';import { WeChatConfig } from '@/components/steps/WeChatConfig';import { SettingsPageShell } from './SettingsPageShell';import { Badge } from '@/components/ui/badge';+import { Button } from '@/components/ui/button';+import {+ Dialog,+ DialogContent,+ DialogDescription,+ DialogFooter,+ DialogHeader,+ DialogTitle,+} from '@/components/ui/dialog';const PLATFORM_TILE_STYLES: Record<string, { bg: string; border: string }> = {slack: { bg: 'bg-[#4A154B26]', border: 'border-[#4A154B66]' },@@ -54,6 +63,8 @@ export const SettingsPlatformsPage: React.FC = () => {// Which platform's credential form is expanded (the "Configure" toggle).const [openConfig, setOpenConfig] = useState<string | null>(null);const [busyPlatform, setBusyPlatform] = useState<string | null>(null);+ // The platform pending a disable confirmation (null = no dialog open).+ const [confirmDisableId, setConfirmDisableId] = useState<string | null>(null);const [restartPhase, setRestartPhase] = useState<'idle' | 'saving' | 'restarting'>('idle');useEffect(() => {@@ -118,19 +129,25 @@ export const SettingsPlatformsPage: React.FC = () => {}};+ // Disabling a live platform stops it receiving messages, so confirm first+ // (a misclick on an enabled platform shouldn't silently take it offline).+ const doDisable = async (id: string) => {+ setBusyPlatform(id);+ try {+ await persistEnabled(enabledPlatforms.filter((p) => p !== id));+ setRevealed((prev) => prev.filter((p) => p !== id));+ setOpenConfig((prev) => (prev === id ? null : prev));+ } finally {+ setBusyPlatform(null);+ }+ };+const toggleTile = async (id: string) => {if (busyPlatform) return;const enabled = enabledPlatforms.includes(id);if (enabled) {- // Uncheck an enabled platform → disable immediately (single step).- setBusyPlatform(id);- try {- await persistEnabled(enabledPlatforms.filter((p) => p !== id));- setRevealed((prev) => prev.filter((p) => p !== id));- setOpenConfig((prev) => (prev === id ? null : prev));- } finally {- setBusyPlatform(null);- }+ // Uncheck an enabled platform → confirm before disabling.+ setConfirmDisableId(id);return;}if (revealed.includes(id)) {@@ -357,6 +374,40 @@ export const SettingsPlatformsPage: React.FC = () => {);})}</div>++ <Dialog open={confirmDisableId !== null} onOpenChange={(open) => !open && setConfirmDisableId(null)}>+ <DialogContent>+ <DialogHeader>+ <DialogTitle>{t('platform.disableConfirmTitle')}</DialogTitle>+ <DialogDescription>+ {t('platform.disableConfirmBody', {+ name: confirmDisableId+ ? t(+ platformCatalog.find((p) => p.id === confirmDisableId)?.title_key ||+ `platform.${confirmDisableId}.title`+ )+ : '',+ })}+ </DialogDescription>+ </DialogHeader>+ <DialogFooter>+ <Button variant="secondary" size="sm" onClick={() => setConfirmDisableId(null)}>+ {t('common.cancel')}+ </Button>+ <Button+ variant="destructive-soft"+ size="sm"+ onClick={() => {+ const id = confirmDisableId;+ setConfirmDisableId(null);+ if (id) void doDisable(id);+ }}+ >+ {t('platform.disableConfirmCta')}+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog></SettingsPageShell>);};diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.jsonindex 73833d1b5..362211b8c 100644--- a/ui/src/i18n/en.json+++ b/ui/src/i18n/en.json@@ -729,6 +729,9 @@"primaryDesc": "Used for compatibility ordering and default UI focus.","credentialsTitle": "Platform credentials","credentialsSubtitle": "Connect each IM platform with the credentials your bot uses to authenticate.",+ "disableConfirmTitle": "Disable this platform?",+ "disableConfirmBody": "{{name}} will stop receiving messages. You can re-enable it anytime.",+ "disableConfirmCta": "Disable","enabledPlatforms": "Enabled platforms","selectedSummary": "{{count}} selected","apply": "Apply",diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.jsonindex 742846155..b05fa75fe 100644--- a/ui/src/i18n/zh.json+++ b/ui/src/i18n/zh.json@@ -729,6 +729,9 @@"primaryDesc": "仅用于兼容排序和默认界面展示焦点。","credentialsTitle": "平台凭证","credentialsSubtitle": "为每个 IM 平台配置机器人认证所需的凭证。",+ "disableConfirmTitle": "禁用该平台?",+ "disableConfirmBody": "禁用后将停止接收 {{name}} 的消息。你随时可以重新启用。",+ "disableConfirmCta": "禁用","enabledPlatforms": "已启用平台","selectedSummary": "已选择 {{count}} 个","apply": "应用",diff --git a/vibe/restart_supervisor.py b/vibe/restart_supervisor.pyindex 68a92c1ad..2f9cda32d 100644--- a/vibe/restart_supervisor.py+++ b/vibe/restart_supervisor.py@@ -109,7 +109,7 @@ def _runtime_ready_for_config(config) -> bool:return bool(getattr(getattr(config, "slack", None), "bot_token", ""))-def _start_runtime_processes() -> tuple[int, int | None]:+def _start_runtime_processes(start_ui: bool = True) -> tuple[int, int | None]:from core.services import settings as settings_servicepaths.ensure_data_dirs()@@ -121,8 +121,13 @@ def _start_runtime_processes() -> tuple[int, int | None]:runtime.write_status("setup", "missing platform credentials")service_pid = runtime.start_service(wait_for_ready=False, initial_ready_timeout=0)- bind_host = runtime.effective_ui_bind_host(config)- ui_pid = runtime.start_ui(bind_host, config.ui.setup_port, wait_for_ready=False)+ 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()if runtime.service_pid_recorded(service_pid):runtime.write_status("running", f"pid={service_pid}", service_pid, ui_pid)@@ -148,7 +153,13 @@ def _stop_service_for_restart() -> tuple[bool, float]:return bool(stopped), _rounded_seconds(time.monotonic() - started_at)-def _stop_runtime_for_restart() -> tuple[bool, dict[str, float | bool], float, int | None, bool, float]:+def _stop_runtime_for_restart(stop_ui: bool = True) -> tuple[bool, dict[str, float | bool], float, int | None, bool, float]:+ if not stop_ui:+ # Service-only restart: leave the UI process untouched so the open Web+ # UI survives. Report its still-recorded pid; ``ui_stopped`` is True only+ # to satisfy the "did the UI stop" guard (we deliberately did not stop it).+ service_stopped, stop_service_seconds = _stop_service_for_restart()+ return True, {}, 0.0, _read_recorded_ui_pid(), service_stopped, stop_service_secondswith ThreadPoolExecutor(max_workers=2, thread_name_prefix="avibe-restart-stop") as executor:ui_future = executor.submit(_stop_ui_for_restart)service_future = executor.submit(_stop_service_for_restart)@@ -174,8 +185,13 @@ def _run_restart_job(delay_seconds: float,vibe_path: str | None,trigger: str,+ scope: str = "all",prepare_show_runtime: bool = False,) -> int:+ # "service": restart only the service process, leaving the Web UI process+ # running (a config change shouldn't tear down the open Web UI). "all"+ # (default, e.g. CLI `vibe restart` / upgrades) restarts both.+ restart_ui = scope != "service"log_path = _restart_log_path(job_id)safe_cwd = get_safe_cwd()_prune_restart_logs()@@ -211,6 +227,7 @@ def _run_restart_job("state": "scheduled" if delay_seconds > 0 else "running","trigger": trigger,"delay_seconds": delay_seconds,+ "scope": scope,"old_pid": old_pid,"new_pid": None,"log_path": str(log_path),@@ -231,17 +248,17 @@ def _run_restart_job(write("restart job started after delay")restart_started_at = time.monotonic()- write("stopping UI and service")+ write("stopping UI and service" if restart_ui else "stopping service (Web UI kept running)")stop_runtime_started_at = time.monotonic()try:- ui_stopped, ui_timings, stop_ui_seconds, ui_pid, stopped, stop_service_seconds = _stop_runtime_for_restart()+ ui_stopped, ui_timings, stop_ui_seconds, ui_pid, stopped, stop_service_seconds = _stop_runtime_for_restart(stop_ui=restart_ui)except Exception as exc:return _fail(payload, f"stop runtime failed: {exc}", log, 2, started_at=restart_started_at)stage_durations.update(ui_timings)record_duration("stop_ui_total_seconds", stop_ui_seconds)record_duration("stop_service_seconds", stop_service_seconds)mark_duration("stop_runtime_seconds", stop_runtime_started_at)- if ui_pid and ui_stopped is False and runtime.pid_alive(ui_pid):+ if restart_ui and ui_pid and ui_stopped is False and runtime.pid_alive(ui_pid):return _fail(payload, f"UI pid {ui_pid} did not stop", log, 2, started_at=restart_started_at)if old_pid and stopped is False and runtime.pid_alive(old_pid):return _fail(payload, f"service pid {old_pid} did not stop", log, 2, started_at=restart_started_at)@@ -255,7 +272,7 @@ def _run_restart_job(write("starting service")start_runtime_started_at = time.monotonic()try:- new_pid, ui_pid = _start_runtime_processes()+ new_pid, ui_pid = _start_runtime_processes(start_ui=restart_ui)except Exception as exc:return _fail(payload, f"start runtime failed: {exc}", log, 1, started_at=restart_started_at)mark_duration("start_runtime_seconds", start_runtime_started_at)@@ -327,6 +344,7 @@ def schedule_restart(delay_seconds: float = 0.0,vibe_path: str | None = None,trigger: str = "cli",+ scope: str = "all",prepare_show_runtime: bool = False,) -> dict:job_id = uuid.uuid4().hex[:12]@@ -336,6 +354,8 @@ def schedule_restart("__restart-supervisor",]command.extend(["--job-id", job_id, "--delay-seconds", str(delay_seconds), "--trigger", trigger])+ if scope != "all":+ command.extend(["--scope", scope])if vibe_path:command.extend(["--vibe-path", vibe_path])if prepare_show_runtime:@@ -354,6 +374,7 @@ def schedule_restart("job_id": job_id,"state": "scheduled","trigger": trigger,+ "scope": scope,"delay_seconds": delay_seconds,"supervisor_pid": None,"old_pid": _read_recorded_pid(),@@ -397,6 +418,7 @@ def main(argv: list[str] | None = None) -> int:parser.add_argument("--job-id", required=True)parser.add_argument("--delay-seconds", type=float, default=0.0)parser.add_argument("--trigger", default="cli")+ parser.add_argument("--scope", default="all", choices=("all", "service"))parser.add_argument("--vibe-path")parser.add_argument("--prepare-show-runtime", action="store_true")args = parser.parse_args(argv)@@ -405,6 +427,7 @@ def main(argv: list[str] | None = None) -> int:delay_seconds=max(0.0, args.delay_seconds),vibe_path=args.vibe_path,trigger=args.trigger,+ scope=args.scope,prepare_show_runtime=args.prepare_show_runtime,)diff --git a/vibe/ui_server.py b/vibe/ui_server.pyindex 0bad4236e..10a313ec2 100644--- a/vibe/ui_server.py+++ b/vibe/ui_server.py@@ -2179,8 +2179,14 @@ def control():_stop_opencode_server()runtime.write_status("stopped", "stopped", None, status.get("ui_pid"))elif action == "restart":+ # Default to a SERVICE-ONLY restart: a Web-UI-triggered restart (e.g. a+ # config change) must not tear down the Web UI process the user is+ # looking at. A caller can still request a full restart with+ # ``scope: "all"`` (e.g. a UI host/port change that needs the UI server+ # itself to come back up).+ scope = payload.get("scope") if payload.get("scope") in ("all", "service") else "service"runtime.write_status("restarting", "restarting", status.get("service_pid"), status.get("ui_pid"))- result = schedule_restart(delay_seconds=0.0, trigger="web-ui")+ result = schedule_restart(delay_seconds=0.0, trigger="web-ui", scope=scope)return jsonify({"ok": True, "action": action, "restart": result, "status": runtime.read_status()})return jsonify({"ok": True, "action": action, "status": runtime.read_status()})