This commit is contained in:
ZacharyZhang-NY committed 2026-04-04 12:03:50 -04:00
1 parent 66158e222e
commit 67c757f481
314 files changed
+37945 -22962

No files matched your search

+30 -5
View File
@@ -1,3 +1,4 @@
import { app } from "electron";
import electronUpdater from "electron-updater";
import type { AppDatabase } from "./database";
import type { NotificationOptions } from "./notification-service";
@@ -18,14 +19,37 @@ export function createUpdaterService({
logger,
notify,
}: UpdaterServiceDependencies) {
let listenersAttached = false;
function attachListeners() {
if (listenersAttached) {
return;
}
listenersAttached = true;
autoUpdater.on("checking-for-update", () => {
logger.info("[updater] checking for updates");
});
autoUpdater.on("update-available", (info) => {
logger.info("[updater] update available", info.version);
notify({
title: "Update Available",
body: `Version ${info.version} is ready to install`,
body: `Version ${info.version} is downloading in the background`,
urgency: "informational",
navigation: { section: "settings" },
});
});
autoUpdater.on("download-progress", (progress) => {
logger.info("[updater] download progress", {
percent: progress.percent,
transferred: progress.transferred,
total: progress.total,
});
});
autoUpdater.on("update-downloaded", (info) => {
logger.info("[updater] update downloaded", info.version);
notify({
title: "Update Ready",
body: `Version ${info.version} will install when AgentCompany quits`,
urgency: "informational",
navigation: { section: "settings" },
});
@@ -55,15 +79,16 @@ export function createUpdaterService({
return false;
}
const updateUrl = process.env.AGENTCOMPANY_UPDATE_URL?.trim();
if (!updateUrl || updateUrl.includes("example.invalid")) {
if (!app.isPackaged && (!updateUrl || updateUrl.includes("example.invalid"))) {
logger.info("[updater] Skipping update check because no real update URL is configured.");
return false;
}
try {
autoUpdater.logger = logger as any;
autoUpdater.autoDownload = false;
await autoUpdater.checkForUpdates();
return true;
autoUpdater.autoDownload = true;
autoUpdater.autoInstallOnAppQuit = true;
const result = await autoUpdater.checkForUpdates();
return Boolean(result?.updateInfo);
} catch (error) {
logger.error(error);
return false;