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:
ДмитрийandClaude Sonnet 5.5 committed 2026-10-07 06:21:11 +05:00
1 parent 3f700ee8f4
commit b3c50a7b39
20 files changed
+637 -58

No files matched your search

+2 -1
View File
@@ -87,7 +87,8 @@ export {};
return (S[args.module]??[]).map(s => ({...s, value: moduleEdits[args.module]?.[s.key] ?? s.value}));
}
if(cmd==="module_save_settings") { moduleEdits[args.module] = {...moduleEdits[args.module], ...args.changes}; return Object.keys(args.changes); }
if(cmd==="report_context") return {manager_version:"0.3.1",windows:"Windows 11 (build 26200)",install_kind:"new",server_version:"0.261001.10"};
if(cmd==="report_context") return {manager_version:"0.3.1",windows:"Windows 11 (build 26200)",install_kind:"new",server_version:"0.261001.10",suggested_target:"companions",bots_version:"0.2.1 · 1a2b3c4d"};
if(cmd==="report_targets") return [{id:"manager",repo:"Corfirean/coa-server-manager",ours:true},{id:"companions",repo:"Corfirean/mod-coa-playerbots",ours:true},{id:"squid",repo:"Zyth45/mod-playerbots",ours:false}];
if(cmd==="open_link"){(window as any).__lastLink=args.url;return null;}
if(cmd==="export_diagnostics") return "C:\\Users\\you\\Desktop\\CoA-Diagnostics-20261001-140000.zip";
if(cmd==="install_preflight") return {ok:true,problems:[],free_bytes:210*2**30};
+13 -2
View File
@@ -702,9 +702,9 @@ const de: Partial<Record<keyof typeof en, string>> = {
"rep.expectedHint": "Beschreibe das erwartete Verhalten.",
"rep.steps": "Schritte zum Nachstellen",
"rep.attachTitle": "Logs und Screenshots",
"rep.attachText": "Erstelle eine Diagnosedatei (Einstellungen und Logs ohne Passwörter und Adressen) und ziehe sie zusammen mit Screenshots oder Videos auf die GitHub-Seite, sobald sie offen ist.",
"rep.attachText": "Ein Klick sammelt die Diagnose: Logs des Managers und des Servers, Absturzberichte, Windows-Absturzeinträge und Update-Protokolle, ohne Passwörter und Adressen. Der Ordner mit der Datei wird geöffnet; ziehe die Datei zusammen mit Screenshots oder Videos auf die GitHub-Seite.",
"rep.makeFile": "Diagnosedatei erstellen",
"rep.fileSaved": "Gespeichert unter {path}. Ziehe diese Datei in das GitHub-Issue.",
"rep.fileSaved": "Gespeichert unter {path}. Der Ordner wurde geöffnet. Ziehe diese Datei in das GitHub-Issue.",
"rep.privacy": "Bitte entferne Passwörter, Tokens, private IP-Angaben und andere sensible Daten, bevor du Logs veröffentlichst.",
"rep.open": "Bericht auf GitHub öffnen",
"rep.copy": "Text kopieren",
@@ -714,6 +714,17 @@ const de: Partial<Record<keyof typeof en, string>> = {
"rep.opened": "GitHub wurde im Browser geöffnet. Prüfe den Text, hänge Dateien an und klicke auf „Submit new issue“.",
"rep.openedLong": "Der Bericht ist für einen Link zu lang und wurde deshalb in die Zwischenablage kopiert. GitHub ist geöffnet: Füge ihn (Strg+V) in die Beschreibung ein, hänge Dateien an und klicke auf „Submit new issue“.",
"rep.copied": "In die Zwischenablage kopiert.",
"rep.targetTitle": "Worum geht es bei dem Problem?",
"rep.target.manager": "CoA Server Manager, der Server oder andere Module",
"rep.target.companions": "CoA Companions (Bots und das CoABotUI-Addon)",
"rep.target.squid": "SQUID Playerbots",
"rep.targetPublic": "Der Bericht wird öffentlich auf GitHub in {repo} veröffentlicht.",
"rep.botsVersion": "Bot-Version",
"rep.withDiag": "Diagnose für mich sammeln (empfohlen)",
"rep.collectOpen": "Diagnose sammeln und Bericht öffnen",
"rep.collecting": "Diagnose wird gesammelt…",
"overview.reportHint": "Ein Dienst wurde von selbst beendet?",
"overview.reportBtn": "Diagnose sammeln und melden",
// Realmlist switcher and modules page
"realm.profileLabel": "Realm",
+13 -2
View File
@@ -735,9 +735,9 @@ const en = {
"rep.expectedHint": "Describe the expected behaviour.",
"rep.steps": "Steps to reproduce",
"rep.attachTitle": "Logs and screenshots",
"rep.attachText": "Create a diagnostics file (settings and logs with passwords and addresses removed) and drag it, together with any screenshot or video, into the GitHub page once it is open.",
"rep.attachText": "One click collects the diagnostics: the Manager's and the server's logs, crash reports, Windows crash records and update journals, with passwords and addresses removed. The file's folder opens; drag the file, together with any screenshot or video, into the GitHub page.",
"rep.makeFile": "Create the diagnostics file",
"rep.fileSaved": "Saved to {path}. Drag this file into the GitHub issue.",
"rep.fileSaved": "Saved to {path}. The folder was opened. Drag this file into the GitHub issue.",
"rep.privacy": "Please remove passwords, tokens, private IP information or other sensitive data before posting logs.",
"rep.open": "Open the report on GitHub",
"rep.copy": "Copy the text",
@@ -747,6 +747,17 @@ const en = {
"rep.opened": "GitHub was opened in your browser. Check the text, attach files and press Submit new issue.",
"rep.openedLong": "The report is too long for a link, so it was copied to the clipboard. GitHub is open: paste it (Ctrl+V) into the description, attach files and press Submit new issue.",
"rep.copied": "Copied to the clipboard.",
"rep.targetTitle": "What is the problem about?",
"rep.target.manager": "CoA Server Manager, the server or other modules",
"rep.target.companions": "CoA Companions (bots and the CoABotUI addon)",
"rep.target.squid": "SQUID Playerbots",
"rep.targetPublic": "The report will be public on GitHub in {repo}.",
"rep.botsVersion": "Bot release",
"rep.withDiag": "Collect the diagnostics for me (recommended)",
"rep.collectOpen": "Collect diagnostics and open the report",
"rep.collecting": "Collecting diagnostics…",
"overview.reportHint": "A service stopped on its own?",
"overview.reportBtn": "Collect diagnostics and report",
// Realmlist switcher and modules page
"realm.label": "Realm",
+13 -2
View File
@@ -702,9 +702,9 @@ const es: Partial<Record<keyof typeof en, string>> = {
"rep.expectedHint": "Describe el comportamiento esperado.",
"rep.steps": "Pasos para reproducirlo",
"rep.attachTitle": "Registros y capturas",
"rep.attachText": "Crea un archivo de diagnóstico (ajustes y registros sin contraseñas ni direcciones) y arrástralo, junto con capturas o vídeos, a la página de GitHub cuando se abra.",
"rep.attachText": "Un clic reúne el diagnóstico: registros del Manager y del servidor, informes de fallos, registros de fallos de Windows y diarios de actualización, sin contraseñas ni direcciones. Se abre la carpeta del archivo; arrástralo, junto con capturas o vídeos, a la página de GitHub.",
"rep.makeFile": "Crear el archivo de diagnóstico",
"rep.fileSaved": "Guardado en {path}. Arrastra este archivo al issue de GitHub.",
"rep.fileSaved": "Guardado en {path}. Se abrió la carpeta. Arrastra este archivo al issue de GitHub.",
"rep.privacy": "Elimina contraseñas, tokens, información de IP privada y otros datos sensibles antes de publicar registros.",
"rep.open": "Abrir el informe en GitHub",
"rep.copy": "Copiar el texto",
@@ -714,6 +714,17 @@ const es: Partial<Record<keyof typeof en, string>> = {
"rep.opened": "GitHub se abrió en tu navegador. Revisa el texto, adjunta archivos y pulsa «Submit new issue».",
"rep.openedLong": "El informe es demasiado largo para un enlace, así que se copió al portapapeles. GitHub está abierto: pégalo (Ctrl+V) en la descripción, adjunta archivos y pulsa «Submit new issue».",
"rep.copied": "Copiado al portapapeles.",
"rep.targetTitle": "¿Sobre qué es el problema?",
"rep.target.manager": "CoA Server Manager, el servidor u otros módulos",
"rep.target.companions": "CoA Companions (bots y el addon CoABotUI)",
"rep.target.squid": "SQUID Playerbots",
"rep.targetPublic": "El informe será público en GitHub, en {repo}.",
"rep.botsVersion": "Versión de los bots",
"rep.withDiag": "Reunir el diagnóstico por mí (recomendado)",
"rep.collectOpen": "Reunir el diagnóstico y abrir el informe",
"rep.collecting": "Reuniendo el diagnóstico…",
"overview.reportHint": "¿Un servicio se detuvo solo?",
"overview.reportBtn": "Reunir el diagnóstico y avisar",
// Realmlist switcher and modules page
"realm.profileLabel": "Reino",
+13 -2
View File
@@ -702,9 +702,9 @@ const fr: Partial<Record<keyof typeof en, string>> = {
"rep.expectedHint": "Décrivez le comportement attendu.",
"rep.steps": "Étapes pour reproduire",
"rep.attachTitle": "Journaux et captures d’écran",
"rep.attachText": "Créez un fichier de diagnostic (réglages et journaux sans mots de passe ni adresses) et glissez-le, avec vos captures ou vidéos, sur la page GitHub une fois ouverte.",
"rep.attachText": "Un clic rassemble le diagnostic : journaux du Manager et du serveur, rapports de plantage, enregistrements de plantage de Windows et journaux de mise à jour, sans mots de passe ni adresses. Le dossier du fichier s’ouvre ; glissez le fichier, avec vos captures ou vidéos, sur la page GitHub.",
"rep.makeFile": "Créer le fichier de diagnostic",
"rep.fileSaved": "Enregistré dans {path}. Glissez ce fichier dans l’issue GitHub.",
"rep.fileSaved": "Enregistré dans {path}. Le dossier a été ouvert. Glissez ce fichier dans l’issue GitHub.",
"rep.privacy": "Veuillez retirer les mots de passe, jetons, adresses IP privées et autres données sensibles avant de publier des journaux.",
"rep.open": "Ouvrir le rapport sur GitHub",
"rep.copy": "Copier le texte",
@@ -714,6 +714,17 @@ const fr: Partial<Record<keyof typeof en, string>> = {
"rep.opened": "GitHub s’est ouvert dans votre navigateur. Vérifiez le texte, joignez les fichiers et appuyez sur « Submit new issue ».",
"rep.openedLong": "Le rapport est trop long pour un lien : il a été copié dans le presse-papiers. GitHub est ouvert : collez-le (Ctrl+V) dans la description, joignez les fichiers et appuyez sur « Submit new issue ».",
"rep.copied": "Copié dans le presse-papiers.",
"rep.targetTitle": "De quoi parle le problème ?",
"rep.target.manager": "CoA Server Manager, le serveur ou d’autres modules",
"rep.target.companions": "CoA Companions (bots et addon CoABotUI)",
"rep.target.squid": "SQUID Playerbots",
"rep.targetPublic": "Le rapport sera public sur GitHub dans {repo}.",
"rep.botsVersion": "Version des bots",
"rep.withDiag": "Rassembler le diagnostic pour moi (recommandé)",
"rep.collectOpen": "Rassembler le diagnostic et ouvrir le rapport",
"rep.collecting": "Collecte du diagnostic…",
"overview.reportHint": "Un service s’est arrêté tout seul ?",
"overview.reportBtn": "Rassembler le diagnostic et signaler",
// Realmlist switcher and modules page
"realm.profileLabel": "Royaume",
+13 -2
View File
@@ -733,9 +733,9 @@ const ru: Partial<Record<keyof typeof en, string>> = {
"rep.expectedHint": "Опишите ожидаемое поведение.",
"rep.steps": "Как воспроизвести",
"rep.attachTitle": "Логи и скриншоты",
"rep.attachText": "Создайте файл диагностики (настройки и логи без паролей и адресов) и перетащите его вместе со скриншотами или видео на страницу GitHub, когда она откроется.",
"rep.attachText": "Диагностика собирается одним нажатием: логи менеджера и сервера, отчёты о падениях, записи Windows о сбоях и журналы обновлений, без паролей и адресов. Откроется папка с файлом; перетащите его вместе со скриншотами или видео на страницу GitHub.",
"rep.makeFile": "Создать файл диагностики",
"rep.fileSaved": "Сохранено: {path}. Перетащите этот файл в issue на GitHub.",
"rep.fileSaved": "Сохранено: {path}. Папка открыта. Перетащите этот файл в issue на GitHub.",
"rep.privacy": "Перед публикацией логов удалите пароли, токены, частные IP-адреса и другие личные данные.",
"rep.open": "Открыть отчёт на GitHub",
"rep.copy": "Копировать текст",
@@ -745,6 +745,17 @@ const ru: Partial<Record<keyof typeof en, string>> = {
"rep.opened": "GitHub открыт в браузере. Проверьте текст, прикрепите файлы и нажмите «Submit new issue».",
"rep.openedLong": "Отчёт слишком длинный для ссылки, поэтому он скопирован в буфер обмена. GitHub открыт: вставьте текст (Ctrl+V) в описание, прикрепите файлы и нажмите «Submit new issue».",
"rep.copied": "Скопировано в буфер обмена.",
"rep.targetTitle": "О чём проблема?",
"rep.target.manager": "CoA Server Manager, сервер или другие модули",
"rep.target.companions": "CoA Companions (боты и аддон CoABotUI)",
"rep.target.squid": "SQUID Playerbots",
"rep.targetPublic": "Репорт будет публичным на GitHub в {repo}.",
"rep.botsVersion": "Версия ботов",
"rep.withDiag": "Собрать диагностику за меня (рекомендуется)",
"rep.collectOpen": "Собрать диагностику и открыть репорт",
"rep.collecting": "Собираю диагностику…",
"overview.reportHint": "Служба остановилась сама?",
"overview.reportBtn": "Собрать диагностику и сообщить",
// Realmlist switcher and modules page
"realm.label": "Реалм",
+13 -2
View File
@@ -714,9 +714,9 @@ const zh = {
"rep.expectedHint": "描述你期望的正常表现。",
"rep.steps": "复现步骤",
"rep.attachTitle": "日志与截图附件",
"rep.attachText": "生成一份诊断包文件(已自动脱敏密码与私有 IP 等敏感信息),并在浏览器打开 GitHub 页面后,将其连同截图或录屏一起拖拽上传。",
"rep.attachText": "一键收集诊断信息:管理器与服务器日志、崩溃报告、Windows 崩溃记录和更新日志(已去除密码与地址)。文件所在文件夹会自动打开;请将该文件连同截图或录屏一起拖入 GitHub 页面。",
"rep.makeFile": "生成诊断包文件",
"rep.fileSaved": "已保存至 {path}。请将该文件拖入 GitHub Issue 中。",
"rep.fileSaved": "已保存至 {path}。文件夹已打开。请将该文件拖入 GitHub Issue 中。",
"rep.privacy": "上传前请注意检查并移除日志中可能包含的私有密码、Token 或其他敏感隐私信息。",
"rep.open": "在 GitHub 上打开报告",
"rep.copy": "复制报告文本",
@@ -726,6 +726,17 @@ const zh = {
"rep.opened": "已在浏览器中打开 GitHub。请检查内容、附上日志文件并点击“Submit new issue”。",
"rep.openedLong": "报告内容较长超出 URL 长度限制,已自动复制到剪贴板。请在已打开的 GitHub 页面中按 Ctrl+V 粘贴描述,附上文件后提交。",
"rep.copied": "已复制到剪贴板。",
"rep.targetTitle": "问题与什么有关?",
"rep.target.manager": "CoA Server Manager、服务器或其他模块",
"rep.target.companions": "CoA Companions(机器人与 CoABotUI 插件)",
"rep.target.squid": "SQUID Playerbots",
"rep.targetPublic": "该报告将公开发布在 GitHub 的 {repo}。",
"rep.botsVersion": "机器人版本",
"rep.withDiag": "替我收集诊断信息(推荐)",
"rep.collectOpen": "收集诊断信息并打开报告",
"rep.collecting": "正在收集诊断信息…",
"overview.reportHint": "某个服务自己停止了?",
"overview.reportBtn": "收集诊断信息并反馈",
// Realmlist switcher and modules page
"realm.label": "服务器列表",
+14
View File
@@ -234,6 +234,19 @@ export interface ReportContext {
windows: string;
install_kind: "new" | "imported";
server_version: string | null;
/** where the form starts: the bot system that is switched on, else the Manager */
suggested_target: ReportTargetId;
/** the release of the bot system that is on */
bots_version: string | null;
}
export type ReportTargetId = "manager" | "companions" | "squid";
/** A place a problem report can go: its GitHub repository as `owner/name`. */
export interface ReportTarget {
id: ReportTargetId;
repo: string;
ours: boolean;
}
export interface InstallRequirements {
@@ -419,6 +432,7 @@ export const api = {
allSettings: (id: string) => invoke<AllSetting[]>("all_settings", { id }),
allSettingsSave: (id: string, changes: Record<string, string>) => invoke<string[]>("all_settings_save", { id, changes }),
reportContext: (id: string) => invoke<ReportContext>("report_context", { id }),
reportTargets: () => invoke<ReportTarget[]>("report_targets"),
listAccounts: (id: string) => invoke<AccountInfo[]>("list_accounts", { id }),
accountSetPassword: (id: string, name: string, password: string) => invoke<void>("account_set_password", { id, name, password }),
accountSetAccess: (id: string, name: string, level: number) => invoke<void>("account_set_access", { id, name, level }),
+13 -4
View File
@@ -1,9 +1,14 @@
import type { ReportTarget, ReportTargetId } from "./api";
/** The text of a problem report, always in English so whoever reads it on GitHub can follow it; the person's own words go in as typed. */
export interface ReportInput {
managerVersion: string;
windows: string;
installKind: "new" | "imported";
serverVersion: string | null;
/** where the report goes; a bot repository is told which Manager and bot release it came from */
target: ReportTargetId;
botsVersion: string | null;
what: string;
expected: string;
steps: string;
@@ -11,7 +16,10 @@ export interface ReportInput {
diagnostics: boolean;
}
export const NEW_ISSUE_URL = "https://github.com/Corfirean/coa-server-manager/issues/new";
/** The "new issue" page of a repository given as `owner/name`. */
export function newIssueUrl(repo: string): string {
return `https://github.com/${repo}/issues/new`;
}
const PRIVACY = "> Please remove passwords, tokens, private IP information or other sensitive data before posting logs.";
export function reportBody(r: ReportInput): string {
@@ -23,6 +31,7 @@ export function reportBody(r: ReportInput): string {
`**Windows version:** ${r.windows || "unknown"} `,
`**Fresh install or imported server:** ${r.installKind === "new" ? "Fresh install" : "Imported server"} `,
...(r.serverVersion ? [`**Server version:** ${r.serverVersion} `] : []),
...(r.target !== "manager" ? [`**Bot system:** ${r.target === "squid" ? "SQUID Playerbots" : "CoA Companions"}${r.botsVersion ? ` ${r.botsVersion}` : ""} `] : []),
"",
"**What happened?** ",
text(r.what, "Describe the problem."),
@@ -54,9 +63,9 @@ export function encodeQuery(s: string): string {
.join("");
}
/** A link that opens GitHub's "new issue" page with the title and text filled in. */
export function issueUrl(title: string, body: string): string {
return `${NEW_ISSUE_URL}?labels=bug&title=${encodeQuery(title)}&body=${encodeQuery(body)}`;
/** A link that opens GitHub's "new issue" page of `target` with the title and text filled in. The bug label is only asked for in our own repositories. */
export function issueUrl(target: Pick<ReportTarget, "repo" | "ours">, title: string, body: string): string {
return `${newIssueUrl(target.repo)}?${target.ours ? "labels=bug&" : ""}title=${encodeQuery(title)}&body=${encodeQuery(body)}`;
}
/** Links longer than this are not reliable in every browser; the full text is then copied to the clipboard instead. */
+7 -1
View File
@@ -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
View File
@@ -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>
);
}
+1 -1
View File
@@ -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" ? (