feat: add copy diagnostics button

Add copy diagnostics button in About dialog.
Button copies report with OpenChamber state, OpenCode health, directories, and projects.
Show success or error toasts after copying attempt.
This commit is contained in:
Bohdan Triapitsyn
2026-01-16 14:43:53 +02:00
parent 5389bae465
commit 976018dd32
9 changed files with 234 additions and 332 deletions
+29
View File
@@ -1,6 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { useSessionStore } from '@/stores/useSessionStore';
import { useDirectoryStore } from '@/stores/useDirectoryStore';
import { useProjectsStore } from '@/stores/useProjectsStore';
import { opencodeClient } from '@/lib/opencode/client';
import { checkIsGitRepository } from '@/lib/gitApi';
import { streamDebugEnabled } from '@/stores/utils/streamDebug';
@@ -176,6 +177,7 @@ export const debugUtils = {
async getAppStatus() {
const directoryState = useDirectoryStore.getState();
const sessionState = useSessionStore.getState();
const projectsState = useProjectsStore.getState();
const currentDirectory = directoryState.currentDirectory || null;
const opencodeDirectory = opencodeClient.getDirectory() ?? null;
@@ -291,9 +293,17 @@ export const debugUtils = {
}
}
const projectSamples = projectsState.projects.map((project) => ({
id: project.id,
path: project.path,
label: project.label,
}));
const report = {
runtime: {
platform: runtimeApis?.runtime?.platform ?? null,
isDesktop: isDesktopRuntime,
isVSCode: Boolean(runtimeApis?.runtime?.isVSCode),
hasRuntimeApis: Boolean(runtimeApis),
desktopServerOrigin: desktopServer?.origin ?? null,
},
@@ -313,6 +323,11 @@ export const debugUtils = {
hasPersistedDirectory: directoryState.hasPersistedDirectory,
isSwitchingDirectory: directoryState.isSwitchingDirectory,
},
projects: {
total: projectsState.projects.length,
activeProjectId: projectsState.activeProjectId,
samples: projectSamples,
},
sessions: {
total: sessions.length,
currentSessionId: sessionState.currentSessionId,
@@ -341,6 +356,20 @@ export const debugUtils = {
return report;
},
async buildDiagnosticsReport() {
const report = await this.getAppStatus();
return JSON.stringify(report, null, 2);
},
async copyDiagnosticsReport() {
const report = await this.buildDiagnosticsReport();
if (typeof navigator !== 'undefined' && navigator.clipboard) {
await navigator.clipboard.writeText(report);
return { ok: true, report } as const;
}
return { ok: false, report } as const;
},
checkLastMessage() {
const info = this.getLastAssistantMessage();
if (!info) return false;