Skip to content

VoiceStudio is the open-source, fully-local ElevenLabs alternative — voice cloning, voice design, video dubbing, dictation, transcription & audiobook creation in 646 languages.

feat(diagnostics): format host snapshot lines for bug reports

velixio26dc53e5aec4
diff --git a/electron/src/shared/utils/hostSnapshot.test.ts b/electron/src/shared/utils/hostSnapshot.test.ts
new file mode 100644
index 000000000..feaba1496
--- /dev/null
+++ b/electron/src/shared/utils/hostSnapshot.test.ts
@@ -0,0 +1,29 @@
+import { expect, it } from 'vitest';
+import { formatHostSnapshot } from './hostSnapshot';
+
+const snapshot = {
+ os: 'win32 Windows 11 Pro (10.0.26100)',
+ arch: 'x64',
+ cpu: 'Ryzen 9',
+ ramGb: 32,
+ diskFreeGb: 12.5,
+ gpu: 'vendor 0x1002',
+ runtime: { pythonPresent: false, uvPresent: true, pathFlags: ['onedrive'] },
+};
+
+it('adds machine facts only when the backend could not supply them', () => {
+ const down = formatHostSnapshot(snapshot, { machine: true });
+ expect(down).toContain('os (app): win32 Windows 11 Pro (10.0.26100)');
+ expect(down).toContain('runtime python: MISSING');
+ expect(down).toContain('runtime path flags: onedrive');
+ const up = formatHostSnapshot(snapshot, { machine: false });
+ expect(up.some((line) => line.startsWith('os (app)'))).toBe(false);
+ expect(up).toContain('runtime python: MISSING');
+});
+
+it('is empty without a snapshot and says unknown for unresolved files', () => {
+ expect(formatHostSnapshot(null, { machine: true })).toEqual([]);
+ expect(
+ formatHostSnapshot({ runtime: { pythonPresent: null, uvPresent: null } }, { machine: false }),
+ ).toEqual(['runtime python: unknown', 'runtime uv: unknown', 'runtime path flags: none']);
+});
diff --git a/electron/src/shared/utils/hostSnapshot.ts b/electron/src/shared/utils/hostSnapshot.ts
new file mode 100644
index 000000000..51ee12acf
--- /dev/null
+++ b/electron/src/shared/utils/hostSnapshot.ts
@@ -0,0 +1,46 @@
+export interface HostSnapshotLike {
+ os?: string;
+ arch?: string;
+ cpu?: string | null;
+ ramGb?: number;
+ diskFreeGb?: number | null;
+ gpu?: string | null;
+ runtime?: {
+ pythonPresent?: boolean | null;
+ uvPresent?: boolean | null;
+ pathFlags?: string[];
+ };
+}
+
+const present = (value: boolean | null | undefined) =>
+ value == null ? 'unknown' : value ? 'present' : 'MISSING';
+
+/**
+ * Report lines for facts the desktop shell read itself. `machine` is only
+ * needed when the backend could not supply `/system/info`; the runtime lines
+ * are always useful because the backend cannot describe its own missing files.
+ */
+export function formatHostSnapshot(
+ snapshot: HostSnapshotLike | null | undefined,
+ { machine }: { machine: boolean },
+): string[] {
+ if (!snapshot) return [];
+ const lines: string[] = [];
+ if (machine) {
+ if (snapshot.os) lines.push(`os (app): ${snapshot.os}`);
+ if (snapshot.arch) lines.push(`arch (app): ${snapshot.arch}`);
+ if (snapshot.cpu) lines.push(`cpu_model (app): ${snapshot.cpu}`);
+ if (snapshot.ramGb) lines.push(`ram_total_gb (app): ${snapshot.ramGb}`);
+ if (snapshot.gpu) lines.push(`gpu (app): ${snapshot.gpu}`);
+ }
+ if (snapshot.diskFreeGb != null) lines.push(`runtime disk free gb: ${snapshot.diskFreeGb}`);
+ const runtime = snapshot.runtime;
+ if (runtime) {
+ lines.push(`runtime python: ${present(runtime.pythonPresent)}`);
+ lines.push(`runtime uv: ${present(runtime.uvPresent)}`);
+ lines.push(
+ `runtime path flags: ${runtime.pathFlags?.length ? runtime.pathFlags.join(', ') : 'none'}`,
+ );
+ }
+ return lines;
+}