mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-24 11:25:56 +00:00
Collect all diagnostics in one click and route reports to the right project
- The diagnostic package now also holds crash reports and small crash dumps from Core/Crashes, Windows' own crash records for the server programs (needed for crashes that bypass the server's crash handler), the newest update journals, the bot, supervisor and updater logs, and a view of which server programs run and from where. The folder with the file opens after export. - JSON files in the package keep valid JSON after secrets are removed. - The problem report asks what the problem is about and opens the new-issue page of the Manager, CoA Companions or SQUID Playerbots, preselecting the bot system that is switched on. One button collects diagnostics and opens the report. - Targets come from the module catalog; only their new-issue pages may be opened. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3f700ee8f4
commit
b3c50a7b39
20 files changed
+637
-58
No files matched your search
@@ -64,7 +64,7 @@ function Row({ label, s }: { label: string; s: ServiceStatus }) {
|
||||
);
|
||||
}
|
||||
|
||||
export function Overview({ server, companions = true, onForget, onOpenUpdates, onRealmChanged }: { server: ServerSummary; /** the companions module is on */ companions?: boolean; onForget: () => Promise<void>; onOpenUpdates: () => void; onRealmChanged: () => void }) {
|
||||
export function Overview({ server, companions = true, onForget, onOpenUpdates, onRealmChanged, onReport }: { server: ServerSummary; /** the companions module is on */ companions?: boolean; onForget: () => Promise<void>; onOpenUpdates: () => void; onRealmChanged: () => void; /** open the problem report, which collects the diagnostics */ onReport: () => void }) {
|
||||
const t = useT();
|
||||
const human = useHuman();
|
||||
const [status, setStatus] = useState<StatusView | null>(null);
|
||||
@@ -228,6 +228,12 @@ export function Overview({ server, companions = true, onForget, onOpenUpdates, o
|
||||
/>
|
||||
{headline}
|
||||
</div>
|
||||
{!transitioning && !running && anyUp && (
|
||||
<p className="mt-2 text-sm text-muted">
|
||||
{t("overview.reportHint")}{" "}
|
||||
<button onClick={onReport} className="cursor-pointer text-gold underline hover:text-ink">{t("overview.reportBtn")}</button>
|
||||
</p>
|
||||
)}
|
||||
|
||||
<div className="mt-5 divide-y divide-line border-y border-line">
|
||||
<Row label={t("overview.database")} s={mysql} />
|
||||
|
||||
+90
-30
@@ -1,22 +1,36 @@
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Loader2 } from "lucide-react";
|
||||
import { api, asUiError, type ReportContext, type UiError } from "@/lib/api";
|
||||
import { api, asUiError, type ReportContext, type ReportTarget, type ReportTargetId, type UiError } from "@/lib/api";
|
||||
import { MAX_LINK, issueUrl, reportBody } from "@/lib/report";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card } from "@/components/ui/card";
|
||||
import { useHuman, useT } from "@/i18n";
|
||||
import { useHuman, useT, type Key } from "@/i18n";
|
||||
|
||||
const field = "mt-1 block w-full rounded-md border border-line bg-bg px-3 py-2.5 text-[15px] outline-none focus:border-gold";
|
||||
|
||||
/** A problem report that becomes a prefilled GitHub issue. Nothing is sent from here: the person reviews and submits it on GitHub. */
|
||||
const TARGET_LABEL: Record<ReportTargetId, Key> = {
|
||||
manager: "rep.target.manager",
|
||||
companions: "rep.target.companions",
|
||||
squid: "rep.target.squid",
|
||||
};
|
||||
|
||||
const FALLBACK: ReportTarget = { id: "manager", repo: "Corfirean/coa-server-manager", ours: true };
|
||||
|
||||
/**
|
||||
* A problem report that becomes a prefilled GitHub issue in the repository of whatever it is about. One button collects
|
||||
* the diagnostics (and shows the file in its folder) and opens the issue; the person reviews it and submits it on GitHub.
|
||||
*/
|
||||
export function ReportPage({ serverId }: { serverId: string }) {
|
||||
const t = useT();
|
||||
const human = useHuman();
|
||||
const [ctx, setCtx] = useState<ReportContext | null>(null);
|
||||
const [targets, setTargets] = useState<ReportTarget[]>([]);
|
||||
const [targetId, setTargetId] = useState<ReportTargetId | null>(null);
|
||||
const [title, setTitle] = useState("");
|
||||
const [what, setWhat] = useState("");
|
||||
const [expected, setExpected] = useState("");
|
||||
const [steps, setSteps] = useState("");
|
||||
const [withDiag, setWithDiag] = useState(true);
|
||||
const [file, setFile] = useState<string | null>(null);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [note, setNote] = useState<string | null>(null);
|
||||
@@ -25,30 +39,44 @@ export function ReportPage({ serverId }: { serverId: string }) {
|
||||
|
||||
useEffect(() => {
|
||||
void api.reportContext(serverId).then(setCtx).catch(() => setCtx(null));
|
||||
void api.reportTargets().then(setTargets).catch(() => setTargets([]));
|
||||
}, [serverId]);
|
||||
|
||||
const body = useMemo(
|
||||
() =>
|
||||
reportBody({
|
||||
managerVersion: ctx?.manager_version ?? "",
|
||||
windows: ctx?.windows ?? "",
|
||||
installKind: ctx?.install_kind ?? "new",
|
||||
serverVersion: ctx?.server_version ?? null,
|
||||
what,
|
||||
expected,
|
||||
steps,
|
||||
diagnostics: file !== null,
|
||||
}),
|
||||
[ctx, what, expected, steps, file],
|
||||
);
|
||||
const issueTitle = `[Bug] ${title.trim()}`;
|
||||
// start on the bot system that is switched on, until the person picks one
|
||||
const chosen: ReportTargetId = targetId ?? ctx?.suggested_target ?? "manager";
|
||||
const shown = targets.length ? targets : [FALLBACK];
|
||||
const target = shown.find((x) => x.id === chosen) ?? shown[0];
|
||||
|
||||
function bodyFor(hasFile: boolean): string {
|
||||
return reportBody({
|
||||
managerVersion: ctx?.manager_version ?? "",
|
||||
windows: ctx?.windows ?? "",
|
||||
installKind: ctx?.install_kind ?? "new",
|
||||
serverVersion: ctx?.server_version ?? null,
|
||||
target: target.id,
|
||||
botsVersion: ctx?.bots_version ?? null,
|
||||
what,
|
||||
expected,
|
||||
steps,
|
||||
diagnostics: hasFile,
|
||||
});
|
||||
}
|
||||
const issueTitle = target.ours ? `[Bug] ${title.trim()}` : title.trim();
|
||||
const ready = title.trim().length > 0 && what.trim().length > 0;
|
||||
|
||||
async function makeFile() {
|
||||
/** Collects the diagnostics once; the Manager shows the file in its folder. */
|
||||
async function collect(): Promise<string> {
|
||||
if (file) return file;
|
||||
const path = await api.exportDiagnostics(serverId);
|
||||
setFile(path);
|
||||
return path;
|
||||
}
|
||||
|
||||
async function collectOnly() {
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
try {
|
||||
setFile(await api.exportDiagnostics(serverId));
|
||||
await collect();
|
||||
} catch (e) {
|
||||
setError(asUiError(e));
|
||||
} finally {
|
||||
@@ -56,26 +84,32 @@ export function ReportPage({ serverId }: { serverId: string }) {
|
||||
}
|
||||
}
|
||||
|
||||
/** One button: collect the diagnostics (if asked), then open the issue with everything filled in. */
|
||||
async function openIssue() {
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
setNote(null);
|
||||
try {
|
||||
const full = issueUrl(issueTitle, body);
|
||||
const path = withDiag ? await collect() : null;
|
||||
const body = bodyFor(path !== null);
|
||||
const full = issueUrl(target, issueTitle, body);
|
||||
if (full.length <= MAX_LINK) {
|
||||
await api.openLink(full);
|
||||
setNote(t("rep.opened"));
|
||||
} else {
|
||||
await navigator.clipboard.writeText(body);
|
||||
await api.openLink(issueUrl(issueTitle, "Paste the report text here (it was copied to the clipboard by CoA Server Manager)."));
|
||||
await api.openLink(issueUrl(target, issueTitle, "Paste the report text here (it was copied to the clipboard by CoA Server Manager)."));
|
||||
setNote(t("rep.openedLong"));
|
||||
}
|
||||
} catch (e) {
|
||||
setError(asUiError(e));
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function copy() {
|
||||
await navigator.clipboard.writeText(`${issueTitle}\n\n${body}`);
|
||||
await navigator.clipboard.writeText(`${issueTitle}\n\n${bodyFor(file !== null)}`);
|
||||
setNote(t("rep.copied"));
|
||||
}
|
||||
|
||||
@@ -85,6 +119,22 @@ export function ReportPage({ serverId }: { serverId: string }) {
|
||||
<p className="mt-1 text-muted">{t("q.report")}</p>
|
||||
<p className="mt-3 text-sm text-muted">{t("rep.intro")}</p>
|
||||
|
||||
<Card className="mt-6 p-6">
|
||||
<h2 className="font-semibold" id="rep-target">{t("rep.targetTitle")}</h2>
|
||||
<div role="radiogroup" aria-labelledby="rep-target" className="mt-3 space-y-2">
|
||||
{shown.map((x) => (
|
||||
<label key={x.id} className={`flex cursor-pointer items-start gap-3 rounded-md border px-3 py-2.5 ${chosen === x.id ? "border-gold" : "border-line"}`}>
|
||||
<input type="radio" name="rep-target" className="mt-1" checked={chosen === x.id} onChange={() => setTargetId(x.id)} />
|
||||
<span>
|
||||
<span className="block text-[15px]">{t(TARGET_LABEL[x.id])}</span>
|
||||
<span className="selectable block text-xs text-muted">{x.repo}</span>
|
||||
</span>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
<p className="mt-3 text-xs text-muted">{t("rep.targetPublic", { repo: target.repo })}</p>
|
||||
</Card>
|
||||
|
||||
<Card className="mt-6 p-6">
|
||||
<h2 className="font-semibold">{t("rep.autoTitle")}</h2>
|
||||
<dl className="mt-3 grid grid-cols-[auto_1fr] gap-x-6 gap-y-1 text-sm">
|
||||
@@ -100,6 +150,12 @@ export function ReportPage({ serverId }: { serverId: string }) {
|
||||
<dd>{ctx.server_version}</dd>
|
||||
</>
|
||||
)}
|
||||
{target.id !== "manager" && ctx?.bots_version && (
|
||||
<>
|
||||
<dt className="text-muted">{t("rep.botsVersion")}</dt>
|
||||
<dd>{ctx.bots_version}</dd>
|
||||
</>
|
||||
)}
|
||||
</dl>
|
||||
</Card>
|
||||
|
||||
@@ -125,16 +181,20 @@ export function ReportPage({ serverId }: { serverId: string }) {
|
||||
<Card className="mt-6 p-6">
|
||||
<h2 className="font-semibold">{t("rep.attachTitle")}</h2>
|
||||
<p className="mt-1 text-sm text-muted">{t("rep.attachText")}</p>
|
||||
<Button className="mt-3" size="sm" disabled={busy} onClick={() => void makeFile()}>
|
||||
{busy && <Loader2 className="h-4 w-4 animate-spin" aria-hidden />}
|
||||
{t("rep.makeFile")}
|
||||
</Button>
|
||||
<label className="mt-3 flex cursor-pointer items-start gap-3 text-sm">
|
||||
<input type="checkbox" className="mt-1" checked={withDiag} onChange={(e) => setWithDiag(e.target.checked)} />
|
||||
<span>{t("rep.withDiag")}</span>
|
||||
</label>
|
||||
{file && <p className="selectable mt-3 break-all text-sm text-ok" role="status">{t("rep.fileSaved", { path: file })}</p>}
|
||||
<p className="mt-4 text-xs text-warn">{t("rep.privacy")}</p>
|
||||
</Card>
|
||||
|
||||
<div className="mt-6 flex flex-wrap items-center gap-3">
|
||||
<Button variant="primary" disabled={!ready} onClick={() => void openIssue()}>{t("rep.open")}</Button>
|
||||
<Button variant="primary" disabled={!ready || busy} onClick={() => void openIssue()}>
|
||||
{busy && <Loader2 className="h-4 w-4 animate-spin" aria-hidden />}
|
||||
{busy ? t("rep.collecting") : withDiag ? t("rep.collectOpen") : t("rep.open")}
|
||||
</Button>
|
||||
<Button variant="ghost" disabled={busy} onClick={() => void collectOnly()}>{t("rep.makeFile")}</Button>
|
||||
<Button variant="ghost" disabled={!ready} onClick={() => void copy()}>{t("rep.copy")}</Button>
|
||||
<button onClick={() => setShowPreview((v) => !v)} aria-expanded={showPreview} className="cursor-pointer text-sm text-muted underline hover:text-ink">
|
||||
{t("rep.preview")}
|
||||
@@ -144,7 +204,7 @@ export function ReportPage({ serverId }: { serverId: string }) {
|
||||
<p className="mt-2 text-xs text-muted">{t("rep.githubNote")}</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>}
|
||||
{showPreview && <pre className="selectable mt-3 max-h-80 overflow-auto whitespace-pre-wrap rounded bg-black/40 p-3 text-xs text-muted">{`${issueTitle}\n\n${body}`}</pre>}
|
||||
{showPreview && <pre className="selectable mt-3 max-h-80 overflow-auto whitespace-pre-wrap rounded bg-black/40 p-3 text-xs text-muted">{`${issueTitle}\n\n${bodyFor(file !== null || withDiag)}`}</pre>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -127,7 +127,7 @@ export function Shell(props: {
|
||||
|
||||
<main className="h-full flex-1 overflow-y-auto px-10 py-8">
|
||||
{page === "overview" ? (
|
||||
<Overview key={server.id} server={server} companions={botModule === "companions" && !hiddenPages.includes("bots")} onForget={() => props.onForget(server.id)} onOpenUpdates={() => setPage("settings")} onRealmChanged={reloadModules} />
|
||||
<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 === "console" ? (
|
||||
|
||||
Reference in new issue
Block a user