A local-first multi-agent app development platform, built on PenguinHarness
feat(desktop): 默认从 OSS 镜像检查更新,镜像不通回退 GitHub Releases
lmliheng5648d16a3ba8
diff --git a/packages/desktop/src/update-support.ts b/packages/desktop/src/update-support.tsindex 4367493d..5c0dac57 100644--- a/packages/desktop/src/update-support.ts+++ b/packages/desktop/src/update-support.ts@@ -49,8 +49,45 @@ export function feedUrlOverride(env: NodeJS.ProcessEnv): string | null {}}-// Adelie fork note (2026-10-05): PENGUIN_UPDATE_SOURCE and PENGUIN_UPDATE_SPEED_PROBE lived-// here. They chose between two feeds — upstream's GitHub Releases and an Alibaba Cloud OSS-// mirror of the same assets — and Adelie has exactly one feed, its own GitHub Releases, so-// both knobs are gone rather than left accepting values that no longer mean anything. A-// deployment that runs a mirror of its own points PENGUIN_UPDATE_FEED_URL at it.+/**+ * Adelie's own GitHub Releases, where the release assets are published: the source of truth, and+ * the feed a check falls back to when the mirror does not answer.+ */+export const GITHUB_FEED = {+ provider: "github" as const,+ owner: "lmliheng",+ repo: "Adelie",+};++/** The human-facing page the same feed belongs to (the error dialog's "Open Releases"). */+export const RELEASES_URL = "https://github.com/lmliheng/Adelie/releases";++/**+ * The Alibaba Cloud OSS mirror of those assets — the same bytes, served from `latest/` under+ * version-less names (see `scripts/publish-release-to-oss.sh`). It is the default feed, not a+ * replacement: Adelie's users are in China, where github.com is slow to unusable, and a check+ * that cannot reach the mirror goes to GitHub Releases instead.+ */+export const MIRROR_FEED_URL = "https://adelie-releases.oss-cn-hangzhou.aliyuncs.com/latest";++/** Which of the three feeds a check is pointed at. */+export type UpdateFeedKind = "override" | "mirror" | "github";++/**+ * The feed a check starts from: an explicit `PENGUIN_UPDATE_FEED_URL` (a deployment's own mirror,+ * or the local server an end-to-end update test stands up) wins over everything, the OSS mirror is+ * the default.+ */+export function initialFeedKind(env: NodeJS.ProcessEnv): UpdateFeedKind {+ return feedUrlOverride(env) !== null ? "override" : "mirror";+}++/**+ * Whether a failed check on this feed is retried against GitHub Releases. Only the mirror falls+ * back: it is a convenience copy of the Release assets, so GitHub still holds what the check was+ * looking for. An override is an instruction about which feed to use, and a check that quietly+ * went elsewhere would answer a different question than the one that was asked.+ */+export function fallsBackToGithub(kind: UpdateFeedKind): boolean {+ return kind === "mirror";+}diff --git a/packages/desktop/src/updater.ts b/packages/desktop/src/updater.tsindex 0197d9d8..5beb8836 100644--- a/packages/desktop/src/updater.ts+++ b/packages/desktop/src/updater.ts@@ -17,11 +17,13 @@* check or download is manual too, but its outcomes render in the modal that asked, not* in dialogs: the native restart prompt follows only a download the native dialog started.*- * Adelie fork note (2026-10-05): this build publishes to one feed — its own GitHub Releases- * (`lmliheng/Adelie`). Upstream's second feed, an Alibaba Cloud OSS mirror of the same- * assets, is gone here, and with it the speed probe that chose between the two sources: a- * mirror belongs to the project that runs it, and this one has none. What remains is- * `PENGUIN_UPDATE_FEED_URL` for a deployment that runs a mirror of its own.+ * Adelie fork note (2026-10-06): the assets are published to this fork's own GitHub Releases+ * (`lmliheng/Adelie`) and mirrored to Alibaba Cloud OSS, and the mirror is the feed a check+ * starts from — github.com is slow to unusable for the users this fork is built for. GitHub+ * Releases stays the source of truth: a check the mirror does not answer is retried there, so a+ * mirror that is stale, broken or simply gone costs one round-trip rather than the update.+ * `PENGUIN_UPDATE_FEED_URL` still outranks both — an end-to-end update test points it at the+ * local server it just stood up — and is answered as-is, never followed by a fallback.** Release builds use Developer ID signing on macOS and Authenticode signing on Windows;* unsigned dry-run artifacts can still find updates, but platform trust and release@@ -37,7 +39,16 @@ import type {} from "@lmliheng/penguin-server/api";import { resolveProfile } from "./app-identity.js";import { logLine } from "./desktop-log.js";-import { feedUrlOverride, updateSupport } from "./update-support.js";+import {+ GITHUB_FEED,+ MIRROR_FEED_URL,+ RELEASES_URL,+ fallsBackToGithub,+ feedUrlOverride,+ initialFeedKind,+ updateSupport,+} from "./update-support.js";+import type { UpdateFeedKind } from "./update-support.js";import { initialUpdateStatus, nextUpdateStatus } from "./updater-status.js";import type { UpdaterEvent } from "./updater-status.js";@@ -48,16 +59,6 @@ const FIRST_CHECK_DELAY_MS = 20_000;/** Subsequent automatic checks. */const CHECK_INTERVAL_MS = 6 * 60 * 60 * 1000;-// Adelie's own releases, not upstream's (2026-10-05): the two projects reuse version-// numbers, so a feed left pointing at PenguinHarness would offer — and install — a-// PenguinHarness build over this app.-const RELEASES_URL = "https://github.com/lmliheng/Adelie/releases";-const GITHUB_FEED = {- provider: "github" as const,- owner: "lmliheng",- repo: "Adelie",-};-function log(line: string): void {logLine(`[updater] ${line}`);}@@ -72,18 +73,24 @@ let downloadInFlight = false;let nativeDownload = false;/**- * The feed this build updates from: Adelie's own GitHub Releases, or the generic feed an- * explicit PENGUIN_UPDATE_FEED_URL names (a deployment's own mirror). One source, fixed at- * init — there is no selection step to wait on, and no second feed to retry against.+ * The feeds this build can update from, and the one a check is pointed at right now: the OSS+ * mirror by default, an explicit PENGUIN_UPDATE_FEED_URL instead when one is set, and GitHub+ * Releases while a check the mirror did not answer is being retried (`handleCheckError`).*/let overrideFeedUrl: string | null = null;+let activeFeed: UpdateFeedKind = "mirror";-function applyFeed(): void {- if (overrideFeedUrl === null) {+/** Points electron-updater at one of the three feeds; the kind is remembered for the fallback. */+function setFeed(kind: UpdateFeedKind): void {+ activeFeed = kind;+ if (kind === "github") {autoUpdater.setFeedURL(GITHUB_FEED);return;}- autoUpdater.setFeedURL({ provider: "generic", url: overrideFeedUrl });+ autoUpdater.setFeedURL({+ provider: "generic",+ url: kind === "override" ? (overrideFeedUrl as string) : MIRROR_FEED_URL,+ });}function scheduleChecks(): void {@@ -138,6 +145,22 @@ function reportUpdaterError(err: Error, step: "check" | "download"): void {});}+/**+ * A check that failed. The default feed is the OSS mirror, a convenience copy of the Release+ * assets — so a check it does not answer is retried against GitHub Releases, which is where those+ * assets are published and which every release leaves current. Only a failure of that second feed+ * is the user's failure. An explicit PENGUIN_UPDATE_FEED_URL never falls back: it names the feed+ * to use, and a check against some other one would answer a different question.+ */+function handleCheckError(err: Error): void {+ if (fallsBackToGithub(activeFeed)) {+ log(`mirror check failed (${err.message}); retrying against GitHub Releases`);+ void check("github");+ return;+ }+ reportUpdaterError(err, "check");+}+/** Current snapshot, for the initial push after a server (re)start. */export function getUpdaterStatus(): DesktopUpdateStatus {return status;@@ -273,16 +296,23 @@ export function initUpdater(getWindow: () => BrowserWindow | null): void {if (downloadInFlight) {return;}- reportUpdaterError(err, "check");+ handleCheckError(err);});overrideFeedUrl = feedUrlOverride(process.env);- applyFeed();- if (overrideFeedUrl !== null) log(`feed override: ${overrideFeedUrl}`);+ setFeed(initialFeedKind(process.env));+ // Which feed this run will read says where an update did (or did not) come from, which is the+ // first question when one fails.+ log(+ overrideFeedUrl !== null+ ? `feed override: ${overrideFeedUrl}`+ : `feed: mirror ${MIRROR_FEED_URL} (GitHub Releases as fallback)`,+ );scheduleChecks();}-async function check(): Promise<void> {+/** `startFeed` is what the GitHub fallback passes; an ordinary check starts from the default. */+async function check(startFeed?: UpdateFeedKind): 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@@ -295,6 +325,9 @@ async function check(): Promise<void> {) {return;}+ // Every ordinary check starts from the configured default, so a mirror that failed last time+ // gets another chance instead of the session being pinned to the fallback.+ setFeed(startFeed ?? initialFeedKind(process.env));try {await autoUpdater.checkForUpdates();} catch (err) {diff --git a/packages/desktop/test/update-support.test.ts b/packages/desktop/test/update-support.test.tsindex ab313760..a6bf10b0 100644--- a/packages/desktop/test/update-support.test.ts+++ b/packages/desktop/test/update-support.test.ts@@ -1,5 +1,12 @@import { describe, expect, it } from "vitest";-import { feedUrlOverride, updateSupport } from "../src/update-support.js";+import {+ GITHUB_FEED,+ MIRROR_FEED_URL,+ fallsBackToGithub,+ feedUrlOverride,+ initialFeedKind,+ updateSupport,+} from "../src/update-support.js";describe("updateSupport", () => {it("supports packaged macOS and Windows builds", () => {@@ -65,5 +72,38 @@ describe("feedUrlOverride", () => {});});-// The source/probe switches (PENGUIN_UPDATE_SOURCE, PENGUIN_UPDATE_SPEED_PROBE) are gone with-// the second feed; PENGUIN_UPDATE_FEED_URL above is what remains for a deployment's own mirror.+describe("the default feed", () => {+ it("is Adelie's own OSS mirror, over https, with /latest as the generic feed its assets live under", () => {+ // The mirror is a generic feed: electron-updater appends `/latest.yml` (Windows) or+ // `/latest-linux.yml` (Linux) to this URL, which is exactly what publish-release-to-oss.sh+ // uploads to `latest/`.+ expect(MIRROR_FEED_URL).toBe("https://adelie-releases.oss-cn-hangzhou.aliyuncs.com/latest");+ expect(new URL(MIRROR_FEED_URL).protocol).toBe("https:");+ });++ it("is this fork's GitHub Releases when a check falls back, not upstream's", () => {+ // Both projects reuse version numbers: a feed left pointing at PenguinHarness would offer —+ // and install — a PenguinHarness build over this app.+ expect(GITHUB_FEED).toEqual({ provider: "github", owner: "lmliheng", repo: "Adelie" });+ });+});++describe("initialFeedKind", () => {+ it("starts from the mirror, or from an explicit PENGUIN_UPDATE_FEED_URL when one is set", () => {+ expect(initialFeedKind({})).toBe("mirror");+ expect(initialFeedKind({ PENGUIN_UPDATE_FEED_URL: "http://127.0.0.1:8080/feed" })).toBe(+ "override",+ );+ // An unusable override is not a feed; the check still starts from the mirror.+ expect(initialFeedKind({ PENGUIN_UPDATE_FEED_URL: "file:///etc/passwd" })).toBe("mirror");+ });+});++describe("fallsBackToGithub", () => {+ it("retries the mirror against GitHub Releases, and leaves an override alone", () => {+ expect(fallsBackToGithub("mirror")).toBe(true);+ expect(fallsBackToGithub("override")).toBe(false);+ // Already the fallback: a second failure is the answer, not another retry.+ expect(fallsBackToGithub("github")).toBe(false);+ });+});