Merge current master into portable characters while retaining 0.7.0

This commit is contained in:
Дмитрий committed 2026-10-19 13:47:05 +05:00
commit f40c0e1324
114 files changed
+6694 -600

No files matched your search

+1 -1
View File
@@ -198,7 +198,7 @@ export function BackupsPage({ serverId }: { serverId: string }) {
<div>
<p className="font-medium">{p.label && p.trigger === "manual" && p.label !== "e2e" ? p.label : trigger(p.trigger)}</p>
<p className="text-sm text-muted">
{w(p.created_at)} · {p.realm === "wildcard" ? "Wildcard" : "CoA"} · {t(`bk.kind.${p.kind}` as Key)} · {size(p.components.reduce((a, c) => a + c.bytes, 0))}
{w(p.created_at)} · {p.realm === "wildcard" ? "Wildcard" : "CoA"} · {t(`bk.kind.${p.kind}` as Key)} · {size(p.components.reduce((a, c) => a + c.bytes, p.mysql_snapshot?.bytes ?? 0))}
</p>
</div>
<div className="flex shrink-0 gap-1">
+9
View File
@@ -1,4 +1,5 @@
import { useEffect, useState } from "react";
import { listen } from "@tauri-apps/api/event";
import { open } from "@tauri-apps/plugin-dialog";
import { api, asUiError, type ClientInfo, type ClientStatus, type UiError } from "@/lib/api";
import { checkClient } from "@/lib/clientUpdate";
@@ -16,6 +17,7 @@ export function ClientCard({ serverId, remote = false }: { serverId: string; rem
const [note, setNote] = useState<string | null>(null);
const [busy, setBusy] = useState(false);
const [status, setStatus] = useState<ClientStatus | null>(null);
const [patchProgress, setPatchProgress] = useState<string | null>(null);
const [dialog, setDialog] = useState<ClientDialogMode | null>(null);
const [playAfter, setPlayAfter] = useStartAfterUpdate("client", serverId);
@@ -25,6 +27,10 @@ export function ClientCard({ serverId, remote = false }: { serverId: string; rem
};
useEffect(() => {
void refresh();
const unlisten = listen<{ id: string; step: string; percent: number }>("custom-races-progress", e => {
if (e.payload.id === serverId) setPatchProgress(`${e.payload.step} (${Math.round(e.payload.percent * 100)}%)`);
});
return () => { void unlisten.then(f => f()); };
}, [serverId]); // eslint-disable-line react-hooks/exhaustive-deps
async function run(fn: () => Promise<string | void>) {
@@ -40,6 +46,7 @@ export function ClientCard({ serverId, remote = false }: { serverId: string; rem
setError(asUiError(e));
} finally {
setBusy(false);
setPatchProgress(null);
}
}
@@ -111,11 +118,13 @@ export function ClientCard({ serverId, remote = false }: { serverId: string; rem
{status && !status.managed && (
<Button size="sm" disabled={busy} onClick={() => setDialog("track")}>{t("client.track.button")}</Button>
)}
{remote && <Button size="sm" disabled={busy} onClick={() => void run(() => api.customRacesInstall(serverId))}>{t("client.races.install")}</Button>}
<Button size="sm" variant="ghost" disabled={busy} onClick={() => void choose()}>{t("client.changeFolder")}</Button>
<Button size="sm" variant="ghost" disabled={busy} onClick={() => setDialog("setup")}>{t("client.downloadInstead")}</Button>
</div>
</>
)}
{patchProgress && <p className="mt-3 text-sm text-muted" role="status">{patchProgress}</p>}
{note && <p className="mt-3 text-sm text-ok" role="status">{note}</p>}
{error && <p className="mt-3 text-sm text-bad" role="alert">{error.human.code === "unknown" ? error.technical : human(error.human).message}</p>}
{dialog && (
+1 -1
View File
@@ -170,7 +170,7 @@ export function FriendsPage({ serverId }: { serverId: string }) {
<ul className="mt-2 divide-y divide-line">
<Line ok={st.server_running}>{t("fr.st.running")}</Line>
<Line ok={st.servers_open}>{t("fr.st.open")}</Line>
<Line ok={st.firewall.auth && st.firewall.world}>{t("fr.st.firewall")}</Line>
{st.firewall && <Line ok={st.firewall.auth && st.firewall.world}>{t("fr.st.firewall")}</Line>}
<Line ok={st.exposure.filter((e) => e.what === "database" || e.what === "server console").every((e) => !e.reachable_from_network)}>
{t("fr.st.private")}
</Line>
+44
View File
@@ -0,0 +1,44 @@
import { useEffect, useState } from "react";
import { open } from "@tauri-apps/plugin-dialog";
import { api, asUiError } from "@/lib/api";
import { Button } from "@/components/ui/button";
import { Card } from "@/components/ui/card";
import { useT } from "@/i18n";
/** Where a Docker server reads the game data from. Not shown for a repack, which keeps its data in its own folder. */
export function GameDataCard({ serverId }: { serverId: string }) {
const t = useT();
const [folder, setFolder] = useState<string | null>(null);
const [message, setMessage] = useState<{ ok: boolean; text: string } | null>(null);
useEffect(() => {
let alive = true;
void api.gameDataFolder(serverId).then((f) => alive && setFolder(f)).catch(() => alive && setFolder(null));
return () => { alive = false; };
}, [serverId]);
if (folder === null) return null;
async function change() {
const picked = await open({ directory: true, multiple: false, title: t("gamedata.dialog"), defaultPath: folder ?? undefined });
if (typeof picked !== "string") return;
try {
setFolder(await api.setGameDataFolder(serverId, picked));
setMessage({ ok: true, text: t("gamedata.saved") });
} catch (e) {
setMessage({ ok: false, text: asUiError(e).technical });
}
}
return (
<Card className="mt-6 p-6">
<h2 className="font-semibold">{t("gamedata.title")}</h2>
<p className="mt-1 text-sm text-muted">{t("gamedata.text")}</p>
<div className="mt-3 flex items-center gap-3">
<code className="selectable min-w-0 flex-1 truncate rounded-md border border-line bg-card px-3 py-2 text-sm" title={folder}>{folder}</code>
<Button onClick={() => void change()}>{t("gamedata.change")}</Button>
</div>
{message && <p className={message.ok ? "mt-2 text-sm text-ok" : "mt-2 text-sm text-bad"} role="status">{message.text}</p>}
</Card>
);
}
+18 -2
View File
@@ -144,6 +144,17 @@ export function ModulesPage({ serverId, onChanged, onRegisterGuard }: { serverId
}
}
async function uninstallClientPatch() {
setRacesInstalling(true);
setError(null);
try {
await api.customRacesUninstall(serverId);
await load();
onChanged?.();
} catch (e) { setError(asUiError(e)); }
finally { setRacesInstalling(false); }
}
async function toggle(m: ModuleView) {
setError(null);
try {
@@ -205,7 +216,9 @@ export function ModulesPage({ serverId, onChanged, onRegisterGuard }: { serverId
{!m.installed && m.status !== "soon" && <span className="mt-1.5 shrink-0 text-xs text-muted">{t("mod.notHere")}</span>}
</div>
{m.id === "custom-races" && (
<div className="w-full">
<p className="text-xs text-muted">{locale === "ru" ? "Установленная версия патча клиента: " : "Installed client patch version: "}{racesPatchStatus?.version ?? (locale === "ru" ? "не записана" : "not recorded")}</p>
{racesInstalling && racesProgress ? (
<div className="rounded-lg border border-gold/30 bg-gold/5 p-3">
<div className="flex items-center justify-between gap-3 text-xs">
@@ -252,7 +265,8 @@ export function ModulesPage({ serverId, onChanged, onRegisterGuard }: { serverId
</span>
)}
</div>
{(!racesPatchStatus || racesPatchStatus.state === "not-installed" || racesPatchStatus.state === "partially-installed") && (
{racesPatchStatus?.state === "partially-installed" && <p className="text-xs text-warn">{locale === "ru" ? "Файлы отсутствуют или изменены. Восстановите патч клиента." : "Files are missing or changed. Repair the client patch."}</p>}
{(
<Button
size="sm"
variant="secondary"
@@ -261,9 +275,11 @@ export function ModulesPage({ serverId, onChanged, onRegisterGuard }: { serverId
onClick={() => void installClientPatch()}
>
{racesInstalling && <Loader2 className="mr-1.5 h-3.5 w-3.5 animate-spin" />}
{locale === "ru" ? "Установить патч клиента" : "Install Client Patch 1.5"}
{racesPatchStatus?.state === "not-installed" ? (locale === "ru" ? "Установить патч клиента" : "Install Client Patch") : (locale === "ru" ? "Восстановить патч клиента" : "Repair Client Patch")}
</Button>
)}
{racesPatchStatus && racesPatchStatus.state !== "not-installed" && <Button size="sm" variant="ghost" disabled={racesInstalling} onClick={() => void uninstallClientPatch()}>{locale === "ru" ? "Удалить патч клиента" : "Uninstall Client Patch"}</Button>}
<p className="text-xs text-muted">{locale === "ru" ? (m.enabled ? "После установки патч будет включён." : "После установки патч останется отключённым: модуль сервера выключен или отсутствует.") : (m.enabled ? "The patch will be enabled after installation." : "The patch will stay disabled after installation: the server module is off or missing.")}</p>
</div>
)}
</div>
+18 -10
View File
@@ -46,21 +46,22 @@ function Row({ label, s }: { label: string; s: ServiceStatus }) {
const t = useT();
const running = s.state === "running";
const starting = s.state === "starting";
const crashed = s.state === "crashed";
return (
<div className="flex items-center justify-between py-2.5">
<span>{label}</span>
<span
className={cn("flex items-center gap-2 text-sm", running ? "text-ok" : starting ? "text-warn" : "text-muted")}
className={cn("flex items-center gap-2 text-sm", running ? "text-ok" : starting || crashed ? "text-warn" : "text-muted")}
role="status"
>
<span
aria-hidden
className={cn(
"h-2 w-2 rounded-full",
running ? "bg-ok" : starting ? "animate-[pulse-dot_1.2s_ease-in-out_infinite] bg-warn" : "bg-muted/50",
running ? "bg-ok" : starting ? "animate-[pulse-dot_1.2s_ease-in-out_infinite] bg-warn" : crashed ? "bg-warn" : "bg-muted/50",
)}
/>
{running ? t("status.running") : starting ? t("status.starting") : t("status.stopped")}
{running ? t("status.running") : starting ? t("status.starting") : crashed ? t("status.crashed") : t("status.stopped")}
</span>
</div>
);
@@ -98,7 +99,13 @@ export function Overview({ server, companions = true, onForget, onOpenUpdates, o
const [keepMine, setKeepMine] = useState(true);
const [perf, setPerf] = useState<Performance | null>(null);
const upd = useServerUpdate(server.id);
const visibleFailure = failure ?? upd.stateError ?? upd.uiError;
const needsDecision = (upd.preview?.conflicts.length ?? 0) > 0;
const runServerUpdate = async () => {
setFailure(null);
setShowDetails(false);
await applyServerUpdate(server.id);
};
const [startBots, setStartBots] = useState<number | null | undefined>(undefined);
const [autoRestart, setAutoRestart] = useAutoRestart(server.id);
const autoRestartRef = useRef(autoRestart);
@@ -400,7 +407,7 @@ export function Overview({ server, companions = true, onForget, onOpenUpdates, o
variant="primary"
size="xl"
disabled={transitioning || upd.applying}
onClick={() => (needsDecision ? onOpenUpdates() : void applyServerUpdate(server.id))}
onClick={() => (needsDecision ? onOpenUpdates() : void runServerUpdate())}
className="min-w-56"
>
{upd.applying && <Loader2 className="h-5 w-5 animate-spin" aria-hidden />}
@@ -423,7 +430,7 @@ export function Overview({ server, companions = true, onForget, onOpenUpdates, o
</Button>
)}
{running && upd.available && (
<Button variant="secondary" size="sm" disabled={transitioning || upd.applying} onClick={() => (needsDecision ? onOpenUpdates() : void applyServerUpdate(server.id))}>
<Button variant="secondary" size="sm" disabled={transitioning || upd.applying} onClick={() => (needsDecision ? onOpenUpdates() : void runServerUpdate())}>
{upd.applying && <Loader2 className="h-4 w-4 animate-spin" aria-hidden />}
{needsDecision ? t("overview.openUpdates") : t("btn.updateTo", { v: upd.preview?.to_version ?? "" })}
</Button>
@@ -538,6 +545,7 @@ export function Overview({ server, companions = true, onForget, onOpenUpdates, o
{upd.available && upd.preview && (
<div className="mt-4 rounded-md border border-gold/40 bg-gold/5 p-3 text-sm">
<p>{t("overview.updateAvail", { to: upd.preview.to_version, from: upd.preview.from_version ?? "?" })}</p>
{upd.preview.latest_version && <p>{t("upd.intermediate", { to: upd.preview.to_version, latest: upd.preview.latest_version })}</p>}
{needsDecision && <p className="mt-1 text-muted">{t("overview.updateConflicts")}</p>}
{upd.applying && (
<div className="mt-2">
@@ -586,21 +594,21 @@ export function Overview({ server, companions = true, onForget, onOpenUpdates, o
</Card>
)}
{failure && (
{visibleFailure && (
<Card className="mt-4 border-bad/40 p-5" role="alert">
<p className="font-medium text-bad">{human(failure.human).title}</p>
<p className="mt-1 text-sm text-muted">{human(failure.human).message}</p>
<p className="font-medium text-bad">{human(visibleFailure.human).title}</p>
<p className="mt-1 text-sm text-muted">{human(visibleFailure.human).message}</p>
<div className="mt-3 flex gap-2">
<Button size="sm" onClick={() => setShowDetails((v) => !v)}>
{showDetails ? t("common.hideDetails") : t("common.viewDetails")}
</Button>
<Button size="sm" variant="ghost" onClick={() => void navigator.clipboard.writeText(failure.technical)}>
<Button size="sm" variant="ghost" onClick={() => void navigator.clipboard.writeText(visibleFailure.technical)}>
{t("common.copyError")}
</Button>
</div>
{showDetails && (
<pre className="mt-3 max-h-56 overflow-auto whitespace-pre-wrap rounded bg-black/40 p-3 text-xs text-muted">
{failure.technical || t("common.noOutput")}
{visibleFailure.technical || t("common.noOutput")}
</pre>
)}
</Card>
+4
View File
@@ -7,6 +7,7 @@ import { api, asUiError, type UiError, type UpdatePreview, type UpdateTxn } from
import { Button } from "@/components/ui/button";
import { Card } from "@/components/ui/card";
import { ClientCard } from "@/screens/ClientCard";
import { GameDataCard } from "@/screens/GameDataCard";
import { DiagnosticsCard } from "@/screens/DiagnosticsCard";
import { AboutCard } from "@/screens/AboutCard";
import { RemoveServerCard } from "@/screens/RemoveServerCard";
@@ -175,6 +176,8 @@ export function SettingsHome({ serverId, serverName = "", path, onForget }: { se
<RealmStartupSettings serverId={serverId} />
<AutoRestartSettings serverId={serverId} />
<GameDataCard serverId={serverId} />
<DiagnosticsCard serverId={serverId} />
<RepairCard key={serverId} serverId={serverId} />
<PublishCard key={`publish-${serverId}`} serverId={serverId} serverName={serverName} />
@@ -233,6 +236,7 @@ export function SettingsHome({ serverId, serverName = "", path, onForget }: { se
<p className="font-medium">
{preview.from_version ? t("upd.availableFrom", { to: preview.to_version, from: preview.from_version }) : t("upd.available", { to: preview.to_version })}
</p>
{preview.latest_version && <p className="mt-1 text-sm text-warn" role="status">{t("upd.intermediate", { to: preview.to_version, latest: preview.latest_version })}</p>}
<p className="mt-1 text-sm text-muted">
{!preview.database_check_error && (preview.pending_migrations ?? preview.migrations) > 0
? t("upd.summaryDb", { size: mb(preview.download_bytes), files: preview.items.filter((i) => i.action !== "skip").length, db: preview.pending_migrations ?? preview.migrations })