Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

fix(desktop): repair ACP updates and add manual retry

tianma-iff4b36fc64f0e
diff --git a/apps/desktop/src/main/acp-adapter-manager.mjs b/apps/desktop/src/main/acp-adapter-manager.mjs
index 62bfec94..ff0197c4 100644
--- a/apps/desktop/src/main/acp-adapter-manager.mjs
+++ b/apps/desktop/src/main/acp-adapter-manager.mjs
@@ -15,6 +15,9 @@ const REGISTRY_URL = "https://cdn.agentclientprotocol.com/registry/v1/latest/reg
const PI_PACKAGE_URL = "https://registry.npmjs.org/pi-acp/latest";
export const MAX_ARCHIVE_BYTES = 500 * 1024 * 1024;
export const MAX_EXTRACTED_BYTES = 2 * 1024 * 1024 * 1024;
+// Official archives exceed 100 MB on macOS and 300 MB on Linux. Allow slow
+// downloads to complete while retaining a finite deadline and the size caps.
+export const ADAPTER_DOWNLOAD_TIMEOUT_MS = 10 * 60_000;
const VERSION_PATTERN = /^\d+\.\d+\.\d+$/;
const SUPPORTED_MAJOR = { codex: 2, claudeCode: 0, antigravity: 1 };
const NPM_PACKAGES = { codex: "@agentclientprotocol/codex-acp", claudeCode: "@agentclientprotocol/claude-agent-acp", piAgent: "pi-acp" };
@@ -51,7 +54,7 @@ export const managedAdapterCommand = (root, id, version, { platform = process.pl
const readRegistry = async (fetchImpl) => {
const response = await fetchImpl(REGISTRY_URL, { signal: AbortSignal.timeout(15_000), redirect: "error" });
- if (!response.ok) throw new Error("registry_unavailable");
+ if (!response.ok) throw new Error(`registry_unavailable (HTTP ${response.status})`);
const contentLength = Number(response.headers.get("content-length") || 0);
if (contentLength > 1024 * 1024) throw new Error("registry_too_large");
const raw = await response.text();
@@ -70,7 +73,8 @@ export const selectPiAdapterRelease = (entry) => {
const readPiRelease = async (fetchImpl) => {
const response = await fetchImpl(PI_PACKAGE_URL, { signal: AbortSignal.timeout(15_000), redirect: "error" });
- if (!response.ok || Number(response.headers.get("content-length") || 0) > 1024 * 1024) throw new Error("registry_unavailable");
+ if (!response.ok) throw new Error(`registry_unavailable (HTTP ${response.status})`);
+ if (Number(response.headers.get("content-length") || 0) > 1024 * 1024) throw new Error("registry_too_large");
const raw = await response.text();
if (raw.length > 1024 * 1024) throw new Error("registry_too_large");
return selectPiAdapterRelease(JSON.parse(raw));
@@ -116,8 +120,8 @@ const runNpm = (args, cwd, { executablePath = process.execPath, spawnImpl = spaw
});
const downloadArchive = async (url, destination, expectedHash, fetchImpl) => {
- const response = await fetchImpl(url, { signal: AbortSignal.timeout(120_000), redirect: "error" });
- if (!response.ok || !response.body) throw new Error("adapter_download_failed");
+ const response = await fetchImpl(url, { signal: AbortSignal.timeout(ADAPTER_DOWNLOAD_TIMEOUT_MS), redirect: "error" });
+ if (!response.ok || !response.body) throw new Error(`adapter_download_failed (HTTP ${response.status})`);
if (Number(response.headers.get("content-length") || 0) > MAX_ARCHIVE_BYTES) throw new Error("adapter_too_large");
const handle = await open(destination, "wx", 0o600);
const hash = createHash("sha256");
@@ -222,47 +226,58 @@ export function createAcpAdapterManager({ root, fetchImpl = fetch, platform = pr
if (!MANAGED_IDS.includes(id)) return Promise.reject(new Error("unknown_adapter"));
if (inFlight.has(id)) return inFlight.get(id);
const task = (async () => {
- const previous = get(id);
- if (updateOnly && !previous) return { updated: false, reason: "not_managed" };
- const release = id === "piAgent"
- ? await readPiRelease(fetchImpl)
- : selectAdapterRelease(await readRegistry(fetchImpl), id, { platform, arch });
- if (previous && compareVersions(release.version, previous.version) <= 0) return { updated: false, version: previous.version };
- const versionRoot = path.join(root, id);
- const target = path.join(versionRoot, release.version);
- const stage = path.join(versionRoot, `.stage-${release.version}-${process.pid}-${Date.now()}`);
- await mkdir(stage, { recursive: true, mode: 0o700 });
+ let updateStage = "registry";
try {
- if (release.kind === "npm") {
- await installNpmImpl(["install", "--prefix", stage, "--ignore-scripts", "--no-audit", "--no-fund", "--package-lock=false", "--registry=https://registry.npmjs.org", release.packageName], stage, { executablePath, spawnImpl, npmPath });
- } else {
- const archive = path.join(stage, "adapter.zip");
- await downloadImpl(release.archive, archive, release.sha256, fetchImpl);
- await extractImpl(archive, stage, platform);
- await rm(archive);
- if (platform !== "win32") await chmod(path.join(stage, "agy_acp_server.par"), 0o700);
+ const previous = get(id);
+ if (updateOnly && !previous) return { updated: false, reason: "not_managed" };
+ const release = id === "piAgent"
+ ? await readPiRelease(fetchImpl)
+ : selectAdapterRelease(await readRegistry(fetchImpl), id, { platform, arch });
+ if (previous && compareVersions(release.version, previous.version) <= 0) return { updated: false, version: previous.version };
+ updateStage = "install";
+ const versionRoot = path.join(root, id);
+ const target = path.join(versionRoot, release.version);
+ const stage = path.join(versionRoot, `.stage-${release.version}-${process.pid}-${Date.now()}`);
+ await mkdir(stage, { recursive: true, mode: 0o700 });
+ try {
+ if (release.kind === "npm") {
+ await installNpmImpl(["install", "--prefix", stage, "--ignore-scripts", "--no-audit", "--no-fund", "--package-lock=false", "--registry=https://registry.npmjs.org", release.packageName], stage, { executablePath, spawnImpl, npmPath });
+ } else {
+ const archive = path.join(stage, "adapter.zip");
+ updateStage = "download";
+ await downloadImpl(release.archive, archive, release.sha256, fetchImpl);
+ updateStage = "extract";
+ await extractImpl(archive, stage, platform);
+ await rm(archive);
+ if (platform !== "win32") await chmod(path.join(stage, "agy_acp_server.par"), 0o700);
+ }
+ // Inspect the staged command before making it visible to future sessions.
+ const stagedFile = release.kind === "npm"
+ ? npmEntryFile(stage, id)
+ : path.join(stage, platform === "win32" ? "agy_acp_server.exe" : "agy_acp_server.par");
+ if (!existsSync(stagedFile)) throw new Error("adapter_install_failed");
+ const stagedCommand = release.kind === "npm"
+ ? { command: executablePath, args: [stagedFile], env: { ELECTRON_RUN_AS_NODE: "1" } }
+ : { command: stagedFile, args: antigravityArgs(platform) };
+ updateStage = "validate";
+ const result = await validate(stagedCommand);
+ if (result?.state === "needs_login" && previous) {
+ const previousResult = await validate(previous.command);
+ if (previousResult?.state !== "needs_login") throw new Error("adapter_probe_failed");
+ } else if (result?.state !== "available" && !(result?.state === "needs_login" && !previous)) {
+ throw new Error(result?.detail || result?.state || "adapter_probe_failed");
+ }
+ updateStage = "activate";
+ await rm(target, { recursive: true, force: true });
+ await rename(stage, target);
+ await save(id, release.version);
+ return { updated: true, version: release.version, adapter: result };
+ } catch (error) {
+ await rm(stage, { recursive: true, force: true });
+ throw error;
}
- // Inspect the staged command before making it visible to future sessions.
- const stagedFile = release.kind === "npm"
- ? npmEntryFile(stage, id)
- : path.join(stage, platform === "win32" ? "agy_acp_server.exe" : "agy_acp_server.par");
- if (!existsSync(stagedFile)) throw new Error("adapter_install_failed");
- const stagedCommand = release.kind === "npm"
- ? { command: executablePath, args: [stagedFile], env: { ELECTRON_RUN_AS_NODE: "1" } }
- : { command: stagedFile, args: antigravityArgs(platform) };
- const result = await validate(stagedCommand);
- if (result?.state === "needs_login" && previous) {
- const previousResult = await validate(previous.command);
- if (previousResult?.state !== "needs_login") throw new Error("adapter_probe_failed");
- } else if (result?.state !== "available" && !(result?.state === "needs_login" && !previous)) {
- throw new Error(result?.detail || result?.state || "adapter_probe_failed");
- }
- await rm(target, { recursive: true, force: true });
- await rename(stage, target);
- await save(id, release.version);
- return { updated: true, version: release.version, adapter: result };
} catch (error) {
- await rm(stage, { recursive: true, force: true });
+ error.updateStage = updateStage;
throw error;
}
})();
diff --git a/apps/desktop/src/main/acp-adapter-manager.test.mjs b/apps/desktop/src/main/acp-adapter-manager.test.mjs
index c680e0df..5e217733 100644
--- a/apps/desktop/src/main/acp-adapter-manager.test.mjs
+++ b/apps/desktop/src/main/acp-adapter-manager.test.mjs
@@ -4,7 +4,7 @@ import { mkdtemp, mkdir, readFile, readdir, rm, writeFile } from "node:fs/promis
import { tmpdir } from "node:os";
import path from "node:path";
import { zipSync } from "fflate";
-import { MAX_ARCHIVE_BYTES, MAX_EXTRACTED_BYTES, createAcpAdapterManager, managedAdapterCommand, selectAdapterRelease, selectPiAdapterRelease } from "./acp-adapter-manager.mjs";
+import { ADAPTER_DOWNLOAD_TIMEOUT_MS, MAX_ARCHIVE_BYTES, MAX_EXTRACTED_BYTES, createAcpAdapterManager, managedAdapterCommand, selectAdapterRelease, selectPiAdapterRelease } from "./acp-adapter-manager.mjs";
const codexEntry = (version) => ({
id: "codex-acp",
@@ -13,6 +13,44 @@ const codexEntry = (version) => ({
});
describe("managed ACP adapters", () => {
+ test("reports the failed stage and HTTP status, retains the old binary, and retries using the supplied network transport", async () => {
+ const root = await mkdtemp(path.join(tmpdir(), "edgeever-acp-network-"));
+ const oldDir = path.join(root, "antigravity", "1.3.0");
+ await mkdir(oldDir, { recursive: true });
+ await writeFile(path.join(oldDir, "agy_acp_server.par"), "old");
+ await writeFile(path.join(root, "installed.json"), JSON.stringify({ antigravity: { version: "1.3.0" } }));
+ let failure = "registry";
+ const requests = [];
+ const archive = "https://dl.google.com/agy-extensions/releases/macos/test.zip";
+ const manager = createAcpAdapterManager({
+ root, platform: "darwin", arch: "arm64",
+ fetchImpl: async (url, init) => {
+ requests.push(url);
+ expect(init.redirect).toBe("error");
+ expect(init.signal.aborted).toBe(false);
+ if (url === archive) return failure === "download" ? new Response("", { status: 503 }) : new Response(zipSync({ "agy_acp_server.par": new TextEncoder().encode("new") }));
+ if (failure === "registry") return new Response("", { status: 502 });
+ return new Response(JSON.stringify({ agents: [{ id: "antigravity-acp", version: "1.4.0", distribution: { binary: { "darwin-aarch64": { archive, cmd: "./agy_acp_server.par" } } } }] }));
+ },
+ });
+ try {
+ for (const stage of ["registry", "download"]) {
+ failure = stage;
+ let error;
+ try { await manager.install("antigravity", async () => ({ state: "available" })); } catch (caught) { error = caught; }
+ expect(error.updateStage).toBe(stage);
+ expect(error.message).toContain(stage === "registry" ? "HTTP 502" : "HTTP 503");
+ expect(manager.get("antigravity").version).toBe("1.3.0");
+ expect(await readdir(path.join(root, "antigravity"))).toEqual(["1.3.0"]);
+ }
+ failure = null;
+ expect((await manager.install("antigravity", async () => ({ state: "available" }))).version).toBe("1.4.0");
+ expect(requests.filter((url) => url === archive)).toHaveLength(2);
+ expect(ADAPTER_DOWNLOAD_TIMEOUT_MS).toBe(600_000);
+ expect(await readFile(path.join(oldDir, "agy_acp_server.par"), "utf8")).toBe("old");
+ } finally { await rm(root, { recursive: true, force: true }); }
+ });
+
test("accepts only the expected pi ACP npm package and retains the old adapter on a failed update", async () => {
const root = await mkdtemp(path.join(tmpdir(), "edgeever-managed-pi-"));
let version = "0.0.34";
diff --git a/apps/desktop/src/main/acp-host.mjs b/apps/desktop/src/main/acp-host.mjs
index ebe22a09..c529e493 100644
--- a/apps/desktop/src/main/acp-host.mjs
+++ b/apps/desktop/src/main/acp-host.mjs
@@ -709,7 +709,7 @@ export function createAcpHostRuntime(options = {}) {
const handshakeTimeoutMs = options.handshakeTimeoutMs ?? HANDSHAKE_TIMEOUT_MS;
const authenticationTimeoutMs = options.authenticationTimeoutMs ?? 5 * 60_000;
const commandDeps = options;
- const manager = options.adapterManager ?? (options.adapterStore ? createAcpAdapterManager({ root: options.adapterStore, executablePath: options.executablePath }) : null);
+ const manager = options.adapterManager ?? (options.adapterStore ? createAcpAdapterManager({ root: options.adapterStore, executablePath: options.executablePath, fetchImpl: options.adapterFetchImpl }) : null);
const active = new Map();
const updateFailures = new Map();
const installingIds = new Set();
@@ -876,11 +876,11 @@ export function createAcpHostRuntime(options = {}) {
clearAdapterStatus(id) { latestStatus.delete(id); },
listAdapters(configuredPaths = {}) {
return ["codex", "claudeCode", "antigravity", "openClaw", "hermesAgent", "grokBuild", "deepseekHarness", "piAgent", "workbuddyCn", "workbuddyIntl"].map((id) => {
- if (installingIds.has(id)) return { ...adapterShell(id), state: "installing" };
+ if (installingIds.has(id)) return { ...adapterShell(id), state: "installing", ...(manager?.get(id) ? { managed: true, version: manager.get(id).version } : {}), ...(updateFailures.has(id) ? { updateError: updateFailures.get(id) } : {}) };
const customPath = configuredPaths[id];
const resolved = resolveCommand({ id, path: customPath }, { prepareProxy: false });
return resolved.ok
- ? { ...adapterShell(id), ...(latestStatus.get(id) ?? { state: "not_probed", detail: "not_probed" }), ...(resolved.version ? { version: resolved.version, managed: true } : {}), ...(customPath ? { customPath, managed: false, version: undefined } : {}), ...(updateFailures.has(id) ? { updateError: updateFailures.get(id) } : {}) }
+ ? { ...adapterShell(id), ...(latestStatus.get(id) ?? { state: "not_probed", detail: "not_probed" }), ...(resolved.version ? { version: resolved.version, managed: true } : {}), ...(customPath ? { customPath, managed: false, version: undefined } : {}), ...(!customPath && updateFailures.has(id) ? { updateError: updateFailures.get(id) } : {}) }
: adapterFromResolution(id, resolved);
});
},
@@ -907,7 +907,13 @@ export function createAcpHostRuntime(options = {}) {
}
}, { updateOnly });
if (result.adapter) latestStatus.set(id, result.adapter);
+ updateFailures.delete(id);
return result;
+ } catch (error) {
+ const reason = sanitizeFailureDetail(`${error.updateStage ? `${error.updateStage}: ` : ""}${error.message ?? error}${error.cause?.code ? ` (${error.cause.code})` : ""}`);
+ updateFailures.set(id, reason);
+ try { options.onUpdateDiagnostic?.({ id, reason }); } catch { /* diagnostics are optional */ }
+ throw new Error(reason);
} finally {
installingIds.delete(id);
}
@@ -935,11 +941,9 @@ export function createAcpHostRuntime(options = {}) {
if (id === "piAgent" && !localExecutable("pi", resolutionDeps(commandDeps))) continue;
try {
const result = await this.installAdapter(id, { updateOnly: true });
- updateFailures.delete(id);
results.push({ id, ...result });
} catch (error) {
const reason = sanitizeFailureDetail(error);
- updateFailures.set(id, reason);
results.push({ id, updated: false, reason });
}
}
diff --git a/apps/desktop/src/main/acp-host.test.mjs b/apps/desktop/src/main/acp-host.test.mjs
index 877b5a00..d66297fe 100644
--- a/apps/desktop/src/main/acp-host.test.mjs
+++ b/apps/desktop/src/main/acp-host.test.mjs
@@ -368,6 +368,30 @@ describe("ACP command allow-list", () => {
}
});
+ test("records sanitized update failures and clears them after a manual retry including no-op success", async () => {
+ let fail = true;
+ const diagnostics = [];
+ const runtime = createAcpHostRuntime({
+ onUpdateDiagnostic: (event) => diagnostics.push(event),
+ adapterManager: {
+ get: (id) => id === "antigravity" ? { version: "1.3.0", command: { command: "/tmp/agy", args: [] } } : null,
+ installedIds: () => ["antigravity"],
+ install: async () => {
+ if (fail) throw Object.assign(new Error("fetch failed https://example.com/?token=private"), { updateStage: "download", cause: { code: "ETIMEDOUT" } });
+ return { updated: false, version: "1.3.0" };
+ },
+ },
+ });
+ const [result] = await runtime.updateInstalled();
+ expect(result.reason).toBe("download: fetch failed [url] (ETIMEDOUT)");
+ expect(runtime.listAdapters().find((item) => item.id === "antigravity").updateError).toBe(result.reason);
+ expect(diagnostics).toEqual([{ id: "antigravity", reason: result.reason }]);
+ await expect(runtime.installAdapter("antigravity")).rejects.toThrow(result.reason);
+ fail = false;
+ expect(await runtime.installAdapter("antigravity")).toEqual({ updated: false, version: "1.3.0" });
+ expect(runtime.listAdapters().find((item) => item.id === "antigravity").updateError).toBeUndefined();
+ });
+
test("automatically installs only a detected agent missing its ACP connector", async () => {
let installed = false;
let installs = 0;
diff --git a/apps/desktop/src/main/index.mjs b/apps/desktop/src/main/index.mjs
index ae39a237..1437d2bc 100644
--- a/apps/desktop/src/main/index.mjs
+++ b/apps/desktop/src/main/index.mjs
@@ -1832,6 +1832,8 @@ const startApplication = async () => {
});
const acpRuntime = registerAcpIpc(ipcMain, createAcpHostRuntime({
adapterStore: join(app.getPath("userData"), "acp-adapters"),
+ adapterFetchImpl: (url, init) => net.fetch(url, { ...init, credentials: "omit" }),
+ onUpdateDiagnostic: (details) => { void writeDiagnostic("acp.adapter-update-failed", details); },
onDiagnostic: (details) => { void writeDiagnostic("acp.adapter-stderr", details); },
onProcessDiagnostic: ({ event, ...details }) => { void writeDiagnostic(`acp.adapter-${event}`, details); },
mcpScriptPath: app.isPackaged
diff --git a/apps/web/src/components/settings/DesktopAcpAgentCard.tsx b/apps/web/src/components/settings/DesktopAcpAgentCard.tsx
index f45cb89a..2ef49111 100644
--- a/apps/web/src/components/settings/DesktopAcpAgentCard.tsx
+++ b/apps/web/src/components/settings/DesktopAcpAgentCard.tsx
@@ -12,6 +12,7 @@ import {
AI_SIDEBAR_SOURCE_KEY,
AI_SIDEBAR_SELECTION_EVENT,
displayedDesktopAcpAdapter,
+ desktopAcpUpdateErrorHintKey,
desktopAcpLoginRetryAvailable,
listDesktopAcpAdapters,
installDesktopAcpAdapter,
@@ -144,6 +145,7 @@ const DesktopAcpAgentCardBody = ({ bridge }: { bridge: boolean }) => {
}, []);
const shown = displayedDesktopAcpAdapter({ id: adapterId, path: adapterPath, listed, probed });
+ const updateHintKey = shown?.updateError ? desktopAcpUpdateErrorHintKey(shown.updateError) : null;
const isWorkBuddy = adapterId === "workbuddyCn" || adapterId === "workbuddyIntl";
const status = t(statusKey(shown, probing));
const tone = getStatusTone({
@@ -185,22 +187,22 @@ const DesktopAcpAgentCardBody = ({ bridge }: { bridge: boolean }) => {
setInstallError(false);
};
- const install = async () => {
+ const install = async (retryUpdate = false) => {
if (adapterId !== "codex" && adapterId !== "claudeCode" && adapterId !== "antigravity" && adapterId !== "piAgent") return;
setInstalling(true);
setInstallError(false);
try {
const result = await installDesktopAcpAdapter(adapterId);
- if (result.updated) {
- if (adapterId === "antigravity") setAdapterPath("");
- setListed(await listDesktopAcpAdapters());
- if (result.adapter) setProbed({ ...result.adapter, version: result.version, managed: true });
+ if (result.updated || result.version) {
+ if (adapterId === "antigravity" && result.updated) setAdapterPath("");
+ setProbed(result.adapter ? { ...result.adapter, version: result.version, managed: true } : null);
} else {
setInstallError(true);
}
} catch {
- setInstallError(true);
+ if (!retryUpdate) setInstallError(true);
} finally {
+ setListed(await listDesktopAcpAdapters().catch(() => listed));
setInstalling(false);
}
};
@@ -450,7 +452,14 @@ const DesktopAcpAgentCardBody = ({ bridge }: { bridge: boolean }) => {
<p>{t("aiAssistant.agentSource.hermesAgentSetupHint")}</p>
) : null}
{shown?.updateError ? (
- <p className="text-xs text-amber-700" role="status">{t("aiAssistant.agentSource.updateFailed")}</p>
+ <div className="space-y-2 text-xs text-amber-700" role="status">
+ <p>{t("aiAssistant.agentSource.updateFailed")}</p>
+ {updateHintKey ? <p>{t(updateHintKey)}</p> : null}
+ <p className="break-words">{t("aiAssistant.agentSource.updateFailureReason", { reason: shown.updateError })}</p>
+ <Button type="button" variant="outline" size="sm" className="h-8 bg-card text-xs font-normal" disabled={installing || probing || shown.state === "installing" || Boolean(authenticating)} onClick={() => void install(true)}>
+ {installing || shown.state === "installing" ? t("aiAssistant.agentSource.updating") : t("aiAssistant.agentSource.retryUpdate")}
+ </Button>
+ </div>
) : null}
</div>
) : null}
diff --git a/apps/web/src/lib/desktop-acp.test.mjs b/apps/web/src/lib/desktop-acp.test.mjs
index 2a1351ba..4e6e266c 100644
--- a/apps/web/src/lib/desktop-acp.test.mjs
+++ b/apps/web/src/lib/desktop-acp.test.mjs
@@ -1,5 +1,5 @@
import { expect, test } from "bun:test";
-import { desktopAcpLoginRetryAvailable, desktopAcpNoteAccessErrorKey, aiSidebarAdapterFromStorage, aiSidebarSourceFromStorage, displayedDesktopAcpAdapter } from "./desktop-acp.ts";
+import { desktopAcpUpdateErrorHintKey, desktopAcpLoginRetryAvailable, desktopAcpNoteAccessErrorKey, aiSidebarAdapterFromStorage, aiSidebarSourceFromStorage, displayedDesktopAcpAdapter } from "./desktop-acp.ts";
test("a checked custom Antigravity executable takes priority over the managed connector status", () => {
const managed = { id: "antigravity", label: "Antigravity", state: "failed", version: "1.2.1", managed: true };
@@ -156,3 +156,18 @@ test("WorkBuddy connection failures keep an edition-specific sign-in recovery pa
expect(desktopAcpLoginRetryAvailable(undefined)).toBe(false);
expect(desktopAcpLoginRetryAvailable({ id: "codex", state: "failed", authMethods: [{ id: "browser" }] })).toBe(false);
});
+
+test("settings preserves the latest update failure alongside an earlier successful connection probe", () => {
+ const probed = { id: "antigravity", state: "available", version: "1.3.0", managed: true };
+ const current = { ...probed, updateError: "download: timeout" };
+ const input = { id: "antigravity", path: "", listed: [current], probed };
+ expect(displayedDesktopAcpAdapter(input).updateError).toBe("download: timeout");
+ expect(displayedDesktopAcpAdapter({ ...input, listed: [{ ...probed }] }).updateError).toBeUndefined();
+});
+
+test("update errors offer a network remedy while keeping unrelated failures distinct", () => {
+ expect(desktopAcpUpdateErrorHintKey("download: The operation was aborted due to timeout")).toBe("aiAssistant.agentSource.updateTimeoutHint");
+ expect(desktopAcpUpdateErrorHintKey("download: fetch failed (ETIMEDOUT)")).toBe("aiAssistant.agentSource.updateTimeoutHint");
+ expect(desktopAcpUpdateErrorHintKey("registry: fetch failed (ENOTFOUND)")).toBe("aiAssistant.agentSource.updateNetworkHint");
+ expect(desktopAcpUpdateErrorHintKey("extract: invalid_adapter_archive")).toBeNull();
+});
diff --git a/apps/web/src/lib/desktop-acp.ts b/apps/web/src/lib/desktop-acp.ts
index 1ef5f6f1..7b2e65d5 100644
--- a/apps/web/src/lib/desktop-acp.ts
+++ b/apps/web/src/lib/desktop-acp.ts
@@ -19,6 +19,12 @@ export type DesktopAcpAdapter = {
authMethods?: Array<{ id: string; name: string }>;
};
+export const desktopAcpUpdateErrorHintKey = (reason: string) => {
+ if (/timeout|timed.?out/i.test(reason)) return "aiAssistant.agentSource.updateTimeoutHint";
+ if (/fetch failed|ERR_(?:NETWORK|PROXY|CONNECTION)|ECONN|ENOTFOUND|EAI_AGAIN/i.test(reason)) return "aiAssistant.agentSource.updateNetworkHint";
+ return null;
+};
+
// Offer only login methods advertised by the agent. Unreadable saved tokens
// require a different remedy and must not invite a futile sign-in loop.
export const desktopAcpLoginRetryAvailable = (adapter: DesktopAcpAdapter | undefined) => Boolean(
@@ -47,7 +53,7 @@ export const displayedDesktopAcpAdapter = ({
if (current?.customPath) return checked;
if (current?.state === "installing" || (current?.managed && (!checked?.managed || current.version !== checked.version))) return current;
if (checked?.state === "available" && (current?.state === "needs_login" || current?.state === "failed" || current?.state === "not_installed")) return current;
- return checked ?? current;
+ return checked && current ? { ...checked, updateError: current.updateError } : checked ?? current;
};
export const desktopAcpSelectorVisible = (adapter: DesktopAcpAdapter, customPath: string) => (
diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.ts
index fdcfd868..e924533b 100644
--- a/packages/shared/src/i18n/en-US.ts
+++ b/packages/shared/src/i18n/en-US.ts
@@ -1776,6 +1776,11 @@ export const enUS = {
installing: "Installing and checking…",
installFailed: "Installation or connection check failed. The previous version was kept.",
updateFailed: "Automatic update failed. The previous version remains in use.",
+ updateFailureReason: "Reason: {{reason}}",
+ updateTimeoutHint: "The download or connection timed out. Check your network and retry.",
+ updateNetworkHint: "Could not reach the update service. Check your network and system proxy, then retry.",
+ retryUpdate: "Retry update",
+ updating: "Updating…",
authenticating: "Signing in…",
authenticationTimedOut: "Sign-in did not complete. Please try again.",
authenticationFailed: "Sign-in failed or was cancelled. Try again.",
diff --git a/packages/shared/src/i18n/ja.ts b/packages/shared/src/i18n/ja.ts
index b63a8fc4..76668dd3 100644
--- a/packages/shared/src/i18n/ja.ts
+++ b/packages/shared/src/i18n/ja.ts
@@ -1765,6 +1765,11 @@ export const ja = {
installing: "インストールして確認中…",
installFailed: "インストールまたは接続確認に失敗しました。以前のバージョンは保持されています。",
updateFailed: "自動更新に失敗しました。以前のバージョンを継続して使用します。",
+ updateFailureReason: "失敗の理由:{{reason}}",
+ updateTimeoutHint: "ダウンロードまたは接続がタイムアウトしました。ネットワークを確認して再試行してください。",
+ updateNetworkHint: "更新サービスに接続できません。ネットワークとシステムプロキシを確認して再試行してください。",
+ retryUpdate: "更新を再試行",
+ updating: "更新中…",
authenticating: "ログイン中…",
authenticationTimedOut: "ログインが完了しませんでした。再試行してください。",
authenticationFailed: "ログインに失敗したか、キャンセルされました。再試行してください。",
diff --git a/packages/shared/src/i18n/pl.ts b/packages/shared/src/i18n/pl.ts
index b90cdbc7..9fdbc287 100644
--- a/packages/shared/src/i18n/pl.ts
+++ b/packages/shared/src/i18n/pl.ts
@@ -1765,6 +1765,11 @@ export const pl = {
installing: "Instalowanie i sprawdzanie…",
installFailed: "Instalacja lub sprawdzenie połączenia nie powiodło się. Zachowano poprzednią wersję.",
updateFailed: "Automatyczna aktualizacja nie powiodła się. Nadal używana jest poprzednia wersja.",
+ updateFailureReason: "Przyczyna: {{reason}}",
+ updateTimeoutHint: "Pobieranie lub połączenie przekroczyło limit czasu. Sprawdź sieć i spróbuj ponownie.",
+ updateNetworkHint: "Nie można połączyć się z usługą aktualizacji. Sprawdź sieć i systemowe ustawienia proxy, a następnie ponów próbę.",
+ retryUpdate: "Ponów aktualizację",
+ updating: "Aktualizowanie…",
authenticating: "Logowanie…",
authenticationTimedOut: "Logowanie nie zostało ukończone. Spróbuj ponownie.",
authenticationFailed: "Logowanie nie powiodło się lub zostało anulowane. Spróbuj ponownie.",
diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.ts
index 75f28023..25092148 100644
--- a/packages/shared/src/i18n/zh-CN.ts
+++ b/packages/shared/src/i18n/zh-CN.ts
@@ -1776,6 +1776,11 @@ export const zhCN = {
installing: "正在安装并检查…",
installFailed: "安装或连接检查失败,原版本已保留。",
updateFailed: "自动更新失败,正在继续使用原版本。",
+ updateFailureReason: "失败原因:{{reason}}",
+ updateTimeoutHint: "下载或连接超时,请检查网络后重试。",
+ updateNetworkHint: "无法连接更新服务,请检查网络和系统代理后重试。",
+ retryUpdate: "重试更新",
+ updating: "正在更新…",
authenticating: "正在登录…",
authenticationTimedOut: "登录未完成,请重试",
authenticationFailed: "登录失败或已取消,请重试",