Skip to content

A desktop coding agent with free access to frontier models.

TypeScript

feat(settings): Diagnostics section with copy, export and open logs folder

ogsamrat787671bfb9fc
diff --git a/apps/app/src/app/lib/desktop.ts b/apps/app/src/app/lib/desktop.ts
index 1d017b38..fb18b832 100644
--- a/apps/app/src/app/lib/desktop.ts
+++ b/apps/app/src/app/lib/desktop.ts
@@ -771,6 +771,7 @@ const {
resetOpencodeCache,
opencodeMcpAuth,
setWindowDecorations,
+ openLogsFolder,
} = desktopBridge;
export {
@@ -829,4 +830,5 @@ export {
resetOpencodeCache,
opencodeMcpAuth,
setWindowDecorations,
+ openLogsFolder,
};
diff --git a/apps/app/src/app/lib/diagnostics-bundle.ts b/apps/app/src/app/lib/diagnostics-bundle.ts
index e19e8a29..dbb9b7a9 100644
--- a/apps/app/src/app/lib/diagnostics-bundle.ts
+++ b/apps/app/src/app/lib/diagnostics-bundle.ts
@@ -43,6 +43,8 @@ export type DiagnosticsBundleInputs = {
hostInfo: OmniRushServerInfo | null;
developerLogs: DevLogRecord[];
perfLogs: PerfLogRecord[];
+ /** Renderer-side platform guess, used when the desktop bridge does not report its OS. */
+ platform?: string | null;
context?: DiagnosticsBundleContext;
cloudMcpHealth?: unknown;
};
@@ -65,6 +67,8 @@ function pickAppInfo(info: AppBuildInfo | null) {
gitSha: info.gitSha ?? null,
buildEpoch: info.buildEpoch ?? null,
omnirushDevMode: info.omnirushDevMode ?? null,
+ os: info.os ?? null,
+ arch: info.arch ?? null,
};
}
@@ -103,8 +107,13 @@ function pickEngineInfo(info: EngineInfo | null) {
function pickHostInfo(info: OmniRushServerInfo | null) {
if (!info) return null;
+ const generation = typeof info.generation === "number" ? info.generation : null;
return {
running: Boolean(info.running),
+ // The desktop runtime counts built-in server starts per app launch; it
+ // does not record restart reasons or times (those are in omnirush-server.log).
+ generation,
+ restartsThisLaunch: generation === null ? null : Math.max(0, generation - 1),
remoteAccessEnabled: info.remoteAccessEnabled,
baseUrl: info.baseUrl ?? null,
connectUrl: info.connectUrl ?? null,
@@ -157,6 +166,7 @@ export function composeDiagnosticsBundleJson(input: DiagnosticsBundleInputs): st
opencodeEngine: pickEngineInfo(input.engineInfo),
runtime: {
tauri: input.desktopRuntime,
+ platform: input.appInfo?.os ?? input.platform ?? null,
developerMode: context?.developerMode === true,
},
session: {
@@ -225,6 +235,13 @@ async function readHostInfo(desktopRuntime: boolean) {
}
}
+function readNavigatorPlatform(): string | null {
+ if (typeof navigator === "undefined") return null;
+ const nav = navigator as Navigator & { userAgentData?: { platform?: string } };
+ const platform = nav.userAgentData?.platform || nav.platform || "";
+ return platform.trim() || null;
+}
+
export async function buildDiagnosticsBundleJson(context?: DiagnosticsBundleContext): Promise<string> {
const desktopRuntime = isDesktopRuntime();
const hasContextHostInfo = context !== undefined && "hostInfo" in context;
@@ -241,6 +258,7 @@ export async function buildDiagnosticsBundleJson(context?: DiagnosticsBundleCont
hostInfo,
developerLogs: readDevLogs(80),
perfLogs: readPerfLogs(80),
+ platform: readNavigatorPlatform(),
context,
});
}
diff --git a/apps/app/src/i18n/locales/en.ts b/apps/app/src/i18n/locales/en.ts
index b4081d94..fd6020c6 100644
--- a/apps/app/src/i18n/locales/en.ts
+++ b/apps/app/src/i18n/locales/en.ts
@@ -1492,6 +1492,13 @@ export default {
"settings.diag_workspaces": "Workspaces: {count}",
"settings.agent_diagnostics_desc": "Run a bounded, redacted check of what the agent actually receives: effective agent, context markers, MCP inventory, and Cloud tool access.",
"settings.agent_diagnostics_title": "Agent context diagnostics",
+ "settings.diagnostics_card_desc": "Share a sanitized report when something goes wrong. Tokens are redacted and chat content is not included. The logs folder holds omnirush-server.log.",
+ "settings.diagnostics_card_title": "Report a problem",
+ "settings.diagnostics_failed": "Could not prepare diagnostics",
+ "settings.diagnostics_open_logs": "Open logs folder",
+ "settings.diagnostics_open_logs_done": "Opened the logs folder",
+ "settings.diagnostics_open_logs_failed": "Could not open the logs folder",
+ "settings.diagnostics_section_title": "Diagnostics",
"settings.diagnostics_unavailable": "Diagnostics unavailable.",
"settings.disable_developer_mode": "Disable Developer Mode",
"settings.disabled": "Disabled",
diff --git a/apps/app/src/react-app/domains/settings/pages/diagnostics-section.tsx b/apps/app/src/react-app/domains/settings/pages/diagnostics-section.tsx
new file mode 100644
index 00000000..3eab4ec0
--- /dev/null
+++ b/apps/app/src/react-app/domains/settings/pages/diagnostics-section.tsx
@@ -0,0 +1,163 @@
+/** @jsxImportSource react */
+import { useState } from "react";
+import { ClipboardCopy, Download, FolderOpen, LifeBuoy } from "lucide-react";
+
+import { t } from "../../../../i18n";
+import { buildDiagnosticsBundleJson } from "../../../../app/lib/diagnostics-bundle";
+import { openLogsFolder } from "../../../../app/lib/desktop";
+import { downloadTextAsFile } from "../../../../app/lib/download";
+import { isElectronRuntime } from "../../../../app/utils";
+
+export type DiagnosticsActionDeps = {
+ buildBundle: () => Promise<string>;
+ writeClipboard: (text: string) => Promise<void>;
+ saveFile: (filename: string, content: string) => void;
+ openLogsFolder: () => Promise<{ ok: boolean; error?: string } | undefined | void>;
+ now?: () => Date;
+};
+
+export type DiagnosticsActionResult = { ok: boolean; message: string };
+
+function errorText(error: unknown): string {
+ if (error instanceof Error && error.message.trim()) return error.message.trim();
+ return String(error ?? "").trim();
+}
+
+function failure(error: unknown): DiagnosticsActionResult {
+ const detail = errorText(error);
+ const base = t("settings.diagnostics_failed");
+ return { ok: false, message: detail ? `${base}: ${detail}` : base };
+}
+
+/** File name for an exported bundle, e.g. omnirush-diagnostics-2026-09-24T08-32-30-000Z.json. */
+export function diagnosticsExportFileName(date: Date): string {
+ return `omnirush-diagnostics-${date.toISOString().replace(/[:.]/g, "-")}.json`;
+}
+
+export async function copyDiagnostics(deps: DiagnosticsActionDeps): Promise<DiagnosticsActionResult> {
+ try {
+ await deps.writeClipboard(await deps.buildBundle());
+ return { ok: true, message: t("session.diagnostics_copied") };
+ } catch (error) {
+ return failure(error);
+ }
+}
+
+export async function exportDiagnostics(deps: DiagnosticsActionDeps): Promise<DiagnosticsActionResult> {
+ try {
+ const json = await deps.buildBundle();
+ deps.saveFile(diagnosticsExportFileName(deps.now?.() ?? new Date()), json);
+ return { ok: true, message: t("session.diagnostics_exported") };
+ } catch (error) {
+ return failure(error);
+ }
+}
+
+export async function openDiagnosticsLogsFolder(deps: DiagnosticsActionDeps): Promise<DiagnosticsActionResult> {
+ try {
+ const result = await deps.openLogsFolder();
+ if (result && result.ok === false) {
+ const detail = result.error?.trim();
+ const base = t("settings.diagnostics_open_logs_failed");
+ return { ok: false, message: detail ? `${base}: ${detail}` : base };
+ }
+ return { ok: true, message: t("settings.diagnostics_open_logs_done") };
+ } catch (error) {
+ const detail = errorText(error);
+ const base = t("settings.diagnostics_open_logs_failed");
+ return { ok: false, message: detail ? `${base}: ${detail}` : base };
+ }
+}
+
+function defaultDeps(buildBundle?: () => Promise<string>): DiagnosticsActionDeps {
+ return {
+ buildBundle: buildBundle ?? (() => buildDiagnosticsBundleJson()),
+ writeClipboard: (text) => navigator.clipboard.writeText(text),
+ saveFile: (filename, content) => downloadTextAsFile(filename, content, "application/json"),
+ openLogsFolder: () => openLogsFolder(),
+ };
+}
+
+type DiagnosticsAction = "copy" | "export" | "logs";
+
+export type DiagnosticsSectionProps = {
+ /** Builds the sanitized bundle with the caller's route context. */
+ buildBundle?: () => Promise<string>;
+ /** "Open logs folder" needs the desktop app; defaults to the current runtime. */
+ canOpenLogsFolder?: boolean;
+ /** Test seam: replaces clipboard, file save and IPC. */
+ deps?: DiagnosticsActionDeps;
+};
+
+/**
+ * Settings > General > Diagnostics. The same sanitized bundle as the
+ * command palette's "Copy diagnostics", plus a shortcut to the logs folder
+ * that holds omnirush-server.log.
+ */
+export function DiagnosticsSection(props: DiagnosticsSectionProps) {
+ const [busy, setBusy] = useState<DiagnosticsAction | null>(null);
+ const [result, setResult] = useState<DiagnosticsActionResult | null>(null);
+ const canOpenLogsFolder = props.canOpenLogsFolder ?? isElectronRuntime();
+
+ async function run(action: DiagnosticsAction) {
+ const deps = props.deps ?? defaultDeps(props.buildBundle);
+ setBusy(action);
+ setResult(null);
+ try {
+ const next = action === "copy"
+ ? await copyDiagnostics(deps)
+ : action === "export"
+ ? await exportDiagnostics(deps)
+ : await openDiagnosticsLogsFolder(deps);
+ setResult(next);
+ } finally {
+ setBusy(null);
+ }
+ }
+
+ const buttonClass = "inline-flex items-center gap-1.5 rounded-lg border border-dls-border px-3 py-2 text-[12px] text-dls-text hover:bg-dls-hover disabled:opacity-50";
+
+ return (
+ <div className="space-y-3" data-testid="settings-diagnostics">
+ <div className="text-[11px] font-semibold uppercase tracking-[0.15em] text-dls-secondary">
+ {t("settings.diagnostics_section_title")}
+ </div>
+ <div className="flex items-start gap-4 rounded-2xl border border-dls-border bg-dls-surface p-4">
+ <div className="flex h-10 w-10 shrink-0 items-center justify-center rounded-xl border border-dls-border bg-dls-hover">
+ <LifeBuoy size={17} className="text-dls-secondary" />
+ </div>
+ <div className="min-w-0 flex-1 space-y-3">
+ <div>
+ <div className="text-[13px] font-medium text-dls-text">{t("settings.diagnostics_card_title")}</div>
+ <div className="text-[11px] text-dls-secondary">{t("settings.diagnostics_card_desc")}</div>
+ </div>
+ <div className="flex flex-wrap gap-2">
+ <button type="button" className={buttonClass} disabled={busy !== null} onClick={() => void run("copy")}>
+ <ClipboardCopy size={13} />
+ {t("session.cmd_diagnostics_copy_title")}
+ </button>
+ <button type="button" className={buttonClass} disabled={busy !== null} onClick={() => void run("export")}>
+ <Download size={13} />
+ {t("session.cmd_diagnostics_export_title")}
+ </button>
+ {canOpenLogsFolder ? (
+ <button type="button" className={buttonClass} disabled={busy !== null} onClick={() => void run("logs")}>
+ <FolderOpen size={13} />
+ {t("settings.diagnostics_open_logs")}
+ </button>
+ ) : null}
+ </div>
+ {result ? (
+ <div
+ className={`text-[11px] ${result.ok ? "text-dls-secondary" : "text-red-400"}`}
+ role="status"
+ data-testid="settings-diagnostics-status"
+ >
+ {result.message}
+ </div>
+ ) : null}
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/apps/app/src/react-app/domains/settings/pages/general-view.tsx b/apps/app/src/react-app/domains/settings/pages/general-view.tsx
index 3e7de751..3c6de53d 100644
--- a/apps/app/src/react-app/domains/settings/pages/general-view.tsx
+++ b/apps/app/src/react-app/domains/settings/pages/general-view.tsx
@@ -31,6 +31,7 @@ import {
useApprovalMode,
type ApprovalsClient,
} from "../approval-mode";
+import { DiagnosticsSection } from "./diagnostics-section";
export type GeneralSettingsViewProps = {
onNavigateTab: (tab: SettingsTab) => void;
@@ -39,6 +40,8 @@ export type GeneralSettingsViewProps = {
omnirushClient?: ApprovalsClient | null;
/** Workspace whose engine is reloaded after the approval mode changes. */
runtimeWorkspaceId?: string | null;
+ /** Builds the sanitized diagnostics bundle with the route's context. */
+ buildDiagnosticsBundle?: () => Promise<string>;
};
type NativeAccountStatus = Awaited<ReturnType<typeof omnirushAccountStatus>>;
@@ -328,6 +331,8 @@ export function GeneralSettingsView(props: GeneralSettingsViewProps) {
onToggle={(enabled) => void approvalMode.setFullPermissions(enabled)}
/>
) : null}
+
+ <DiagnosticsSection buildBundle={props.buildDiagnosticsBundle} />
</div>
);
}
diff --git a/apps/app/src/react-app/shell/settings-route.tsx b/apps/app/src/react-app/shell/settings-route.tsx
index 70c9d3d9..933494c1 100644
--- a/apps/app/src/react-app/shell/settings-route.tsx
+++ b/apps/app/src/react-app/shell/settings-route.tsx
@@ -98,6 +98,7 @@ import {
loadConnectCapabilities,
readCachedConnectCapabilities,
} from "@/react-app/domains/connections/cloud-inventory-cache";
+import { buildDiagnosticsBundleJson } from "@/app/lib/diagnostics-bundle";
import { createOpaqueDiagnosticsScopeKey } from "@/react-app/domains/settings/pages/agent-context-diagnostics-section";
import { CloudProvidersView } from "@/react-app/domains/settings/pages/cloud-providers-view";
import { DebugView } from "@/react-app/domains/settings/pages/debug-view";
@@ -2246,6 +2247,12 @@ function SettingsRouteContent(props: SettingsSurfaceProps = {}) {
developerMode={developerMode}
omnirushClient={omnirushClient}
runtimeWorkspaceId={runtimeWorkspaceId}
+ buildDiagnosticsBundle={() => buildDiagnosticsBundleJson({
+ developerMode,
+ omnirushServerStatus: routeOmniRushStatus,
+ runtimeWorkspaceId,
+ selectedWorkspaceId,
+ })}
/>
);
case "permissions":
diff --git a/apps/app/tests/diagnostics-bundle.test.ts b/apps/app/tests/diagnostics-bundle.test.ts
index cef534e0..2e7eca40 100644
--- a/apps/app/tests/diagnostics-bundle.test.ts
+++ b/apps/app/tests/diagnostics-bundle.test.ts
@@ -172,4 +172,76 @@ describe("diagnostics bundle", () => {
expect(json).not.toContain("owt_den_synthetic_secret");
expect(json).not.toContain("eyJhbGciOiJIUzI1NiJ9");
});
+ test("reports app version, platform and built-in server starts this launch", () => {
+ const input = baseInputs();
+ input.desktopRuntime = true;
+ input.platform = "MacIntel";
+ input.appInfo = { version: "1.1.1", gitSha: "abc1234", os: "win32", arch: "x64" };
+ input.hostInfo = {
+ running: true,
+ generation: 3,
+ remoteAccessEnabled: false,
+ host: "127.0.0.1",
+ port: 4096,
+ baseUrl: "http://127.0.0.1:4096",
+ connectUrl: null,
+ mdnsUrl: null,
+ lanUrl: null,
+ clientToken: null,
+ ownerToken: null,
+ hostToken: null,
+ managedOpencodeBinPath: null,
+ managedOpencodeBinSource: null,
+ logFilePath: "C:\\Users\\someone\\AppData\\Roaming\\ai.omnirush.desktop\\logs\\omnirush-server.log",
+ pid: null,
+ lastStdout: null,
+ lastStderr: null,
+ managedOpencodeExecution: null,
+ };
+
+ const json = composeDiagnosticsBundleJson(input);
+ const parsed = JSON.parse(json);
+
+ expect(parsed.app.version).toBe("1.1.1");
+ expect(parsed.app.os).toBe("win32");
+ expect(parsed.app.arch).toBe("x64");
+ expect(parsed.runtime.platform).toBe("win32");
+ expect(parsed.omnirushServer.host.generation).toBe(3);
+ expect(parsed.omnirushServer.host.restartsThisLaunch).toBe(2);
+ // The log file path names the user's home folder; the bundle never carries it.
+ expect(json).not.toContain("omnirush-server.log");
+ expect(json).not.toContain("someone");
+ });
+
+ test("falls back to the renderer platform and reports unknown server starts as null", () => {
+ const input = baseInputs();
+ input.platform = "Linux x86_64";
+ input.hostInfo = {
+ running: false,
+ generation: null,
+ remoteAccessEnabled: false,
+ host: null,
+ port: null,
+ baseUrl: null,
+ connectUrl: null,
+ mdnsUrl: null,
+ lanUrl: null,
+ clientToken: null,
+ ownerToken: null,
+ hostToken: null,
+ managedOpencodeBinPath: null,
+ managedOpencodeBinSource: null,
+ logFilePath: null,
+ pid: null,
+ lastStdout: null,
+ lastStderr: null,
+ managedOpencodeExecution: null,
+ };
+
+ const parsed = JSON.parse(composeDiagnosticsBundleJson(input));
+
+ expect(parsed.runtime.platform).toBe("Linux x86_64");
+ expect(parsed.omnirushServer.host.generation).toBeNull();
+ expect(parsed.omnirushServer.host.restartsThisLaunch).toBeNull();
+ });
});
diff --git a/apps/app/tests/settings-diagnostics-section.test.tsx b/apps/app/tests/settings-diagnostics-section.test.tsx
new file mode 100644
index 00000000..b3ef44b9
--- /dev/null
+++ b/apps/app/tests/settings-diagnostics-section.test.tsx
@@ -0,0 +1,87 @@
+/** @jsxImportSource react */
+import { describe, expect, test } from "bun:test";
+import { renderToStaticMarkup } from "react-dom/server";
+
+import {
+ DiagnosticsSection,
+ copyDiagnostics,
+ diagnosticsExportFileName,
+ exportDiagnostics,
+ openDiagnosticsLogsFolder,
+ type DiagnosticsActionDeps,
+} from "../src/react-app/domains/settings/pages/diagnostics-section";
+
+function fakeDeps(overrides: Partial<DiagnosticsActionDeps> = {}) {
+ const calls = { clipboard: [] as string[], saved: [] as Array<{ filename: string; content: string }>, logs: 0 };
+ const deps: DiagnosticsActionDeps = {
+ buildBundle: async () => '{"app":{"version":"1.1.1"}}',
+ writeClipboard: async (text) => { calls.clipboard.push(text); },
+ saveFile: (filename, content) => { calls.saved.push({ filename, content }); },
+ openLogsFolder: async () => { calls.logs += 1; return { ok: true }; },
+ now: () => new Date("2026-09-24T08:32:30.000Z"),
+ ...overrides,
+ };
+ return { deps, calls };
+}
+
+describe("settings diagnostics section", () => {
+ test("renders copy, export and open-logs actions in the desktop app", () => {
+ const markup = renderToStaticMarkup(<DiagnosticsSection canOpenLogsFolder deps={fakeDeps().deps} />);
+ expect(markup).toContain("Diagnostics");
+ expect(markup).toContain("Copy diagnostics");
+ expect(markup).toContain("Export diagnostics");
+ expect(markup).toContain("Open logs folder");
+ expect(markup).toContain("omnirush-server.log");
+ });
+
+ test("hides the logs folder button outside the desktop app", () => {
+ const markup = renderToStaticMarkup(<DiagnosticsSection canOpenLogsFolder={false} deps={fakeDeps().deps} />);
+ expect(markup).toContain("Copy diagnostics");
+ expect(markup).toContain("Export diagnostics");
+ expect(markup).not.toContain("Open logs folder");
+ });
+
+ test("copies the sanitized bundle to the clipboard", async () => {
+ const { deps, calls } = fakeDeps();
+ const result = await copyDiagnostics(deps);
+ expect(result.ok).toBe(true);
+ expect(calls.clipboard).toEqual(['{"app":{"version":"1.1.1"}}']);
+ });
+
+ test("exports the same bundle as a timestamped JSON file", async () => {
+ const { deps, calls } = fakeDeps();
+ const result = await exportDiagnostics(deps);
+ expect(result.ok).toBe(true);
+ expect(calls.saved).toEqual([
+ { filename: "omnirush-diagnostics-2026-09-24T08-32-30-000Z.json", content: '{"app":{"version":"1.1.1"}}' },
+ ]);
+ expect(diagnosticsExportFileName(new Date("2026-01-02T03:04:05.006Z"))).toBe(
+ "omnirush-diagnostics-2026-01-02T03-04-05-006Z.json",
+ );
+ });
+
+ test("reports a bundle failure instead of throwing", async () => {
+ const { deps, calls } = fakeDeps({ buildBundle: async () => { throw new Error("bridge unavailable"); } });
+ const copied = await copyDiagnostics(deps);
+ const exported = await exportDiagnostics(deps);
+ expect(copied.ok).toBe(false);
+ expect(copied.message).toContain("bridge unavailable");
+ expect(exported.ok).toBe(false);
+ expect(calls.clipboard).toEqual([]);
+ expect(calls.saved).toEqual([]);
+ });
+
+ test("opens the logs folder through the desktop bridge and surfaces its error", async () => {
+ const ok = fakeDeps();
+ expect((await openDiagnosticsLogsFolder(ok.deps)).ok).toBe(true);
+ expect(ok.calls.logs).toBe(1);
+
+ const refused = fakeDeps({ openLogsFolder: async () => ({ ok: false, error: "Only the main window can open the logs folder." }) });
+ const result = await openDiagnosticsLogsFolder(refused.deps);
+ expect(result.ok).toBe(false);
+ expect(result.message).toContain("Only the main window");
+
+ const missingBridge = fakeDeps({ openLogsFolder: async () => { throw new Error("Electron desktop helper is unavailable: openLogsFolder"); } });
+ expect((await openDiagnosticsLogsFolder(missingBridge.deps)).ok).toBe(false);
+ });
+});
diff --git a/apps/desktop/electron/logs-folder.mjs b/apps/desktop/electron/logs-folder.mjs
new file mode 100644
index 00000000..a49a3420
--- /dev/null
+++ b/apps/desktop/electron/logs-folder.mjs
@@ -0,0 +1,53 @@
+import path from "node:path";
+
+/**
+ * The folder that holds the desktop app's on-disk logs, among them the
+ * built-in server's omnirush-server.log (see resolveOmniRushServerLogFile).
+ * It is always <userData>/logs; nothing the renderer sends can change it.
+ */
+export function resolveDesktopLogsDir(userDataPath) {
+ const base = typeof userDataPath === "string" ? userDataPath.trim() : "";
+ if (!base || !path.isAbsolute(base)) {
+ throw new Error("The app data folder is unavailable.");
+ }
+ return path.join(base, "logs");
+}
+
+/**
+ * Builds the handler behind Settings > Diagnostics > "Open logs folder".
+ *
+ * It takes no input from the renderer: every argument after the IPC event is
+ * ignored, so a compromised page cannot turn it into a generic "open this
+ * path" call. Only the main window's top frame may call it. The folder is
+ * created first, so the button works before the server has written a log.
+ *
+ * @param {{
+ * getUserDataPath: () => string,
+ * isTrustedSender: (event: any) => boolean,
+ * ensureDir: (dir: string) => Promise<unknown>,
+ * openPath: (dir: string) => Promise<string>,
+ * }} deps
+ */
+export function createOpenLogsFolderHandler(deps) {
+ /**
+ * @param {unknown} event
+ * @param {unknown[]} _ignored renderer arguments, never used
+ */
+ return async function openLogsFolder(event, ..._ignored) {
+ if (!deps.isTrustedSender(event)) {
+ return { ok: false, error: "Only the main window can open the logs folder." };
+ }
+ let dir;
+ try {
+ dir = resolveDesktopLogsDir(deps.getUserDataPath());
+ await deps.ensureDir(dir);
+ } catch (error) {
+ return { ok: false, error: error instanceof Error ? error.message : "The logs folder could not be created." };
+ }
+ const failure = await deps.openPath(dir);
+ if (typeof failure === "string" && failure.trim()) {
+ return { ok: false, error: failure.trim() };
+ }
+ return { ok: true };
+ };
+}
diff --git a/apps/desktop/electron/logs-folder.test.mjs b/apps/desktop/electron/logs-folder.test.mjs
new file mode 100644
index 00000000..fe0b493a
--- /dev/null
+++ b/apps/desktop/electron/logs-folder.test.mjs
@@ -0,0 +1,90 @@
+import { describe, it } from "node:test";
+import assert from "node:assert/strict";
+import { readFileSync } from "node:fs";
+import path from "node:path";
+import { fileURLToPath } from "node:url";
+
+import { createOpenLogsFolderHandler, resolveDesktopLogsDir } from "./logs-folder.mjs";
+
+const USER_DATA = path.resolve("/tmp/omnirush-test-user-data");
+const trustedEvent = { trusted: true };
+
+function harness(overrides = {}) {
+ const calls = { ensured: [], opened: [] };
+ const handler = createOpenLogsFolderHandler({
+ getUserDataPath: () => USER_DATA,
+ isTrustedSender: (event) => event?.trusted === true,
+ ensureDir: async (dir) => { calls.ensured.push(dir); },
+ openPath: async (dir) => { calls.opened.push(dir); return ""; },
+ ...overrides,
+ });
+ return { handler, calls };
+}
+
+describe("resolveDesktopLogsDir", () => {
+ it("is the logs folder inside userData", () => {
+ assert.equal(resolveDesktopLogsDir(USER_DATA), path.join(USER_DATA, "logs"));
+ });
+
+ it("refuses an empty or relative userData path", () => {
+ assert.throws(() => resolveDesktopLogsDir(""));
+ assert.throws(() => resolveDesktopLogsDir("relative/dir"));
+ assert.throws(() => resolveDesktopLogsDir(undefined));
+ });
+});
+
+describe("openLogsFolder IPC handler", () => {
+ it("creates and opens <userData>/logs", async () => {
+ const { handler, calls } = harness();
+ assert.deepEqual(await handler(trustedEvent), { ok: true });
+ assert.deepEqual(calls.ensured, [path.join(USER_DATA, "logs")]);
+ assert.deepEqual(calls.opened, [path.join(USER_DATA, "logs")]);
+ });
+
+ it("ignores any path the renderer sends", async () => {
+ const { handler, calls } = harness();
+ await handler(trustedEvent, "/etc", "C:\\Windows\\System32", { path: "/" });
+ assert.deepEqual(calls.opened, [path.join(USER_DATA, "logs")]);
+ });
+
+ it("rejects callers other than the main window without touching the disk", async () => {
+ const { handler, calls } = harness();
+ const result = await handler({ trusted: false });
+ assert.equal(result.ok, false);
+ assert.match(result.error, /main window/);
+ assert.deepEqual(calls.ensured, []);
+ assert.deepEqual(calls.opened, []);
+ });
+
+ it("reports the shell's error string", async () => {
+ const { handler } = harness({ openPath: async () => "No application is associated" });
+ assert.deepEqual(await handler(trustedEvent), { ok: false, error: "No application is associated" });
+ });
+
+ it("reports a folder that cannot be created and does not open anything", async () => {
+ const opened = [];
+ const { handler } = harness({
+ ensureDir: async () => { throw new Error("EACCES"); },
+ openPath: async (dir) => { opened.push(dir); return ""; },
+ });
+ assert.deepEqual(await handler(trustedEvent), { ok: false, error: "EACCES" });
+ assert.deepEqual(opened, []);
+ });
+});
+
+describe("main process wiring", () => {
+ const mainSource = readFileSync(path.join(path.dirname(fileURLToPath(import.meta.url)), "main.mjs"), "utf8");
+
+ it("registers openLogsFolder so that only the IPC event reaches the handler", () => {
+ assert.match(mainSource, /^ "openLogsFolder": async \(event\) => \{\n return openLogsFolder\(event\);\n \},$/m);
+ });
+
+ it("guards on the main window's top frame and the fixed userData path", () => {
+ const start = mainSource.indexOf("const openLogsFolder = createOpenLogsFolderHandler({");
+ assert.notEqual(start, -1);
+ const block = mainSource.slice(start, mainSource.indexOf("});", start));
+ assert.match(block, /getUserDataPath: \(\) => app\.getPath\("userData"\)/);
+ assert.match(block, /event\?\.sender === mainWindow\.webContents/);
+ assert.match(block, /event\?\.senderFrame === mainWindow\.webContents\.mainFrame/);
+ });
+});
diff --git a/apps/desktop/electron/main.mjs b/apps/desktop/electron/main.mjs
index 5b53a9f6..94419f1d 100644
--- a/apps/desktop/electron/main.mjs
+++ b/apps/desktop/electron/main.mjs
@@ -78,6 +78,7 @@ import {
windowsIconFromNativeImage,
} from "./brand-icon-windows.mjs";
import { resetMacDockIcon } from "./brand-icon-darwin.mjs";
+import { createOpenLogsFolderHandler } from "./logs-folder.mjs";
import { createDesktopVaultKeyProvider } from "./secure-vault-key.mjs";
import { applyLinuxPasswordStore, recordLinuxPasswordStore } from "./linux-password-store.mjs";
import { createDesktopOmniRushAccountStore, legacyKeychainAllowed } from "./omnirush-account.mjs";
@@ -1829,6 +1830,18 @@ function applyNativeTheme(mode) {
return true;
}
+const openLogsFolder = createOpenLogsFolderHandler({
+ getUserDataPath: () => app.getPath("userData"),
+ isTrustedSender: (/** @type {any} */ event) => Boolean(
+ mainWindow
+ && !mainWindow.isDestroyed()
+ && event?.sender === mainWindow.webContents
+ && event?.senderFrame === mainWindow.webContents.mainFrame,
+ ),
+ ensureDir: (dir) => mkdir(dir, { recursive: true }),
+ openPath: (dir) => shell.openPath(dir),
+});
+
// Desktop IPC command registry. Every command invokable from the renderer's
// desktopBridge Proxy (apps/app/src/app/lib/desktop.ts) has exactly one
// entry here; handlers receive the ipcMain event followed by the renderer
@@ -1932,6 +1945,8 @@ const desktopCommandHandlers = {
gitSha: process.env.OMNIRUSH_GIT_SHA ?? null,
buildEpoch: process.env.OMNIRUSH_BUILD_EPOCH ?? null,
omnirushDevMode: process.env.OMNIRUSH_DEV_MODE === "1",
+ os: process.platform,
+ arch: process.arch,
};
},
"desktopNotificationShow": async (event, ...args) => {
@@ -2261,6 +2276,10 @@ const desktopCommandHandlers = {
"setWindowDecorations": async (event, ...args) => {
return undefined;
},
+ // Settings > Diagnostics. Opens <userData>/logs only; renderer arguments are ignored.
+ "openLogsFolder": async (event) => {
+ return openLogsFolder(event);
+ },
"__openPath": async (event, ...args) => {
const target = String(args[0] ?? "").trim();
if (!target) return "Path is required.";
diff --git a/apps/desktop/package.json b/apps/desktop/package.json
index 836997a5..715b3f03 100644
--- a/apps/desktop/package.json
+++ b/apps/desktop/package.json
@@ -27,7 +27,7 @@
"prepare:sidecar": "node ./scripts/prepare-sidecar.mjs",
"pretest": "pnpm --filter @omnirush/headless-threads build",
"test:omnirush-account": "node --test electron/omnirush-account.test.mjs",
- "test": "node --test scripts/prepare-server-constants.test.mjs scripts/verify-update-manifest.test.mjs electron/after-pack-paths.test.mjs electron/agent-context-diagnostics-fetch.test.mjs electron/automation-runner.test.mjs electron/binary-transfer.test.mjs electron/blank-slate-profile.test.mjs electron/blank-slate-profile-isolation.test.mjs electron/brand-app-name.test.mjs electron/brand-icon-darwin.test.mjs electron/brand-icon-windows.test.mjs electron/browser-login-sync.test.mjs electron/browser-panel.test.mjs electron/connect-link.test.mjs electron/desktop-distribution.test.mjs electron/dev-profile.test.mjs electron/electron-builder-config.test.mjs electron/linux-desktop-integration.test.mjs electron/linux-password-store.test.mjs electron/no-bare-external-fetch.test.mjs electron/nuke.test.mjs electron/omnirush-account.test.mjs electron/omnirush-ui-mcp.test.mjs electron/open-external.test.mjs electron/process-resilience.test.mjs electron/runtime.test.mjs electron/runtime-ca.test.mjs electron/runtime-chain-repair.test.mjs electron/sentry.test.mjs electron/server-dependency-mirror.test.mjs electron/secure-vault-key.test.mjs electron/stdio-errors.test.mjs electron/ui-control-server.test.mjs electron/updater.test.mjs electron/remote-workspace.test.mjs electron/workspace-archive.test.mjs electron/workspace-store.test.mjs",
+ "test": "node --test scripts/prepare-server-constants.test.mjs scripts/verify-update-manifest.test.mjs electron/after-pack-paths.test.mjs electron/agent-context-diagnostics-fetch.test.mjs electron/automation-runner.test.mjs electron/binary-transfer.test.mjs electron/blank-slate-profile.test.mjs electron/blank-slate-profile-isolation.test.mjs electron/brand-app-name.test.mjs electron/brand-icon-darwin.test.mjs electron/brand-icon-windows.test.mjs electron/browser-login-sync.test.mjs electron/browser-panel.test.mjs electron/connect-link.test.mjs electron/desktop-distribution.test.mjs electron/dev-profile.test.mjs electron/electron-builder-config.test.mjs electron/linux-desktop-integration.test.mjs electron/linux-password-store.test.mjs electron/logs-folder.test.mjs electron/no-bare-external-fetch.test.mjs electron/nuke.test.mjs electron/omnirush-account.test.mjs electron/omnirush-ui-mcp.test.mjs electron/open-external.test.mjs electron/process-resilience.test.mjs electron/runtime.test.mjs electron/runtime-ca.test.mjs electron/runtime-chain-repair.test.mjs electron/sentry.test.mjs electron/server-dependency-mirror.test.mjs electron/secure-vault-key.test.mjs electron/stdio-errors.test.mjs electron/ui-control-server.test.mjs electron/updater.test.mjs electron/remote-workspace.test.mjs electron/workspace-archive.test.mjs electron/workspace-store.test.mjs",
"test:core": "node --test scripts/prepare-server-constants.test.mjs electron/workspace-store.test.mjs electron/workspace-archive.test.mjs electron/connect-link.test.mjs electron/open-external.test.mjs electron/secure-vault-key.test.mjs electron/process-resilience.test.mjs electron/stdio-errors.test.mjs electron/runtime-ca.test.mjs electron/runtime-chain-repair.test.mjs electron/automation-runner.test.mjs",
"pretest:core": "pnpm --filter @omnirush/headless-threads build"
},
diff --git a/packages/types/src/desktop-ipc.ts b/packages/types/src/desktop-ipc.ts
index b16914ae..a50be889 100644
--- a/packages/types/src/desktop-ipc.ts
+++ b/packages/types/src/desktop-ipc.ts
@@ -628,6 +628,9 @@ export type DesktopCommandMap = {
opencodeMcpAuth: { args: [action: string, name: string]; result: ExecResult };
setWindowDecorations: { args: [decorated: boolean]; result: unknown };
+ /** Opens <userData>/logs in the system file manager. Takes no path from the renderer. */
+ openLogsFolder: { args: []; result: { ok: boolean; error?: string } };
+
// Window / OS utilities (dunder commands)
__openPath: { args: [target: string]; result: unknown };
__revealItemInDir: { args: [target: string]; result: unknown };