Add the SQUID dashboard tab and make a stopped server stay stopped after updating

The Dashboard tab (shown with SQUID Playerbots) downloads the dashboard release of the
bots' release series, starts it on a free local port and shows it in the window. After an
update, a server that was stopped stays stopped unless the owner asked for it to start.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ДмитрийandClaude Sonnet 5.5 committed 2026-10-08 07:33:07 +05:00
1 parent 4c4f8bbb3e
commit 838cc07e73
17 files changed
+564 -17

No files matched your search

+17 -1
View File
@@ -827,7 +827,23 @@ const de: Partial<Record<keyof typeof en, string>> = {
"set.searchAll": "Alle Einstellungen nach Name oder Beschreibung durchsuchen…",
"set.search": "Einstellungen durchsuchen…",
"upd.current": "Du bist auf dem neuesten Stand (Version {v}).",
"upd.startAfter": "Server nach dem Update starten (ausschalten, damit er nach dem Update wieder angehalten wird)",
"nav.dashboard": "Dashboard",
"q.dashboard": "Was tun die Bots gerade?",
"dash.title": "Bot-Dashboard",
"dash.intro": "SQUIDs Live-Seite zu den Bots: wo sie sind, was sie tun, was sie finden. Läuft nur auf diesem Computer.",
"dash.notInstalled": "Das Dashboard ist noch nicht installiert.",
"dash.willInstall": "Die zu deinen Bots {v} passende Version wird heruntergeladen.",
"dash.noSquid": "Die Version deiner SQUID-Bots konnte nicht gelesen werden.",
"dash.install": "Dashboard herunterladen",
"dash.versions": "Dashboard {dash} für Bots {bots}",
"dash.running": "läuft",
"dash.stopped": "angehalten",
"dash.mismatch": "Dieses Dashboard gehört nicht zu deinen Bots {bots}. Aktualisiere es, damit die Versionen passen.",
"dash.start": "Dashboard starten",
"dash.stop": "Dashboard anhalten",
"dash.openBrowser": "Im Browser öffnen",
"dash.update": "Dashboard aktualisieren",
"upd.startAfter": "Server nach dem Update starten (sonst bleibt ein angehaltener Server angehalten)",
"client.startAfter": "Spiel nach dem Client-Update starten",
"bk.folder": "Sicherungsordner",
"bk.folderDefault": "Standard",
+17 -1
View File
@@ -850,7 +850,23 @@ const en = {
"set.searchAll": "Search all settings by name or description…",
"set.search": "Search settings…",
"upd.current": "You are up to date (version {v}).",
"upd.startAfter": "Start the server after updating it (turn off to stop it again once the update is done)",
"nav.dashboard": "Dashboard",
"q.dashboard": "What are the bots doing right now?",
"dash.title": "Bot dashboard",
"dash.intro": "SQUID's live page for the bots: where they are, what they do, what they find. It runs on this computer only.",
"dash.notInstalled": "The dashboard is not installed yet.",
"dash.willInstall": "The release that matches your bots {v} will be downloaded.",
"dash.noSquid": "The version of your SQUID bots could not be read.",
"dash.install": "Download the dashboard",
"dash.versions": "Dashboard {dash} for bots {bots}",
"dash.running": "running",
"dash.stopped": "stopped",
"dash.mismatch": "This dashboard does not belong to your bots {bots}. Update it so that they match.",
"dash.start": "Start the dashboard",
"dash.stop": "Stop the dashboard",
"dash.openBrowser": "Open in the browser",
"dash.update": "Update the dashboard",
"upd.startAfter": "Start the server after updating it (otherwise a stopped server stays stopped)",
"client.startAfter": "Start the game after the client has been updated",
"bk.folder": "Backup folder",
"bk.folderDefault": "default",
+17 -1
View File
@@ -827,7 +827,23 @@ const es: Partial<Record<keyof typeof en, string>> = {
"set.searchAll": "Buscar en todos los ajustes por nombre o descripción…",
"set.search": "Buscar ajustes…",
"upd.current": "Estás al día (versión {v}).",
"upd.startAfter": "Iniciar el servidor tras actualizarlo (desactívalo para detenerlo de nuevo al terminar)",
"nav.dashboard": "Panel",
"q.dashboard": "¿Qué están haciendo los bots ahora?",
"dash.title": "Panel de bots",
"dash.intro": "La página en vivo de SQUID sobre los bots: dónde están, qué hacen, qué encuentran. Funciona solo en este equipo.",
"dash.notInstalled": "El panel aún no está instalado.",
"dash.willInstall": "Se descargará la versión que corresponde a tus bots {v}.",
"dash.noSquid": "No se pudo leer la versión de tus bots SQUID.",
"dash.install": "Descargar el panel",
"dash.versions": "Panel {dash} para bots {bots}",
"dash.running": "en marcha",
"dash.stopped": "detenido",
"dash.mismatch": "Este panel no corresponde a tus bots {bots}. Actualízalo para que coincidan.",
"dash.start": "Iniciar el panel",
"dash.stop": "Detener el panel",
"dash.openBrowser": "Abrir en el navegador",
"dash.update": "Actualizar el panel",
"upd.startAfter": "Iniciar el servidor tras actualizarlo (si no, un servidor detenido sigue detenido)",
"client.startAfter": "Iniciar el juego tras actualizar el cliente",
"bk.folder": "Carpeta de copias de seguridad",
"bk.folderDefault": "predeterminada",
+17 -1
View File
@@ -827,7 +827,23 @@ const fr: Partial<Record<keyof typeof en, string>> = {
"set.searchAll": "Rechercher dans tous les réglages par nom ou description…",
"set.search": "Rechercher un réglage…",
"upd.current": "Vous êtes à jour (version {v}).",
"upd.startAfter": "Démarrer le serveur après la mise à jour (désactivez pour qu’il soit arrêté à nouveau ensuite)",
"nav.dashboard": "Tableau de bord",
"q.dashboard": "Que font les bots en ce moment ?",
"dash.title": "Tableau de bord des bots",
"dash.intro": "La page en direct de SQUID sur les bots : où ils sont, ce qu’ils font, ce qu’ils trouvent. Elle ne tourne que sur cet ordinateur.",
"dash.notInstalled": "Le tableau de bord n’est pas encore installé.",
"dash.willInstall": "La version qui correspond à vos bots {v} sera téléchargée.",
"dash.noSquid": "La version de vos bots SQUID n’a pas pu être lue.",
"dash.install": "Télécharger le tableau de bord",
"dash.versions": "Tableau de bord {dash} pour les bots {bots}",
"dash.running": "en cours",
"dash.stopped": "arrêté",
"dash.mismatch": "Ce tableau de bord ne correspond pas à vos bots {bots}. Mettez-le à jour pour que les versions concordent.",
"dash.start": "Démarrer le tableau de bord",
"dash.stop": "Arrêter le tableau de bord",
"dash.openBrowser": "Ouvrir dans le navigateur",
"dash.update": "Mettre à jour le tableau de bord",
"upd.startAfter": "Démarrer le serveur après la mise à jour (sinon un serveur arrêté reste arrêté)",
"client.startAfter": "Lancer le jeu après la mise à jour du client",
"bk.folder": "Dossier des sauvegardes",
"bk.folderDefault": "par défaut",
+17 -1
View File
@@ -848,7 +848,23 @@ const ru: Partial<Record<keyof typeof en, string>> = {
"set.searchAll": "Поиск по всем настройкам: название или описание…",
"set.search": "Поиск по настройкам…",
"upd.current": "У вас последняя версия ({v}).",
"upd.startAfter": "Запускать сервер после обновления (выключите, чтобы он снова остановился после обновления)",
"nav.dashboard": "Панель",
"q.dashboard": "Что сейчас делают боты?",
"dash.title": "Панель ботов",
"dash.intro": "Страница SQUID о ботах в реальном времени: где они, что делают, что находят. Работает только на этом компьютере.",
"dash.notInstalled": "Панель ещё не установлена.",
"dash.willInstall": "Будет скачан выпуск, подходящий к вашим ботам {v}.",
"dash.noSquid": "Не удалось определить версию ботов SQUID.",
"dash.install": "Скачать панель",
"dash.versions": "Панель {dash} для ботов {bots}",
"dash.running": "работает",
"dash.stopped": "остановлена",
"dash.mismatch": "Эта панель не соответствует вашим ботам {bots}. Обновите её, чтобы версии совпадали.",
"dash.start": "Запустить панель",
"dash.stop": "Остановить панель",
"dash.openBrowser": "Открыть в браузере",
"dash.update": "Обновить панель",
"upd.startAfter": "Запускать сервер после обновления (иначе выключенный сервер останется выключенным)",
"client.startAfter": "Запускать игру после обновления клиента",
"bk.folder": "Папка резервных копий",
"bk.folderDefault": "по умолчанию",
+17 -1
View File
@@ -827,7 +827,23 @@ const zh = {
"set.searchAll": "按名称或描述搜索全部设置…",
"set.search": "搜索设置…",
"upd.current": "当前已是最新版本 ({v})。",
"upd.startAfter": "更新后启动服务器(关闭则更新完成后再次停止)",
"nav.dashboard": "仪表盘",
"q.dashboard": "机器人现在在做什么?",
"dash.title": "机器人仪表盘",
"dash.intro": "SQUID 的机器人实时页面:它们在哪里、在做什么、发现了什么。仅在本机运行。",
"dash.notInstalled": "尚未安装仪表盘。",
"dash.willInstall": "将下载与你的机器人 {v} 对应的版本。",
"dash.noSquid": "无法读取你的 SQUID 机器人版本。",
"dash.install": "下载仪表盘",
"dash.versions": "适用于机器人 {bots} 的仪表盘 {dash}",
"dash.running": "运行中",
"dash.stopped": "已停止",
"dash.mismatch": "此仪表盘与你的机器人 {bots} 不匹配。请更新使版本一致。",
"dash.start": "启动仪表盘",
"dash.stop": "停止仪表盘",
"dash.openBrowser": "在浏览器中打开",
"dash.update": "更新仪表盘",
"upd.startAfter": "更新后启动服务器(否则已停止的服务器保持停止)",
"client.startAfter": "更新客户端后启动游戏",
"bk.folder": "备份文件夹",
"bk.folderDefault": "默认",
+14
View File
@@ -78,6 +78,16 @@ export interface DriverOutcome {
output: string;
}
export interface DashboardStatus {
installed: boolean;
tag: string | null;
squid_tag: string | null;
matches: boolean;
running: boolean;
port: number;
url: string;
}
export interface BackupLocation {
path: string;
default_path: string;
@@ -431,6 +441,10 @@ export const api = {
save: (id: string, scope: Scope, changes: Record<string, JsonValue>) => invoke<SaveReport>("save_settings", { id, scope, changes }),
presets: (scope: Scope) => invoke<PresetInfo[]>("list_presets", { scope }),
backups: (id: string) => invoke<RecoveryPoint[]>("list_backups", { id }),
dashboardStatus: (id: string) => invoke<DashboardStatus>("dashboard_status", { id }),
dashboardInstall: (id: string) => invoke<DashboardStatus>("dashboard_install", { id }),
dashboardStart: (id: string) => invoke<DashboardStatus>("dashboard_start", { id }),
dashboardStop: (id: string) => invoke<DashboardStatus>("dashboard_stop", { id }),
backupLocation: (id: string) => invoke<BackupLocation>("backup_location", { id }),
/** `null` goes back to the default folder next to the server. */
setBackupLocation: (id: string, path: string | null) => invoke<BackupLocation>("set_backup_location", { id, path }),
+4 -2
View File
@@ -86,6 +86,9 @@ export async function applyServerUpdate(id: string, opts?: { choices: Record<str
const current = get(id);
if (current.applying || current.stateError || (current.result && "pending" in current.result)) return false;
if (!opts && (!p || p.conflicts.length > 0)) return false;
// The update stops a running server and proves the new build by starting it; a server that was stopped stays stopped
// unless the owner asked for it to start.
const wasRunning = await api.status(id).then((s) => [s.observed.mysql, s.observed.auth, s.observed.world].some((x) => x.state === "running" || x.state === "starting")).catch(() => true);
set(id, { applying: true, step: null, percent: 0, error: null, uiError: null, result: null });
let un: (() => void) | undefined;
try {
@@ -96,8 +99,7 @@ export async function applyServerUpdate(id: string, opts?: { choices: Record<str
try {
const out = await api.applyUpdate(id, opts?.choices ?? {}, opts?.source);
set(id, { result: out.txn.state === "committed" ? { committed: out.txn.to_version ?? "" } : { pending: out.txn } });
// The update proved the new build starts and left it running; the owner may prefer it stopped again.
if (out.txn.state === "committed" && !startAfterUpdate("server", id)) await api.stop(id).catch(() => undefined);
if (out.txn.state === "committed" && !wasRunning && !startAfterUpdate("server", id)) await api.stop(id).catch(() => undefined);
return true;
} catch (e) {
const ui = asUiError(e);
+3 -3
View File
@@ -1,13 +1,13 @@
import { useState } from "react";
/**
* What to do when an update has finished: leave the server running (the default, as the update proves the new build
* starts) or stop it again, and whether to open the game after a client update (off by default).
* Whether a finished update starts things. Off by default for both: updating a stopped server leaves it stopped (a
* server that was running is started again, as the update had to stop it) and a client update does not open the game.
*/
export type AfterUpdate = "server" | "client";
const key = (kind: AfterUpdate, id: string) => `coa-start-after-${kind}-update:${id}`;
const fallback = (kind: AfterUpdate) => kind === "server";
const fallback = (_kind: AfterUpdate) => false;
export function startAfterUpdate(kind: AfterUpdate, id: string): boolean {
try {
+109
View File
@@ -0,0 +1,109 @@
import { useCallback, useEffect, useState } from "react";
import { listen } from "@tauri-apps/api/event";
import { Loader2 } from "lucide-react";
import { api, asUiError, type DashboardStatus, type UiError } from "@/lib/api";
import { Button } from "@/components/ui/button";
import { Card } from "@/components/ui/card";
import { useHuman, useT } from "@/i18n";
/** SQUID's bot dashboard: installed from the release that matches the bots, started on a free port, shown here. */
export function DashboardPage({ serverId }: { serverId: string }) {
const t = useT();
const human = useHuman();
const [status, setStatus] = useState<DashboardStatus | null>(null);
const [busy, setBusy] = useState<"install" | "start" | "stop" | null>(null);
const [step, setStep] = useState<string | null>(null);
const [error, setError] = useState<UiError | null>(null);
const load = useCallback(async () => {
try { setStatus(await api.dashboardStatus(serverId)); } catch (e) { setError(asUiError(e)); }
}, [serverId]);
useEffect(() => {
void load();
const un = listen<string>("dashboard-progress", (e) => setStep(e.payload));
return () => { void un.then((f) => f()); };
}, [load]);
async function run(kind: "install" | "start" | "stop", fn: () => Promise<DashboardStatus>) {
setBusy(kind); setError(null); setStep(null);
try { setStatus(await fn()); } catch (e) { setError(asUiError(e)); await load(); }
finally { setBusy(null); setStep(null); }
}
const install = () => run("install", () => api.dashboardInstall(serverId));
return (
<div className="flex h-full max-w-6xl flex-col">
<h1 className="text-2xl font-semibold">{t("dash.title")}</h1>
<p className="mt-1 text-muted">{t("dash.intro")}</p>
{!status && !error && <p className="mt-6 text-muted">{t("overview.checking")}</p>}
{status && (
<Card className="mt-5 p-5">
{!status.installed ? (
<>
<p className="font-medium">{t("dash.notInstalled")}</p>
<p className="mt-1 text-sm text-muted">{status.squid_tag ? t("dash.willInstall", { v: status.squid_tag }) : t("dash.noSquid")}</p>
<Button className="mt-4" variant="primary" disabled={!!busy || !status.squid_tag} onClick={() => void install()}>
{busy === "install" && <Loader2 className="h-4 w-4 animate-spin" aria-hidden />}
{t("dash.install")}
</Button>
</>
) : (
<>
<p className="text-sm text-muted">
{t("dash.versions", { dash: status.tag ?? "?", bots: status.squid_tag ?? "?" })}
{" · "}
<span className={status.running ? "text-ok" : "text-muted"}>{status.running ? t("dash.running") : t("dash.stopped")}</span>
</p>
{!status.matches && status.squid_tag && (
<p className="mt-2 text-sm text-warn">{t("dash.mismatch", { bots: status.squid_tag })}</p>
)}
<div className="mt-4 flex flex-wrap items-center gap-2">
{status.running ? (
<>
<Button size="sm" variant="secondary" disabled={!!busy} onClick={() => void run("stop", () => api.dashboardStop(serverId))}>
{busy === "stop" && <Loader2 className="h-4 w-4 animate-spin" aria-hidden />}
{t("dash.stop")}
</Button>
<Button size="sm" variant="ghost" onClick={() => void api.openLink(status.url)}>{t("dash.openBrowser")}</Button>
</>
) : (
<Button size="sm" variant="primary" disabled={!!busy} onClick={() => void run("start", () => api.dashboardStart(serverId))}>
{busy === "start" && <Loader2 className="h-4 w-4 animate-spin" aria-hidden />}
{t("dash.start")}
</Button>
)}
{!status.matches && status.squid_tag && (
<Button size="sm" disabled={!!busy} onClick={() => void install()}>
{busy === "install" && <Loader2 className="h-4 w-4 animate-spin" aria-hidden />}
{t("dash.update")}
</Button>
)}
</div>
</>
)}
{busy === "install" && <p className="mt-3 text-sm text-muted" role="status">{step ?? t("bk.working")}</p>}
</Card>
)}
{error && (
<Card className="mt-4 border-bad/40 p-4" role="alert">
<p className="selectable whitespace-pre-wrap break-words text-sm text-bad">{error.human.code === "unknown" ? error.technical : human(error.human).message}</p>
<button className="mt-1 cursor-pointer text-xs text-muted underline" onClick={() => void navigator.clipboard.writeText(error.technical)}>{t("common.copyError")}</button>
</Card>
)}
{status?.running && (
<iframe
key={status.url}
title={t("dash.title")}
src={status.url}
className="mt-4 min-h-[480px] w-full flex-1 rounded-card border border-line bg-black/30"
/>
)}
</div>
);
}
+7 -3
View File
@@ -1,5 +1,5 @@
import { useCallback, useEffect, useState } from "react";
import { Archive, Bot, Bug, Gauge, Globe, Puzzle, Server, Settings, Terminal, Users, type LucideIcon } from "lucide-react";
import { Archive, BarChart3, Bot, Bug, Gauge, Globe, Puzzle, Server, Settings, Terminal, Users, type LucideIcon } from "lucide-react";
import { api, type ServerSummary } from "@/lib/api";
import { useT, type Key } from "@/i18n";
import logo from "@/assets/logo.png";
@@ -14,15 +14,17 @@ import { FriendsPage } from "@/screens/FriendsPage";
import { ReportPage } from "@/screens/ReportPage";
import { ModulesPage } from "@/screens/ModulesPage";
import { ConsolePage } from "@/screens/ConsolePage";
import { DashboardPage } from "@/screens/DashboardPage";
import { Button } from "@/components/ui/button";
import { startServerUpdatePolling, useServerUpdate } from "@/lib/serverUpdate";
import { startClientPolling } from "@/lib/clientUpdate";
type Page = "overview" | "bots" | "server" | "modules" | "players" | "friends" | "backups" | "console" | "report" | "settings";
type Page = "overview" | "bots" | "dashboard" | "server" | "modules" | "players" | "friends" | "backups" | "console" | "report" | "settings";
const NAV: { id: Page; label: Key; icon: LucideIcon; question: Key }[] = [
{ id: "overview", label: "nav.overview", icon: Gauge, question: "q.overview" },
{ id: "bots", label: "nav.bots", icon: Bot, question: "q.bots" },
{ id: "dashboard", label: "nav.dashboard", icon: BarChart3, question: "q.dashboard" },
{ id: "server", label: "nav.server", icon: Server, question: "q.server" },
{ id: "modules", label: "nav.modules", icon: Puzzle, question: "q.modules" },
{ id: "players", label: "nav.players", icon: Users, question: "q.players" },
@@ -84,7 +86,7 @@ export function Shell(props: {
{t("app.name")}
</div>
<ul className="flex flex-col gap-0.5">
{NAV.filter((n) => !hiddenPages.includes(n.id)).map(({ id, label, icon: Icon }) => (
{NAV.filter((n) => !hiddenPages.includes(n.id) && (n.id !== "dashboard" || botModule === "playerbots")).map(({ id, label, icon: Icon }) => (
<li key={id}>
<button
onClick={() => setPage(id)}
@@ -130,6 +132,8 @@ export function Shell(props: {
<Overview key={server.id} server={server} companions={botModule === "companions" && !hiddenPages.includes("bots")} onForget={() => props.onForget(server.id)} onOpenUpdates={() => setPage("settings")} onRealmChanged={reloadModules} onReport={() => setPage("report")} />
) : page === "bots" || page === "server" ? (
<SettingsPage key={`${server.id}-${page}-${botModule}`} serverId={server.id} scope={page} botModule={botModule} title={t(current.label)} question={t(current.question)} />
) : page === "dashboard" ? (
<DashboardPage key={server.id} serverId={server.id} />
) : page === "console" ? (
<ConsolePage key={server.id} serverId={server.id} />
) : page === "modules" ? (