feat(webui): notify when a newer release is available

Advisory, read-only update check: the core polls GitHub's latest stable release, compares it against the running build, and surfaces a notice in the sidebar footer plus a detailed card (changelog + download link + platform-matched asset hint) in Settings → About.

SnowLuma never downloads or applies anything itself — cross-platform self-update is a minefield (Windows locks loaded .node/.dll, Docker bakes the app into image layers, bare installs have no supervisor), so the user downloads and applies manually.

The backend caches results for 6h to stay under GitHub's unauthenticated rate limit, degrades silently on failure, and can be disabled via SNOWLUMA_UPDATE_CHECK=0.
This commit is contained in:
DrSmoothl committed 2026-06-05 16:08:38 +08:00
1 parent 28db1d1079
commit 56dc934106
9 files changed
+362 -5

No files matched your search

+22 -1
View File
@@ -8,7 +8,7 @@ import { ConfirmDialog } from '@/components/confirm-dialog';
import { Skeleton } from '@/components/ui/skeleton';
import { AppStateProvider } from '@/contexts/AppStateContext';
import { useSession } from '@/contexts/SessionContext';
import type { AccountConnections, HookProcessInfo, QQInfo, SystemInfo } from '@/types';
import type { AccountConnections, HookProcessInfo, QQInfo, SystemInfo, UpdateInfo } from '@/types';
/**
* The layout route. Owns the live state shared across the four pages
@@ -25,6 +25,7 @@ export function AppLayout() {
const [processList, setProcessList] = useState<HookProcessInfo[]>([]);
const [systemInfo, setSystemInfo] = useState<SystemInfo | null>(null);
const [connections, setConnections] = useState<AccountConnections[]>([]);
const [updateInfo, setUpdateInfo] = useState<UpdateInfo | null>(null);
const [selectedUin, setSelectedUin] = useState<string | null>(null);
const refreshQqList = useCallback(async () => {
@@ -59,6 +60,14 @@ export function AppLayout() {
}
}, [api]);
const refreshUpdate = useCallback(async (force = false) => {
try {
setUpdateInfo(await api.update.check(force));
} catch (e) {
console.error('update-check', e);
}
}, [api]);
const { ops: processOps, unloadFailedAlert, dismissUnloadFailedAlert } = useHookProcessOps({
onAfterOp: refreshProcesses,
});
@@ -78,12 +87,22 @@ export function AppLayout() {
};
}, [pollInterval, refreshQqList, refreshProcesses, refreshSystem, refreshConnections]);
// Update check runs on its own slow cadence (6h), independent of the fast
// list-polling above — GitHub's API is rate-limited, the result rarely
// changes, and the server caches it anyway, so this is cheap.
useEffect(() => {
refreshUpdate();
const id = setInterval(() => refreshUpdate(), 6 * 60 * 60 * 1000);
return () => clearInterval(id);
}, [refreshUpdate]);
const handleLogout = useCallback(async () => {
await api.logout();
setQqList([]);
setProcessList([]);
setSystemInfo(null);
setConnections([]);
setUpdateInfo(null);
setSelectedUin(null);
session.onLogoutComplete();
}, [api, session]);
@@ -95,12 +114,14 @@ export function AppLayout() {
processList,
systemInfo,
connections,
updateInfo,
selectedUin,
setSelectedUin,
processOps,
refreshProcesses,
refreshSystem,
refreshConnections,
refreshUpdate,
onLogout: handleLogout,
}}
>