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.

feat(upgrade): auto-restart vibe after successful upgrade

cyhhao6c3fa9a3007e
diff --git a/ui/src/components/VersionBadge.tsx b/ui/src/components/VersionBadge.tsx
index 1db420e28..19ab6b8a9 100644
--- a/ui/src/components/VersionBadge.tsx
+++ b/ui/src/components/VersionBadge.tsx
@@ -11,6 +11,7 @@ export const VersionBadge: React.FC = () => {
const [isPopupOpen, setIsPopupOpen] = React.useState(false);
const [checking, setChecking] = React.useState(false);
const [upgrading, setUpgrading] = React.useState(false);
+ const [restarting, setRestarting] = React.useState(false);
const [upgradeResult, setUpgradeResult] = React.useState<UpgradeResult | null>(null);
const popupRef = React.useRef<HTMLDivElement>(null);
@@ -51,11 +52,19 @@ export const VersionBadge: React.FC = () => {
const result = await api.doUpgrade();
setUpgradeResult(result);
if (result.ok) {
- // Refresh version info after upgrade
- setTimeout(() => checkVersion(), 1000);
+ if (result.restarting) {
+ // Show restarting state and reload page after delay
+ setRestarting(true);
+ setTimeout(() => {
+ window.location.reload();
+ }, 4000);
+ } else {
+ // Refresh version info after upgrade
+ setTimeout(() => checkVersion(), 1000);
+ }
}
} catch (e) {
- setUpgradeResult({ ok: false, message: String(e), output: null });
+ setUpgradeResult({ ok: false, message: String(e), output: null, restarting: false });
} finally {
setUpgrading(false);
}
@@ -154,19 +163,27 @@ export const VersionBadge: React.FC = () => {
</span>
</div>
)}
+
+ {/* Restarting Status */}
+ {restarting && (
+ <div className="flex items-center gap-2 px-3 py-2 bg-blue-50 text-blue-700 rounded-md text-sm">
+ <RefreshCw size={16} className="animate-spin" />
+ <span>{t('dashboard.restarting')}</span>
+ </div>
+ )}
</div>
{/* Actions */}
<div className="px-4 py-3 border-t border-border flex gap-2">
<button
onClick={checkVersion}
- disabled={checking}
+ disabled={checking || restarting}
className="flex-1 flex items-center justify-center gap-2 px-3 py-2 text-sm bg-neutral-100 hover:bg-neutral-200 rounded-md transition-colors disabled:opacity-50"
>
<RefreshCw size={14} className={checking ? 'animate-spin' : ''} />
{checking ? t('dashboard.checking') : t('dashboard.checkUpdate')}
</button>
- {hasUpdate && (
+ {hasUpdate && !restarting && (
<button
onClick={handleUpgrade}
disabled={upgrading}
diff --git a/ui/src/context/ApiContext.tsx b/ui/src/context/ApiContext.tsx
index 0512d9b12..218ab2b6d 100644
--- a/ui/src/context/ApiContext.tsx
+++ b/ui/src/context/ApiContext.tsx
@@ -34,6 +34,7 @@ export type UpgradeResult = {
ok: boolean;
message: string;
output: string | null;
+ restarting: boolean;
};
const ApiContext = createContext<ApiContextType | undefined>(undefined);
diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json
index bcf490ea5..86c555689 100644
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@ -189,9 +189,10 @@
"upgrading": "Upgrading...",
"upToDate": "You're up to date",
"checkFailed": "Check failed",
- "upgradeSuccess": "Upgrade successful! Please restart vibe.",
+ "upgradeSuccess": "Upgrade successful!",
"upgradeFailed": "Upgrade failed",
- "updateHint": "Update from {{from}} to {{to}}"
+ "updateHint": "Update from {{from}} to {{to}}",
+ "restarting": "Restarting..."
},
"doctor": {
"title": "System Status",
diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.json
index 9961cfb1e..5e3a5c40b 100644
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@ -189,9 +189,10 @@
"upgrading": "更新中...",
"upToDate": "已是最新版本",
"checkFailed": "检查失败",
- "upgradeSuccess": "更新成功!请重启 vibe。",
+ "upgradeSuccess": "更新成功!",
"upgradeFailed": "更新失败",
- "updateHint": "从 {{from}} 更新到 {{to}}"
+ "updateHint": "从 {{from}} 更新到 {{to}}",
+ "restarting": "正在重启..."
},
"doctor": {
"title": "系统状态",
diff --git a/vibe/api.py b/vibe/api.py
index 873907285..c61a596f4 100644
--- a/vibe/api.py
+++ b/vibe/api.py
@@ -345,11 +345,14 @@ def get_version_info() -> dict:
return result
-def do_upgrade() -> dict:
+def do_upgrade(auto_restart: bool = True) -> dict:
"""Perform upgrade to latest version.
+ Args:
+ auto_restart: If True, restart vibe after successful upgrade
+
Returns:
- {"ok": bool, "message": str, "output": str | None}
+ {"ok": bool, "message": str, "output": str | None, "restarting": bool}
"""
# Determine upgrade method
uv_path = shutil.which("uv")
@@ -360,24 +363,43 @@ def do_upgrade() -> dict:
elif pip_path:
cmd = [pip_path, "install", "--upgrade", "vibe-remote"]
else:
- return {"ok": False, "message": "Neither uv nor pip found", "output": None}
+ return {"ok": False, "message": "Neither uv nor pip found", "output": None, "restarting": False}
try:
result = subprocess.run(cmd, capture_output=True, text=True, timeout=120)
if result.returncode == 0:
+ restarting = False
+ if auto_restart:
+ # Schedule restart in background after response is sent
+ # Use 'vibe' command which will restart both service and UI
+ vibe_path = shutil.which("vibe")
+ if vibe_path:
+ # Start restart process detached, with delay to allow response to be sent
+ restart_cmd = f"sleep 2 && {vibe_path}"
+ subprocess.Popen(
+ restart_cmd,
+ shell=True,
+ stdout=subprocess.DEVNULL,
+ stderr=subprocess.DEVNULL,
+ start_new_session=True,
+ )
+ restarting = True
+
return {
"ok": True,
- "message": "Upgrade successful. Please restart vibe.",
+ "message": "Upgrade successful." + (" Restarting..." if restarting else " Please restart vibe."),
"output": result.stdout,
+ "restarting": restarting,
}
else:
return {
"ok": False,
"message": "Upgrade failed",
"output": result.stderr or result.stdout,
+ "restarting": False,
}
except subprocess.TimeoutExpired:
- return {"ok": False, "message": "Upgrade timed out", "output": None}
+ return {"ok": False, "message": "Upgrade timed out", "output": None, "restarting": False}
except Exception as e:
- return {"ok": False, "message": str(e), "output": None}
+ return {"ok": False, "message": str(e), "output": None, "restarting": False}