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
refactor(ui): move version badge to header with popup
cyhhao3b1783da8d24
diff --git a/ui/src/components/AppShell.tsx b/ui/src/components/AppShell.tsxindex e7d9d8d63..6bfd9dd3b 100644--- a/ui/src/components/AppShell.tsx+++ b/ui/src/components/AppShell.tsx@@ -4,6 +4,7 @@ import { LayoutDashboard, MessageSquare, Activity } from 'lucide-react';import { useTranslation } from 'react-i18next';import { useStatus } from '../context/StatusContext';import { LanguageSwitcher } from './LanguageSwitcher';+import { VersionBadge } from './VersionBadge';import clsx from 'clsx';import logoImg from '../assets/logo.png';@@ -41,6 +42,7 @@ export const AppShell: React.FC = () => {<h1 className="text-xl font-bold font-display tracking-tight flex items-center gap-2"><img src={logoImg} alt="Vibe Remote Logo" className="w-6 h-6 rounded-md" />{t('appShell.title')}+ <VersionBadge /></h1></div>diff --git a/ui/src/components/Dashboard.tsx b/ui/src/components/Dashboard.tsxindex ae9f72bb2..8bdfa7c03 100644--- a/ui/src/components/Dashboard.tsx+++ b/ui/src/components/Dashboard.tsx@@ -1,14 +1,12 @@import React from 'react';import { useTranslation } from 'react-i18next';import { useStatus } from '../context/StatusContext';-import { useApi, type VersionInfo } from '../context/ApiContext';-import { Play, Square, RotateCw, Activity, Terminal, CheckCircle, MessageSquare, Server, Settings, Info, Download, Package } from 'lucide-react';+import { Play, Square, RotateCw, Activity, Terminal, CheckCircle, MessageSquare, Server, Settings, Info } from 'lucide-react';import { Link } from 'react-router-dom';export const Dashboard: React.FC = () => {const { t } = useTranslation();const { status, control } = useStatus();- const api = useApi();const [loading, setLoading] = React.useState(false);const [config, setConfig] = React.useState<any>({});const [doctor, setDoctor] = React.useState<any>(null);@@ -17,12 +15,6 @@ export const Dashboard: React.FC = () => {const [uiMessage, setUiMessage] = React.useState<string | null>(null);const [diagnosticsSaving, setDiagnosticsSaving] = React.useState(false);const [diagnosticsMessage, setDiagnosticsMessage] = React.useState<string | null>(null);-- // Version and upgrade state- const [versionInfo, setVersionInfo] = React.useState<VersionInfo | null>(null);- const [versionLoading, setVersionLoading] = React.useState(false);- const [upgrading, setUpgrading] = React.useState(false);- const [upgradeMessage, setUpgradeMessage] = React.useState<string | null>(null);const handleAction = async (action: string) => {setLoading(true);@@ -123,8 +115,6 @@ export const Dashboard: React.FC = () => {if (doctorRes.ok) {setDoctor(await doctorRes.json());}- // Load version info- checkForUpdates();} catch {// ignore}@@ -132,37 +122,6 @@ export const Dashboard: React.FC = () => {load();}, []);- const checkForUpdates = async () => {- setVersionLoading(true);- try {- const info = await api.getVersion();- setVersionInfo(info);- } catch {- // ignore- } finally {- setVersionLoading(false);- }- };-- const handleUpgrade = async () => {- setUpgrading(true);- setUpgradeMessage(null);- try {- const result = await api.doUpgrade();- if (result.ok) {- setUpgradeMessage(t('dashboard.upgradeSuccess'));- // Refresh version info after upgrade- setTimeout(() => checkForUpdates(), 2000);- } else {- setUpgradeMessage(result.message || t('dashboard.upgradeFailed'));- }- } catch (e) {- setUpgradeMessage(t('dashboard.upgradeFailed'));- } finally {- setUpgrading(false);- }- };-React.useEffect(() => {if (!settingsMessage) return;const timer = window.setTimeout(() => {@@ -500,66 +459,6 @@ export const Dashboard: React.FC = () => {</button></div></div>-- {/* Version & Update Card */}- <div className="bg-panel rounded-xl border border-border p-6 shadow-sm">- <div className="flex items-center justify-between mb-4">- <h3 className="font-semibold flex items-center gap-2 text-text"><Package size={18} /> {t('dashboard.versionAndUpdate')}</h3>- <button- onClick={checkForUpdates}- disabled={versionLoading}- className="text-sm text-accent hover:underline font-medium disabled:opacity-50"- >- {versionLoading ? t('dashboard.checking') : t('dashboard.checkUpdate')}- </button>- </div>- <div className="space-y-3 text-sm">- <div className="flex justify-between items-center">- <span className="text-muted">{t('dashboard.currentVersion')}</span>- <span className="font-mono text-xs text-text">{versionInfo?.current || '-'}</span>- </div>- {versionInfo?.latest && (- <div className="flex justify-between items-center">- <span className="text-muted">{t('dashboard.latestVersion')}</span>- <span className="font-mono text-xs text-text">{versionInfo.latest}</span>- </div>- )}- {versionInfo?.has_update && (- <div className="mt-3 p-3 bg-success/10 border border-success/20 rounded-lg">- <div className="flex items-center justify-between">- <div className="flex items-center gap-2">- <Download size={16} className="text-success" />- <span className="text-success font-medium text-sm">{t('dashboard.updateAvailable')}</span>- </div>- <button- onClick={handleUpgrade}- disabled={upgrading}- className="px-3 py-1.5 bg-success text-white rounded-md text-xs font-semibold disabled:opacity-50 flex items-center gap-1"- >- <Download size={12} /> {upgrading ? t('dashboard.upgrading') : t('dashboard.upgradeNow')}- </button>- </div>- <p className="text-xs text-success/80 mt-2">- {t('dashboard.updateHint', { from: versionInfo.current, to: versionInfo.latest })}- </p>- </div>- )}- {versionInfo && !versionInfo.has_update && !versionInfo.error && (- <div className="flex items-center gap-2 text-success">- <CheckCircle size={14} />- <span className="text-xs">{t('dashboard.upToDate')}</span>- </div>- )}- {versionInfo?.error && (- <div className="text-xs text-warning">{t('dashboard.checkFailed')}: {versionInfo.error}</div>- )}- {upgradeMessage && (- <div className={`text-xs ${upgradeMessage.includes('success') || upgradeMessage.includes('成功') ? 'text-success' : 'text-warning'}`}>- {upgradeMessage}- </div>- )}- </div>- </div></div>diff --git a/ui/src/components/VersionBadge.tsx b/ui/src/components/VersionBadge.tsxnew file mode 100644index 000000000..1db420e28--- /dev/null+++ b/ui/src/components/VersionBadge.tsx@@ -0,0 +1,184 @@+import React from 'react';+import { useTranslation } from 'react-i18next';+import { useApi, type VersionInfo, type UpgradeResult } from '../context/ApiContext';+import { Download, X, RefreshCw, Check, AlertCircle } from 'lucide-react';+import clsx from 'clsx';++export const VersionBadge: React.FC = () => {+ const { t } = useTranslation();+ const api = useApi();+ const [versionInfo, setVersionInfo] = React.useState<VersionInfo | null>(null);+ const [isPopupOpen, setIsPopupOpen] = React.useState(false);+ const [checking, setChecking] = React.useState(false);+ const [upgrading, setUpgrading] = React.useState(false);+ const [upgradeResult, setUpgradeResult] = React.useState<UpgradeResult | null>(null);+ const popupRef = React.useRef<HTMLDivElement>(null);++ // Check version on mount+ React.useEffect(() => {+ checkVersion();+ }, []);++ // Close popup when clicking outside+ React.useEffect(() => {+ const handleClickOutside = (event: MouseEvent) => {+ if (popupRef.current && !popupRef.current.contains(event.target as Node)) {+ setIsPopupOpen(false);+ }+ };+ if (isPopupOpen) {+ document.addEventListener('mousedown', handleClickOutside);+ }+ return () => document.removeEventListener('mousedown', handleClickOutside);+ }, [isPopupOpen]);++ const checkVersion = async () => {+ setChecking(true);+ try {+ const info = await api.getVersion();+ setVersionInfo(info);+ } catch (e) {+ console.error('Failed to check version:', e);+ } finally {+ setChecking(false);+ }+ };++ const handleUpgrade = async () => {+ setUpgrading(true);+ setUpgradeResult(null);+ try {+ const result = await api.doUpgrade();+ setUpgradeResult(result);+ if (result.ok) {+ // Refresh version info after upgrade+ setTimeout(() => checkVersion(), 1000);+ }+ } catch (e) {+ setUpgradeResult({ ok: false, message: String(e), output: null });+ } finally {+ setUpgrading(false);+ }+ };++ const hasUpdate = versionInfo?.has_update === true;+ const currentVersion = versionInfo?.current || '...';++ return (+ <div className="relative" ref={popupRef}>+ {/* Version Badge */}+ <button+ onClick={() => setIsPopupOpen(!isPopupOpen)}+ className={clsx(+ 'relative px-2 py-0.5 text-xs font-medium rounded-md transition-colors cursor-pointer',+ hasUpdate+ ? 'bg-amber-100 text-amber-800 hover:bg-amber-200'+ : 'bg-neutral-100 text-neutral-600 hover:bg-neutral-200'+ )}+ >+ v{currentVersion}+ {/* Update indicator dot */}+ {hasUpdate && (+ <span className="absolute -top-1 -right-1 w-2.5 h-2.5 bg-amber-500 rounded-full border-2 border-white animate-pulse" />+ )}+ </button>++ {/* Popup */}+ {isPopupOpen && (+ <div className="absolute top-full left-0 mt-2 w-72 bg-white rounded-lg shadow-lg border border-border z-50">+ {/* Header */}+ <div className="flex items-center justify-between px-4 py-3 border-b border-border">+ <span className="font-medium text-sm">{t('dashboard.versionAndUpdate')}</span>+ <button+ onClick={() => setIsPopupOpen(false)}+ className="text-muted hover:text-text p-1 rounded"+ >+ <X size={14} />+ </button>+ </div>++ {/* Content */}+ <div className="p-4 space-y-3">+ {/* Current Version */}+ <div className="flex items-center justify-between text-sm">+ <span className="text-muted">{t('dashboard.currentVersion')}</span>+ <span className="font-mono font-medium">{currentVersion}</span>+ </div>++ {/* Latest Version */}+ {versionInfo?.latest && (+ <div className="flex items-center justify-between text-sm">+ <span className="text-muted">{t('dashboard.latestVersion')}</span>+ <span className="font-mono font-medium">{versionInfo.latest}</span>+ </div>+ )}++ {/* Update Status */}+ {hasUpdate ? (+ <div className="flex items-center gap-2 px-3 py-2 bg-amber-50 text-amber-800 rounded-md text-sm">+ <AlertCircle size={16} />+ <span>+ {t('dashboard.updateHint', {+ from: currentVersion,+ to: versionInfo?.latest+ })}+ </span>+ </div>+ ) : versionInfo && !versionInfo.error ? (+ <div className="flex items-center gap-2 px-3 py-2 bg-green-50 text-green-700 rounded-md text-sm">+ <Check size={16} />+ <span>{t('dashboard.upToDate')}</span>+ </div>+ ) : versionInfo?.error ? (+ <div className="flex items-center gap-2 px-3 py-2 bg-red-50 text-red-700 rounded-md text-sm">+ <AlertCircle size={16} />+ <span>{t('dashboard.checkFailed')}</span>+ </div>+ ) : null}++ {/* Upgrade Result */}+ {upgradeResult && (+ <div+ className={clsx(+ 'flex items-center gap-2 px-3 py-2 rounded-md text-sm',+ upgradeResult.ok+ ? 'bg-green-50 text-green-700'+ : 'bg-red-50 text-red-700'+ )}+ >+ {upgradeResult.ok ? <Check size={16} /> : <AlertCircle size={16} />}+ <span>+ {upgradeResult.ok+ ? t('dashboard.upgradeSuccess')+ : t('dashboard.upgradeFailed')}+ </span>+ </div>+ )}+ </div>++ {/* Actions */}+ <div className="px-4 py-3 border-t border-border flex gap-2">+ <button+ onClick={checkVersion}+ disabled={checking}+ 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 && (+ <button+ onClick={handleUpgrade}+ disabled={upgrading}+ className="flex-1 flex items-center justify-center gap-2 px-3 py-2 text-sm bg-accent text-white hover:bg-accent/90 rounded-md transition-colors disabled:opacity-50"+ >+ <Download size={14} className={upgrading ? 'animate-bounce' : ''} />+ {upgrading ? t('dashboard.upgrading') : t('dashboard.upgradeNow')}+ </button>+ )}+ </div>+ </div>+ )}+ </div>+ );+};