Skip to content

A local-first multi-agent app development platform, built on PenguinHarness

fix(desktop): 「检查更新」不再拿上次查到的版本冒充最新版

lmliheng46357436356f
diff --git a/changelog/unreleased/2026-10-28-check-updates-reads-feed.md b/changelog/unreleased/2026-10-28-check-updates-reads-feed.md
new file mode 100644
index 00000000..c6b570b7
--- /dev/null
+++ b/changelog/unreleased/2026-10-28-check-updates-reads-feed.md
@@ -0,0 +1,41 @@
+# "Check for updates" reads the feed again instead of re-showing the last answer
+
+- **Date:** 2026-10-28
+- **Type:** fix
+- **Scope:** `desktop`
+- **Breaking:** no
+
+[中文](2026-10-28-check-updates-reads-feed.zh.md)
+
+Check for updates in the desktop app could answer with a version that was already old. Once a check
+found a release, the shell kept that offer as settled: pressing check again — from the app menu or from
+the update modal — re-displayed the same version without asking the feed, and the six-hourly automatic
+check skipped the feed for the same reason. Publish a new release an hour later and the offer stayed on
+the previous one for the rest of the session, so the app reported a version the cloud had already
+replaced.
+
+Now any check that can run reads the feed: the app menu's item, the modal's row, and the periodic
+check. A newer release replaces the standing offer (nothing is downloaded, and an offer is not a
+promise); an up-to-date answer retires it. The one thing that still settles without a lookup is a check
+asked for while a download is running, a build is waiting to install, or another check is already out —
+there, the row simply gets the current state back, and the menu item says so in a dialog.
+
+## Details
+
+- `packages/desktop/src/updater.ts`: `check()` no longer declines when the status is `available` — it
+ only declines on a download in flight or a downloaded build on disk (a re-check there could
+ invalidate the package the install action points at). `handleUpdaterCommand("check")` and
+ `checkForUpdatesManually()` gate on `manualCheckAsksFeed(status)` and then run that same check, so a
+ standing offer is re-read rather than re-presented.
+- `packages/desktop/src/updater-status.ts`: `manualCheckAsksFeed` — the one place that decides whether a
+ user-asked check can run at all (not `downloading`, not `downloaded`, not `checking`). The fold is
+ unchanged: while an offer stands, a check's `checking` frame and a same-version re-announce still do
+ not replace it, so the offer does not blink out while it is being refreshed.
+- `packages/desktop/test/updater-status.test.ts`: `manualCheckAsksFeed` pinned for every state —
+ including `available`, the case this fix is about.
+
+## Compatibility
+
+- No wire or storage change: `DesktopUpdateStatus` and the updater command frames keep their shape.
+- A periodic check now contacts the feed even while an offer stands, so a long-running session picks up
+ releases published after the offer appeared.
diff --git a/changelog/unreleased/2026-10-28-check-updates-reads-feed.zh.md b/changelog/unreleased/2026-10-28-check-updates-reads-feed.zh.md
new file mode 100644
index 00000000..f2f4d9b7
--- /dev/null
+++ b/changelog/unreleased/2026-10-28-check-updates-reads-feed.zh.md
@@ -0,0 +1,35 @@
+# 「检查更新」重新去查源,不再把上次的结果当成最新的
+
+- **Date:** 2026-10-28
+- **Type:** fix
+- **Scope:** `desktop`
+- **Breaking:** no
+
+[English](2026-10-28-check-updates-reads-feed.md)
+
+桌面端点「检查更新」,有时候会告诉你一个已经过时的版本。原因是:只要查到过一个新版本,壳子就把这条
+可更新提示当成了定局 —— 再点一次检查(菜单里的、更新弹窗里的)只是把同一个版本重新显示一遍,根本没去
+问源;每六小时一次的自动检查也因为同一个理由跳过。这中间云端又发了新版本,于是整段会话里显示的始终是
+上一次查到的那个。
+
+现在只要检查还能跑,就去读源:菜单项、弹窗里的检查、定时检查都一样。查到更新的版本就换掉手上这条
+提示(什么都不会下载,它只是一句「有这一版」);查到已是最新就把提示撤掉。唯一还
+不去查源的情况是:正在下载、已经有安装包在等重启、或者另一个检查已经在路上 —— 这时候行里直接拿到当前
+状态,菜单项则会弹出一个说明。
+
+## 细节
+
+- `packages/desktop/src/updater.ts`:`check()` 不再因为状态是 `available` 就提前返回,只挡「下载中」
+ 与「已下载待安装」(这两处重新查会把安装按钮指向的包作废)。`handleUpdaterCommand("check")` 与
+ `checkForUpdatesManually()` 都改成用 `manualCheckAsksFeed(status)` 判断能不能查,能查就跑同一个
+ `check()` —— 站着的提示会被重新读一次,而不是原样重放。
+- `packages/desktop/src/updater-status.ts`:新增 `manualCheckAsksFeed` —— 判断「用户点的这次检查能不能
+ 真的跑」的唯一一处(`downloading` / `downloaded` / `checking` 之外都能)。状态折叠规则没动:提示
+ 还在时,检查期间的 `checking` 帧和同版本的重播都不会替换它,所以刷新过程中那句话不会闪掉。
+- `packages/desktop/test/updater-status.test.ts`:把 `manualCheckAsksFeed` 在各个状态下都钉住了 ——
+ 包括 `available`,正是这次要修的那一格。
+
+## 兼容
+
+- 协议与存储都没变:`DesktopUpdateStatus` 和各条更新命令帧的形状不变。
+- 定时检查现在会在提示还在时也去问一次源,所以长时间开着的桌面端能收到提示出现之后才发布的版本。
diff --git a/docs/FORK-PROGRESS.md b/docs/FORK-PROGRESS.md
index d334a1b4..399de88c 100644
--- a/docs/FORK-PROGRESS.md
+++ b/docs/FORK-PROGRESS.md
@@ -18155,3 +18155,46 @@ key)、**4.1–4.3**(明令不动)、**5.6** / **5.10**(拍板 / 新依
### 提交
- 代码 + 用例 + 文案 + 文档 + changelog 中英一对:**`e5f9aec6`**;本轮台账(本条)另起一笔,与历次一致。
+
+## 第一百五十一轮:桌面端「检查更新」不再拿上次的结果冒充最新版(2026-10-28,用户点单)
+
+### 起点:用户说「桌面端有时候检查到的版本不是最新版」
+
+- 用户原话:「桌面端有时候检查到的版本不是最新版,是因为之前检查的时候没更新,后续云端版本又更新了,导致
+ 看检查更新的时候是上次检查的版本。」开工 `HEAD` = `0dae1863`。
+- 代码里对得上:`packages/desktop/src/updater.ts` 的 `check()` 在 `status.state === "available"` 时
+ **直接返回**(不查源),`handleUpdaterCommand("check")` 与 `checkForUpdatesManually()` 里还各自有一段
+ 「手上已有可更新版本就重新展示一遍」的分支。于是首次查到 v X 之后,只要云端又发了 v Y,菜单里的「检查更新」
+ 与弹窗里的检查都只会把 v X 再念一遍,每六小时一次的自动检查也一样跳过 —— 整段会话里显示的始终是旧版。
+- 这里没有第二个嫌疑点:`updateModeFor` 决定桌面壳窗口走 `client` 模式,`releaseFlow`(服务端那条自查)
+ 在桌面壳里根本不会被选中。
+
+### 改法:能查就去查
+
+- `check()` 删掉 `available` 那条提前返回,只留「下载中」与「已下载待安装」——这两处重新查会让安装按钮
+ 指向的包作废(原文的注释本来就是这个理由)。可更新版本被新版本替换什么也不会丢,`autoDownload` 是关的。
+- `packages/desktop/src/updater-status.ts` 新增 `manualCheckAsksFeed(status)`:`downloading` /
+ `downloaded` / `checking` 三种状态之外都算「这次检查真的能跑」,`handleUpdaterCommand("check")` 与
+ `checkForUpdatesManually()` 都用它判断;不能跑时前者回一个 `reannounceStatus()`(弹窗的 armed check
+ 立刻拿到当前状态,不至于等 60 秒超时),后者弹一句说明(下载中/正在检查)。
+- 状态折叠规则**没动**:`available` 时检查期间的 `checking` 帧与同版本重播仍然被抑制,所以刷新过程中
+ 行里那句「可更新」不会闪掉;新版本到了才替换。
+
+### 验证
+
+- 单测:`packages/desktop/test/updater-status.test.ts` 新增 `manualCheckAsksFeed` 两组断言(五种状态下
+ 的取值,含本次要修的 `available`);桌面端全量 **26 文件 / 306 通过**(`EXIT=0`)。
+- `pnpm --filter @adelie/desktop typecheck` **EXIT=0**;`oxlint .` 0 警告 0 错误;`prettier --check .` 全仓干净。
+- **没做**真机端到端:要跑通得先打一个 `isPackaged` 的桌面包(AppImage / NSIS)再配一个假 feed,代价远超
+ 这次改动的三行判断;本次的判据是纯函数单测 + 类型检查,逻辑分支都在这两个函数里。
+
+### 没做 / 还差什么
+
+- 弹窗在 `available` 状态的底栏仍然只有「稍后 / 下载并安装」,没有「再查一次」按钮:想手动刷新要么用应用
+ 菜单的检查,要么等定时检查(最长 6 小时,且启动后 20 秒必有一次)。要不要给弹窗加这个按钮,等用户发话。
+- 仍未部署到现网(7777 还是 v0.5.9 的安装);这些改动要进现网得发版,需用户点头。
+- 豆包式「多图画板 + 悬浮快捷条」仍是下一轮的点单,未开工。
+
+### 提交
+
+- 代码 + 用例 + changelog 中英一对 + 本轮台账同在这一笔(按约定不再另开「补记」提交)。
diff --git a/packages/desktop/src/updater-status.ts b/packages/desktop/src/updater-status.ts
index 87619112..1e7e12a9 100644
--- a/packages/desktop/src/updater-status.ts
+++ b/packages/desktop/src/updater-status.ts
@@ -24,8 +24,9 @@
* re-announce) is suppressed: folding it would drop the download context and every
* later progress tick with it. A download's own failure still lands as `error`.
* - While `available`, a check's `checking` and a same-version re-announce are suppressed
- * too: the offer must not blink out under the fallback-feed re-check that a failed
- * download runs. A different version, an up-to-date answer, or an error replace it.
+ * too: a check re-reads the feed precisely to keep the offer current (see
+ * `manualCheckAsksFeed`), and the offer must not blink out while it does. A different
+ * version, an up-to-date answer, or an error replace it.
*/
import type {
DesktopUpdateStatus,
@@ -95,6 +96,25 @@ export function nextUpdateStatus(prev: DesktopUpdateStatus, ev: UpdaterEvent): D
}
}
+/**
+ * Whether a user's "check for updates" should ask the feed again, instead of re-showing what
+ * the shell already found.
+ *
+ * A download in flight, a build waiting on disk, or a check already running says no: asking
+ * again there could invalidate what the user is being offered, and the row that pressed the
+ * button only needs an answer, not a second lookup.
+ *
+ * A standing offer does NOT say no. That offer is only what the *last* check saw, and a
+ * release published since then is precisely what the user pressed the button to find out —
+ * re-showing the old version under a "check for updates" action is how a shell reports a
+ * version that the cloud replaced hours ago.
+ */
+export function manualCheckAsksFeed(status: DesktopUpdateStatus): boolean {
+ return (
+ status.state !== "downloading" && status.state !== "downloaded" && status.state !== "checking"
+ );
+}
+
/** Wraps a snapshot for the port push. */
export function updaterStatusMessage(status: DesktopUpdateStatus): DesktopUpdaterStatusMessage {
return { type: "desktop-updater-status", status };
diff --git a/packages/desktop/src/updater.ts b/packages/desktop/src/updater.ts
index 01f7cfc0..a0ba322d 100644
--- a/packages/desktop/src/updater.ts
+++ b/packages/desktop/src/updater.ts
@@ -41,7 +41,7 @@ import {
updateSupport,
} from "./update-support.js";
import type { UpdateFeedKind } from "./update-support.js";
-import { initialUpdateStatus, nextUpdateStatus } from "./updater-status.js";
+import { initialUpdateStatus, manualCheckAsksFeed, nextUpdateStatus } from "./updater-status.js";
import type { UpdaterEvent } from "./updater-status.js";
const { autoUpdater } = electronUpdater;
@@ -176,15 +176,12 @@ export function handleUpdaterCommand(action: DesktopUpdaterCommandMessage["actio
emitStatus({ kind: "unsupported", reason: support.reason });
return;
}
- if (
- downloadedVersion !== null ||
- status.state === "downloading" ||
- status.state === "available" ||
- status.state === "checking"
- ) {
+ if (!manualCheckAsksFeed(status)) {
reannounceStatus();
return;
}
+ // A standing offer is only what the last check saw; the user asked this one, so it
+ // reads the feed again (see `manualCheckAsksFeed`).
void check();
return;
}
@@ -291,18 +288,20 @@ export function initUpdater(getWindow: () => BrowserWindow | null): void {
scheduleChecks();
}
-/** Runs one check against the configured feed. */
+/**
+ * Runs one check against the configured feed.
+ *
+ * A standing offer is re-read, not kept: it is only what the *last* check saw, and a release
+ * published since then is exactly what a check is for — a shell that keeps showing the
+ * version the cloud replaced an hour ago reads as broken. Nothing is fetched either way
+ * (`autoDownload` is off), so replacing the offer costs the user nothing.
+ */
async function check(): Promise<void> {
// A waiting build ends the checking: a re-check that finds a newer release would
// start fetching it and invalidate the downloaded package on disk while the UI still
// points its install action at it. The user installs what they were offered; the next
- // launch checks again. A running download likewise finishes undisturbed, and a standing
- // offer stays what it is — the user takes it or leaves it; the next launch checks again.
- if (
- downloadedVersion !== null ||
- status.state === "downloading" ||
- status.state === "available"
- ) {
+ // launch checks again. A running download likewise finishes undisturbed.
+ if (downloadedVersion !== null || status.state === "downloading") {
return;
}
// Every check reads the feed configured for this run — an override when one is set, GitHub
@@ -378,20 +377,25 @@ export async function checkForUpdatesManually(): Promise<void> {
await promptRestart(downloadedVersion, null);
return;
}
- if (status.state === "downloading") {
- // check() would decline anyway; a manual action still answers (the silence rule).
+ if (!manualCheckAsksFeed(status)) {
+ // A download already runs, or a check is out: answer the menu click, don't stack a
+ // second lookup on top.
+ const downloading = status.state === "downloading";
await dialog.showMessageBox({
type: "info",
- message: "An update is downloading.",
- detail: "You will be asked to restart when it is ready.",
+ message: downloading
+ ? "An update is downloading."
+ : "Adelie is already checking for updates.",
+ detail: downloading
+ ? "You will be asked to restart when it is ready."
+ : "The result will show in a moment.",
+ buttons: ["OK"],
});
return;
}
- if (status.state === "available" && status.version !== undefined) {
- // The offer stands (check() leaves it alone); a manual check re-presents it.
- await promptDownload(status.version, null);
- return;
- }
+ // Offered or not, the check reads the feed: a release published since the last check is
+ // what the user is asking about, and re-presenting the old offer would name a version the
+ // cloud has already replaced. The outcome lands in a dialog either way.
manualCheckInFlight = true;
await check();
}
diff --git a/packages/desktop/test/updater-status.test.ts b/packages/desktop/test/updater-status.test.ts
index a4151a20..41b70384 100644
--- a/packages/desktop/test/updater-status.test.ts
+++ b/packages/desktop/test/updater-status.test.ts
@@ -14,6 +14,7 @@ import { describe, expect, it } from "vitest";
import type { DesktopUpdateStatus } from "@adelie/server/api";
import {
initialUpdateStatus,
+ manualCheckAsksFeed,
nextUpdateStatus,
parseUpdaterCommand,
updaterStatusMessage,
@@ -182,6 +183,36 @@ describe("nextUpdateStatus", () => {
});
});
+describe("manualCheckAsksFeed", () => {
+ it("asks the feed whenever an answer is what the user is after", () => {
+ expect(manualCheckAsksFeed(initialUpdateStatus("1.0.0"))).toBe(true);
+ expect(manualCheckAsksFeed({ appVersion: "1.0.0", state: "up-to-date" })).toBe(true);
+ expect(manualCheckAsksFeed({ appVersion: "1.0.0", state: "error", message: "offline" })).toBe(
+ true,
+ );
+ // The standing offer is only what the *last* check saw: a release published since is
+ // exactly what the button asks about.
+ expect(manualCheckAsksFeed({ appVersion: "1.0.0", state: "available", version: "1.1.0" })).toBe(
+ true,
+ );
+ });
+
+ it("leaves a running step alone", () => {
+ expect(
+ manualCheckAsksFeed({
+ appVersion: "1.0.0",
+ state: "downloading",
+ version: "1.1.0",
+ percent: 20,
+ }),
+ ).toBe(false);
+ expect(
+ manualCheckAsksFeed({ appVersion: "1.0.0", state: "downloaded", version: "1.1.0" }),
+ ).toBe(false);
+ expect(manualCheckAsksFeed({ appVersion: "1.0.0", state: "checking" })).toBe(false);
+ });
+});
+
describe("port frames", () => {
it("wraps a snapshot for the push", () => {
const status = initialUpdateStatus("1.0.0");