| 49 | } |
| 50 | |
| 51 | export async function exportDebugLogs() { |
| 52 | const restartNetLog = netLog.currentlyLogging |
| 53 | if (restartNetLog) { |
| 54 | await netLog.stopLogging().catch((error) => write("network", "failed to stop net log", { error })) |
| 55 | } |
| 56 | |
| 57 | const output = join(app.getPath("downloads"), `opencode-debug-${stamp()}.zip`) |
| 58 | try { |
| 59 | write("main", "exporting debug logs", { output }) |
| 60 | await writeZip(output, [ |
| 61 | { name: "manifest.json", data: Buffer.from(JSON.stringify(manifest(), null, 2)) }, |
| 62 | ...collect(root, "desktop"), |
| 63 | ...serverLogRoots().flatMap((dir, i) => collect(dir, `server-${i + 1}`)), |
| 64 | ...collect(app.getPath("crashDumps"), "crashpad"), |
| 65 | ]) |
| 66 | shell.showItemInFolder(output) |
| 67 | return output |
| 68 | } finally { |
| 69 | if (restartNetLog) { |
| 70 | await startNetLog().catch((error) => write("network", "failed to restart net log", { error })) |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | export function write( |
| 76 | name: string, |