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): make downloaded updates actionable

tianma-if0fe66082b355
diff --git a/apps/desktop/src/main/desktop-update-flow.test.mjs b/apps/desktop/src/main/desktop-update-flow.test.mjs
index 1b4718c5..fea5dd6e 100644
--- a/apps/desktop/src/main/desktop-update-flow.test.mjs
+++ b/apps/desktop/src/main/desktop-update-flow.test.mjs
@@ -5,6 +5,7 @@ const mainSource = readFileSync(new URL("./index.mjs", import.meta.url), "utf8")
const preloadSource = readFileSync(new URL("../preload/index.cjs", import.meta.url), "utf8");
const noticeSource = readFileSync(new URL("../../../web/src/components/DesktopUpdateNotice.tsx", import.meta.url), "utf8");
const systemInfoSource = readFileSync(new URL("../../../web/src/components/settings/SystemInfoPanel.tsx", import.meta.url), "utf8");
+const notebookPaneSource = readFileSync(new URL("../../../web/src/components/NotebookPane.tsx", import.meta.url), "utf8");
describe("desktop update flow", () => {
test("downloads updates in the background and relaunches after installation", () => {
@@ -38,4 +39,15 @@ describe("desktop update flow", () => {
expect(noticeSource).toContain('t("systemInfo.desktopUpdateRestart")');
expect(noticeSource).not.toContain("downloadUpdate()");
});
+
+ test("pushes update status and shows a native restart prompt after download", () => {
+ expect(mainSource).toContain('mainWindow.webContents.send("desktop:update-status-changed"');
+ expect(mainSource).toContain("promptForDownloadedUpdate(downloadedUpdateVersion)");
+ expect(mainSource).toContain('title: isChinese ? "EdgeEver 更新已就绪" : "EdgeEver update ready"');
+ expect(preloadSource).toContain('ipcRenderer.on("desktop:update-status-changed"');
+ expect(noticeSource).toContain("bridge.onUpdateStatus");
+ expect(noticeSource).toContain('role="alert"');
+ expect(notebookPaneSource).toContain("<DesktopUpdateNotice />");
+ expect(notebookPaneSource).toContain('className="flex items-center gap-1"');
+ });
});
diff --git a/apps/desktop/src/main/index.mjs b/apps/desktop/src/main/index.mjs
index 630cba38..82b25e42 100644
--- a/apps/desktop/src/main/index.mjs
+++ b/apps/desktop/src/main/index.mjs
@@ -80,6 +80,8 @@ let updateCheckInFlight = null;
let updateDownloadInFlight = null;
let updateCheckTimer = null;
let lastUpdateCheckAt = 0;
+let downloadedUpdateVersion = null;
+let promptedUpdateVersion = null;
let sidecarScopeKey = "anonymous";
let activeAccountId = null;
let shutdownCleanupStarted = false;
@@ -505,6 +507,16 @@ const refreshTrayMenu = () => {
createTray();
};
+const desktopUpdateStatus = () => ({
+ state: updateState,
+ version: downloadedUpdateVersion,
+});
+
+const publishDesktopUpdateStatus = () => {
+ if (!mainWindow || mainWindow.isDestroyed()) return;
+ mainWindow.webContents.send("desktop:update-status-changed", desktopUpdateStatus());
+};
+
const installDownloadedUpdate = () => {
if (updateState !== "downloaded") return { started: false };
// The normal window close handler hides the app. Mark this as a real quit
@@ -514,6 +526,34 @@ const installDownloadedUpdate = () => {
return { started: true };
};
+const promptForDownloadedUpdate = async (version) => {
+ const promptKey = version || "unknown";
+ if (isQuitting || promptedUpdateVersion === promptKey) return;
+ promptedUpdateVersion = promptKey;
+ showWindow(mainWindow);
+ const isChinese = app.getLocale().toLowerCase().startsWith("zh");
+ const result = await dialog.showMessageBox(mainWindow, {
+ type: "info",
+ title: isChinese ? "EdgeEver 更新已就绪" : "EdgeEver update ready",
+ message: isChinese
+ ? `EdgeEver v${version || "最新版"} 已下载完成。`
+ : `EdgeEver v${version || "latest"} has been downloaded.`,
+ detail: isChinese
+ ? "现在重启即可完成安装。也可以选择稍后,EdgeEver 会在您退出应用时自动安装。"
+ : "Restart now to finish installing it. You can also choose Later; EdgeEver will install it automatically when you quit the app.",
+ buttons: [isChinese ? "重启以更新" : "Restart to Update", isChinese ? "稍后" : "Later"],
+ defaultId: 0,
+ cancelId: 1,
+ noLink: true,
+ });
+ if (result.response === 0) {
+ void writeDiagnostic("update.install-confirmed", { version });
+ installDownloadedUpdate();
+ } else {
+ void writeDiagnostic("update.install-deferred", { version });
+ }
+};
+
const checkForDesktopUpdate = (reason, { force = false, throwOnError = false } = {}) => {
if (!app.isPackaged || process.env.EDGE_EVER_DISABLE_AUTO_UPDATE === "1" || updateState === "downloaded") {
return Promise.resolve(null);
@@ -552,14 +592,40 @@ const configureAutoUpdater = () => {
autoUpdater.autoDownload = true;
autoUpdater.autoInstallOnAppQuit = true;
autoUpdater.autoRunAppAfterInstall = true;
- autoUpdater.on("update-available", () => { updateState = "available"; refreshTrayMenu(); void writeDiagnostic("update.available"); });
- autoUpdater.on("update-not-available", () => { updateState = "idle"; refreshTrayMenu(); void writeDiagnostic("update.not-available"); });
+ autoUpdater.on("update-available", (info) => {
+ updateState = "available";
+ downloadedUpdateVersion = info?.version || null;
+ refreshTrayMenu();
+ publishDesktopUpdateStatus();
+ void writeDiagnostic("update.available", { version: info?.version });
+ });
+ autoUpdater.on("update-not-available", () => {
+ updateState = "idle";
+ downloadedUpdateVersion = null;
+ refreshTrayMenu();
+ publishDesktopUpdateStatus();
+ void writeDiagnostic("update.not-available");
+ });
autoUpdater.on("download-progress", (progress) => { void writeDiagnostic("update.download-progress", { percent: progress.percent }); });
- autoUpdater.on("update-downloaded", () => { updateState = "downloaded"; refreshTrayMenu(); void writeDiagnostic("update.downloaded"); });
+ autoUpdater.on("update-downloaded", (info) => {
+ updateState = "downloaded";
+ downloadedUpdateVersion = info?.version || downloadedUpdateVersion;
+ refreshTrayMenu();
+ publishDesktopUpdateStatus();
+ void writeDiagnostic("update.downloaded", { version: downloadedUpdateVersion });
+ void promptForDownloadedUpdate(downloadedUpdateVersion).catch((error) => {
+ promptedUpdateVersion = null;
+ void writeDiagnostic("update.prompt-failed", { message: error.message });
+ });
+ });
autoUpdater.on("error", (error) => {
isQuitting = false;
- if (updateState !== "downloaded") updateState = "idle";
+ if (updateState !== "downloaded") {
+ updateState = "idle";
+ downloadedUpdateVersion = null;
+ }
refreshTrayMenu();
+ publishDesktopUpdateStatus();
void writeDiagnostic("update.error", { message: error.message });
});
void checkForDesktopUpdate("startup", { force: true });
@@ -955,10 +1021,10 @@ app.whenReady().then(async () => {
}
return configuredApiBaseUrl;
});
- ipcMain.handle("desktop:update-status", () => ({ state: updateState }));
+ ipcMain.handle("desktop:update-status", () => desktopUpdateStatus());
ipcMain.handle("desktop:check-update", async () => {
await checkForDesktopUpdate("manual", { force: true, throwOnError: true });
- return { state: updateState };
+ return desktopUpdateStatus();
});
ipcMain.handle("desktop:download-update", () => autoUpdater.downloadUpdate());
ipcMain.handle("desktop:install-update", () => installDownloadedUpdate());
diff --git a/apps/desktop/src/preload/index.cjs b/apps/desktop/src/preload/index.cjs
index ce6fe8d4..a05a7dc6 100644
--- a/apps/desktop/src/preload/index.cjs
+++ b/apps/desktop/src/preload/index.cjs
@@ -19,6 +19,11 @@ contextBridge.exposeInMainWorld("edgeeverDesktop", Object.freeze({
checkUpdate: () => ipcRenderer.invoke("desktop:check-update"),
downloadUpdate: () => ipcRenderer.invoke("desktop:download-update"),
installUpdate: () => ipcRenderer.invoke("desktop:install-update"),
+ onUpdateStatus: (callback) => {
+ const listener = (_event, status) => callback(status);
+ ipcRenderer.on("desktop:update-status-changed", listener);
+ return () => ipcRenderer.removeListener("desktop:update-status-changed", listener);
+ },
sidecarRequest: (method, params = {}) => ipcRenderer.invoke("desktop:sidecar-request", method, params),
stageResource: (input) => ipcRenderer.invoke("desktop:stage-resource", input),
listStagedResources: () => ipcRenderer.invoke("desktop:list-staged-resources"),
diff --git a/apps/web/src/app/App.tsx b/apps/web/src/app/App.tsx
index 9fbe24d8..37c3a552 100644
--- a/apps/web/src/app/App.tsx
+++ b/apps/web/src/app/App.tsx
@@ -5,7 +5,6 @@ import { useTranslation } from "react-i18next";
import { PwaUpdateNotice } from "@/components/PwaUpdateNotice";
import { PwaInstallProvider } from "@/components/PwaInstallContext";
import { PwaIosPrompt } from "@/components/PwaIosPrompt";
-import { DesktopUpdateNotice } from "@/components/DesktopUpdateNotice";
import { Button } from "@/components/ui/button";
import {
api,
@@ -230,7 +229,6 @@ export const App = () => {
<Route path="/ai-prompts" element={<AuthenticatedWorkspace />} />
<Route path="*" element={<Navigate to="/" replace />} />
</Routes>
- <DesktopUpdateNotice />
<PwaUpdateNotice />
<PwaIosPrompt />
</PwaInstallProvider>
diff --git a/apps/web/src/components/DesktopUpdateNotice.tsx b/apps/web/src/components/DesktopUpdateNotice.tsx
index 528e577f..f4738b0f 100644
--- a/apps/web/src/components/DesktopUpdateNotice.tsx
+++ b/apps/web/src/components/DesktopUpdateNotice.tsx
@@ -1,8 +1,8 @@
+import { useEffect } from "react";
import { useMutation, useQuery } from "@tanstack/react-query";
-import { LoaderCircle, RotateCcw } from "lucide-react";
+import { ArrowRight, LoaderCircle } from "lucide-react";
import { useTranslation } from "react-i18next";
import { Button } from "@/components/ui/button";
-import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
export const DesktopUpdateNotice = () => {
const { t } = useTranslation();
@@ -19,6 +19,14 @@ export const DesktopUpdateNotice = () => {
mutationFn: () => bridge!.installUpdate(),
});
+ useEffect(() => {
+ if (!bridge?.onUpdateStatus) return;
+ return bridge.onUpdateStatus((status) => {
+ void statusQuery.refetch();
+ if (status.state === "downloaded") window.focus();
+ });
+ }, [bridge, statusQuery.refetch]);
+
const downloaded = bridge?.isAvailable === true && statusQuery.data?.state === "downloaded";
if (!downloaded) return null;
@@ -27,27 +35,21 @@ export const DesktopUpdateNotice = () => {
: t("systemInfo.desktopUpdateRestart");
return (
- <div className="fixed right-5 top-5 z-[90] animate-in slide-in-from-top-3 fade-in duration-300" role="status" aria-live="polite">
- <TooltipProvider>
- <Tooltip>
- <TooltipTrigger asChild>
- <Button
- className="relative h-10 w-10 rounded-full shadow-[0_12px_32px_rgba(15,23,42,0.2)]"
- size="icon"
- variant="solid"
- aria-label={label}
- disabled={installMutation.isPending}
- onClick={() => installMutation.mutate()}
- >
- {installMutation.isPending
- ? <LoaderCircle className="h-4 w-4 animate-spin" />
- : <RotateCcw className="h-4 w-4" />}
- <span className="absolute right-0 top-0 h-2.5 w-2.5 rounded-full border-2 border-white bg-amber-400" aria-hidden="true" />
- </Button>
- </TooltipTrigger>
- <TooltipContent side="left">{label}</TooltipContent>
- </Tooltip>
- </TooltipProvider>
- </div>
+ <Button
+ className="h-8 shrink-0 animate-in rounded-full bg-emerald-600 px-4 text-xs font-semibold text-white shadow-sm fade-in slide-in-from-left-2 hover:bg-emerald-700 hover:text-white"
+ size="sm"
+ variant="solid"
+ role="alert"
+ aria-live="assertive"
+ aria-label={statusQuery.data?.version ? `${label} v${statusQuery.data.version}` : label}
+ disabled={installMutation.isPending}
+ onClick={() => installMutation.mutate()}
+ >
+ {installMutation.isPending
+ ? <LoaderCircle className="h-3.5 w-3.5 animate-spin" />
+ : null}
+ {label}
+ {!installMutation.isPending ? <ArrowRight className="h-3.5 w-3.5" aria-hidden="true" /> : null}
+ </Button>
);
};
diff --git a/apps/web/src/components/NotebookPane.tsx b/apps/web/src/components/NotebookPane.tsx
index a5008ac3..ef06aea4 100644
--- a/apps/web/src/components/NotebookPane.tsx
+++ b/apps/web/src/components/NotebookPane.tsx
@@ -54,6 +54,7 @@ import {
} from "@/lib/app-helpers";
import type { EdgeEverRepository } from "@/lib/repository";
import { statusSettleMotion } from "@/lib/motion";
+import { DesktopUpdateNotice } from "./DesktopUpdateNotice";
const NOTEBOOK_DRAG_SCROLL_EDGE_PX = 56;
const NOTEBOOK_DRAG_SCROLL_MAX_STEP_PX = 18;
@@ -817,17 +818,20 @@ export const NotebookPane = ({
</DropdownMenuGroup>
</DropdownMenuContent>
</DropdownMenu>
- <button
- onClick={onOpenSettings}
- className="flex h-8 w-full items-center gap-3 rounded-md px-3 text-left text-sm font-medium leading-none text-slate-700 transition-colors duration-200 hover:bg-slate-50 hover:text-slate-950 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-400/70"
- type="button"
- aria-label={t("notebookPane.profile")}
- >
- <span className="flex h-4 w-4 shrink-0 items-center justify-center">
- <CircleUserRound className="h-4 w-4" />
- </span>
- <span className="min-w-0 flex-1 truncate">{t("notebookPane.profile")}</span>
- </button>
+ <div className="flex items-center gap-1">
+ <button
+ onClick={onOpenSettings}
+ className="flex h-8 min-w-0 flex-1 items-center gap-3 rounded-md px-3 text-left text-sm font-medium leading-none text-slate-700 transition-colors duration-200 hover:bg-slate-50 hover:text-slate-950 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-slate-400/70"
+ type="button"
+ aria-label={t("notebookPane.profile")}
+ >
+ <span className="flex h-4 w-4 shrink-0 items-center justify-center">
+ <CircleUserRound className="h-4 w-4" />
+ </span>
+ <span className="min-w-0 flex-1 truncate">{t("notebookPane.profile")}</span>
+ </button>
+ <DesktopUpdateNotice />
+ </div>
</div>
</footer>
</div>
diff --git a/apps/web/src/vite-env.d.ts b/apps/web/src/vite-env.d.ts
index bd90158c..91a329be 100644
--- a/apps/web/src/vite-env.d.ts
+++ b/apps/web/src/vite-env.d.ts
@@ -31,10 +31,11 @@ interface EdgeEverDesktopBridge {
openRendererIssue(details: DesktopRendererErrorDetails): Promise<{ opened: true }>;
sidecarStatus(): Promise<{ available: boolean; path: string; scope: string }>;
setAccountScope(accountId: string | null): Promise<{ ready: true; scope: string }>;
- updateStatus(): Promise<{ state: "idle" | "available" | "downloaded" }>;
- checkUpdate(): Promise<{ state: "idle" | "available" | "downloaded" }>;
+ updateStatus(): Promise<DesktopUpdateStatus>;
+ checkUpdate(): Promise<DesktopUpdateStatus>;
downloadUpdate(): Promise<unknown>;
installUpdate(): Promise<unknown>;
+ onUpdateStatus(callback: (status: DesktopUpdateStatus) => void): () => void;
sidecarRequest<T = unknown>(method: string, params?: Record<string, unknown>): Promise<T>;
stageResource(input: { memoId: string; name: string; type: string; bytes: ArrayBuffer }): Promise<{ id: string }>;
listStagedResources(): Promise<Array<{ id: string; memoId: string; name: string; type: string; size: number }>>;
@@ -45,6 +46,11 @@ interface EdgeEverDesktopBridge {
onImportMarkdown(callback: (payload: { name: string; content: string }) => void): () => void;
}
+interface DesktopUpdateStatus {
+ state: "idle" | "available" | "downloaded";
+ version: string | null;
+}
+
type DesktopLocalDataResetErrorCode =
| "unsafe-data-directory"
| "application-bundle-not-found"
diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.ts
index 6743640c..f0044939 100644
--- a/packages/shared/src/i18n/en-US.ts
+++ b/packages/shared/src/i18n/en-US.ts
@@ -636,7 +636,7 @@ export const enUS = {
desktopUpdateDownloading: "Downloading update…",
desktopUpdateReady: "Update downloaded",
desktopUpdateDownload: "Download update",
- desktopUpdateRestart: "Restart to update",
+ desktopUpdateRestart: "Restart to Update",
desktopUpdateInstalling: "Restarting to install update…",
desktopUpdateFailed: "Update failed. Please try again later.",
},
diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.ts
index 5c12af50..37425a75 100644
--- a/packages/shared/src/i18n/zh-CN.ts
+++ b/packages/shared/src/i18n/zh-CN.ts
@@ -636,7 +636,7 @@ export const zhCN = {
desktopUpdateDownloading: "正在下载更新…",
desktopUpdateReady: "更新已下载完成",
desktopUpdateDownload: "下载更新",
- desktopUpdateRestart: "重启并更新",
+ desktopUpdateRestart: "重启以更新",
desktopUpdateInstalling: "正在重启并安装更新…",
desktopUpdateFailed: "更新失败,请稍后重试。",
},