mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-19 03:25:56 +00:00
- A new server goes on to the preview core without compiling any module (recommended modules are declined once; modules come from the Modules page). - Choosing a server with the classic core makes a modular copy next to it: every acore_* database (read from the running database, or from a private copy of the stopped data files opened by the new server's own mysqld), module configs and realm profiles, ports and console login. The old server is only read. The copy then takes the preview core with the modules the old server had switched on. - Installs and the preview update run on unused ports, so a server running on the shipped ports (the old one, or any other) no longer stops them; the schema check after "Preparing database" used the shipped port before. - Dungeon Clear is part of SQUID's Playerbots: no card of its own (it said "Always on" while SQUID was off), switched with SQUID, settings on the SQUID card. E2E (examples/preview_bare_and_copy_e2e, disposable servers, another server running on the shipped ports): fresh install committed with no plugins and a clean boot report; copy of a stopped and of a running classic server: data identical, old server's files byte-for-byte unchanged, Content Scaling and Companions built on the copy, preview core committed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
127 lines
3.6 KiB
TypeScript
127 lines
3.6 KiB
TypeScript
import { useCallback, useEffect, useState } from "react";
|
|
import { api, type ServerSummary } from "@/lib/api";
|
|
import { Welcome } from "@/screens/Welcome";
|
|
import { ImportServer } from "@/screens/ImportServer";
|
|
import { Shell } from "@/screens/Shell";
|
|
import { InstallServer } from "@/screens/InstallServer";
|
|
import { RemoteClient } from "@/screens/RemoteClient";
|
|
import { UpdateBanner } from "@/components/UpdateBanner";
|
|
import { autoUpdateEnabled, installOnClose, lookForUpdate } from "@/lib/selfUpdate";
|
|
|
|
type View = "welcome" | "add" | "import" | "install" | "remote";
|
|
|
|
function initialView(): View {
|
|
try { return localStorage.getItem("coa-play-mode") === "remote" ? "remote" : "welcome"; }
|
|
catch { return "welcome"; }
|
|
}
|
|
|
|
function Main() {
|
|
const [servers, setServers] = useState<ServerSummary[] | null>(null);
|
|
const [view, setView] = useState<View>(initialView);
|
|
const [activeId, setActiveId] = useState<string | null>(null);
|
|
// A classic server the owner chose: the install screen makes a modular copy of it next to it.
|
|
const [copyFrom, setCopyFrom] = useState<string | null>(null);
|
|
|
|
const refresh = useCallback(async () => {
|
|
const list = await api.list().catch(() => []);
|
|
setServers(list);
|
|
setActiveId((cur) => (cur && list.some((s) => s.id === cur) ? cur : (list[0]?.id ?? null)));
|
|
}, []);
|
|
|
|
useEffect(() => {
|
|
void refresh();
|
|
}, [refresh]);
|
|
|
|
if (servers === null) return null;
|
|
|
|
if (view === "remote") return <RemoteClient onHost={() => {
|
|
try { localStorage.setItem("coa-play-mode", "host"); } catch { /* storage unavailable */ }
|
|
setView(servers.length ? "welcome" : "add");
|
|
}} />;
|
|
|
|
if (servers.length > 0 && view === "welcome" && activeId) {
|
|
return (
|
|
<Shell
|
|
servers={servers}
|
|
activeId={activeId}
|
|
onSelect={setActiveId}
|
|
onAddAnother={() => setView("add")}
|
|
onForget={async (id) => {
|
|
await api.forget(id);
|
|
await refresh();
|
|
}}
|
|
/>
|
|
);
|
|
}
|
|
|
|
if (view === "install") {
|
|
return (
|
|
<InstallServer
|
|
canCancel
|
|
copyFrom={copyFrom ?? undefined}
|
|
onCancel={() => {
|
|
setView(copyFrom ? "import" : servers.length > 0 ? "add" : "welcome");
|
|
setCopyFrom(null);
|
|
}}
|
|
onDone={async (s) => {
|
|
setCopyFrom(null);
|
|
await refresh();
|
|
setActiveId(s.id);
|
|
setView("welcome");
|
|
}}
|
|
/>
|
|
);
|
|
}
|
|
|
|
if (view === "import") {
|
|
return (
|
|
<ImportServer
|
|
canCancel
|
|
onCancel={() => setView(servers.length > 0 ? "add" : "welcome")}
|
|
onAdded={async (s) => {
|
|
await refresh();
|
|
setActiveId(s.id);
|
|
setView("welcome");
|
|
}}
|
|
onCopy={(path) => {
|
|
setCopyFrom(path);
|
|
setView("install");
|
|
}}
|
|
/>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<Welcome
|
|
onConnect={() => {
|
|
try { localStorage.setItem("coa-play-mode", "remote"); } catch { /* storage unavailable */ }
|
|
setView("remote");
|
|
}}
|
|
onImport={() => setView("import")}
|
|
onInstall={() => setView("install")}
|
|
onBack={servers.length > 0 ? () => setView("welcome") : undefined}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export default function App() {
|
|
// Quietly fetch a new Manager version a few seconds after start and install it when the window is closed.
|
|
useEffect(() => {
|
|
const stop = installOnClose();
|
|
const timer = setTimeout(() => {
|
|
if (autoUpdateEnabled()) void lookForUpdate({ download: true });
|
|
}, 5000);
|
|
return () => {
|
|
clearTimeout(timer);
|
|
stop();
|
|
};
|
|
}, []);
|
|
|
|
return (
|
|
<>
|
|
<Main />
|
|
<UpdateBanner />
|
|
</>
|
|
);
|
|
}
|