Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(desktop): use Electron proxy for daemon startup requests (MUL-9716) (#11058)
Danila Katalshovf62322c2fd0a
diff --git a/apps/desktop/src/main/cli-bootstrap.ts b/apps/desktop/src/main/cli-bootstrap.tsindex 8ed2dcda12..bfad4cf8a8 100644--- a/apps/desktop/src/main/cli-bootstrap.ts+++ b/apps/desktop/src/main/cli-bootstrap.ts@@ -1,4 +1,4 @@-import { app } from "electron";+import { app, net } from "electron";import { execFile } from "child_process";import { createHash } from "crypto";import { createReadStream, createWriteStream, existsSync } from "fs";@@ -32,12 +32,12 @@ function run(cmd: string, args: string[], cwd?: string): Promise<void> {}async function downloadToFile(url: string, dest: string): Promise<void> {- const res = await fetch(url, { redirect: "follow" });+ const res = await net.fetch(url, { redirect: "follow" });if (!res.ok || !res.body) {throw new Error(`download failed: ${res.status} ${res.statusText}`);}await mkdir(dirname(dest), { recursive: true });- // Node's fetch returns a web ReadableStream; adapt to a Node stream for pipeline.+ // Electron's net.fetch returns a web ReadableStream; adapt to a Node stream for pipeline.const nodeStream = Readable.fromWeb(res.body as Parameters<typeof Readable.fromWeb>[0]);await pipeline(nodeStream, createWriteStream(dest));}@@ -46,7 +46,7 @@ async function downloadToFile(url: string, dest: string): Promise<void> {// filename → sha256 lookup. Format is `<hex> <filename>` per line.async function fetchChecksums(): Promise<Map<string, string>> {const url = `${GITHUB_LATEST_BASE}/checksums.txt`;- const res = await fetch(url, { redirect: "follow" });+ const res = await net.fetch(url, { redirect: "follow" });if (!res.ok) {throw new Error(`checksums.txt fetch failed: ${res.status} ${res.statusText}`,diff --git a/apps/desktop/src/main/daemon-manager.ts b/apps/desktop/src/main/daemon-manager.tsindex 25c1aa9d68..f5fea4106e 100644--- a/apps/desktop/src/main/daemon-manager.ts+++ b/apps/desktop/src/main/daemon-manager.ts@@ -1,4 +1,4 @@-import { app, ipcMain, BrowserWindow, shell, dialog, type MessageBoxOptions } from "electron";+import { app, ipcMain, BrowserWindow, shell, dialog, net, type MessageBoxOptions } from "electron";import { execFile } from "child_process";import {readFile,@@ -272,7 +272,7 @@ async function probeTokenValidity(profile: string): Promise<AuthProbeResult> {try {const controller = new AbortController();const timeout = setTimeout(() => controller.abort(), 4_000);- const res = await fetch(`${targetApiBaseUrl.replace(/\/+$/, "")}/api/me`, {+ const res = await net.fetch(`${targetApiBaseUrl.replace(/\/+$/, "")}/api/me`, {headers: { Authorization: `Bearer ${token}` },signal: controller.signal,});@@ -713,7 +713,7 @@ async function mintPat(jwt: string): Promise<string> {throw new Error("mint PAT: target API URL not set");}const url = `${targetApiBaseUrl.replace(/\/+$/, "")}/api/tokens`;- const res = await fetch(url, {+ const res = await net.fetch(url, {method: "POST",headers: {"Content-Type": "application/json",