25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(updates): keep a prepared package installable when the remote reports no update (#13793)
ordinary being38fd3c5f7353
diff --git a/apps/desktop/src/App.vue b/apps/desktop/src/App.vueindex 49f469a240..1c02b93345 100644--- a/apps/desktop/src/App.vue+++ b/apps/desktop/src/App.vue@@ -341,6 +341,7 @@ const {isDownloadingUpdate,downloadProgress,updateDownloaded,+ updateDownloadedVersion,isInstallingUpdate,updateReady,isIgnoringUpdate,@@ -5961,6 +5962,7 @@ onUnmounted(() => {:is-downloading-update="isDownloadingUpdate":download-progress="downloadProgress":update-downloaded="updateDownloaded"+ :update-downloaded-version="updateDownloadedVersion":is-preparing-update="isPreparingUpdate":is-installing-update="isInstallingUpdate":update-ready="updateReady"diff --git a/apps/desktop/src/components/layout/UpdateDialog.spec.ts b/apps/desktop/src/components/layout/UpdateDialog.spec.tsindex 2a83f117c1..404d96e83a 100644--- a/apps/desktop/src/components/layout/UpdateDialog.spec.ts+++ b/apps/desktop/src/components/layout/UpdateDialog.spec.ts@@ -234,6 +234,40 @@ describe("UpdateDialog active task guard", () => {});});+describe("UpdateDialog prepared package without a remote update (#13562)", () => {+ const upToDateInfo = {+ current_version: "0.5.61",+ latest_version: "0.5.61",+ update_available: false,+ portable_mode: false,+ manual_update_only: false,+ release_name: "DBX v0.5.61",+ release_url: "https://github.com/t8y2/dbx/releases/tag/v0.5.61",+ release_notes: "",+ };++ it("keeps the install action reachable when the remote reports no update", async () => {+ const installDownloaded = vi.fn(async () => {});+ await mountDialog(0, { updateDownloaded: true, downloadProgress: 100 }, installDownloaded, { updateInfo: upToDateInfo });++ const button = installDownloadedButton();+ expect(button).toBeDefined();+ expect(button?.disabled).toBe(false);+ button?.click();+ await flushDialog();++ expect(installDownloaded).toHaveBeenCalledOnce();+ });++ it("labels the prepared package with its own version", async () => {+ await mountDialog(0, { updateDownloaded: true, downloadProgress: 100 }, undefined, { updateInfo: upToDateInfo, updateDownloadedVersion: "0.5.62" });++ expect(document.body.textContent).toContain("v0.5.62 is downloaded");+ expect(document.body.textContent).not.toContain("DBX is up to date");+ expect(document.body.textContent).not.toContain("v0.5.61 is downloaded");+ });+});+describe("UpdateDialog download progress", () => {it("keeps the downloading button at a fixed width as progress changes", async () => {const { state } = await mountDialog(0, { isDownloadingUpdate: true, downloadProgress: 9 });diff --git a/apps/desktop/src/components/layout/UpdateDialog.vue b/apps/desktop/src/components/layout/UpdateDialog.vueindex b83a209e9b..a57ce3ea05 100644--- a/apps/desktop/src/components/layout/UpdateDialog.vue+++ b/apps/desktop/src/components/layout/UpdateDialog.vue@@ -30,6 +30,7 @@ const props = withDefaults(isDownloadingUpdate: boolean;downloadProgress: number | null;updateDownloaded: boolean;+ updateDownloadedVersion?: string;isInstallingUpdate: boolean;isPreparingUpdate?: boolean;updateReady: boolean;@@ -64,6 +65,7 @@ const props = withDefaults(componentUpdatesUpdating: false,updatingComponent: null,isUpdatingAll: false,+ updateDownloadedVersion: "",},);@@ -85,6 +87,13 @@ const selectedTab = ref<UpdateTab>("app");const renderedNotes = ref("");const hasAppUpdate = computed(() => props.updateDownloaded || props.updateReady || props.updateInfo?.update_available === true);+/**+ * A prepared package must stay actionable even when the remote no longer+ * reports that release as newest (yanked/rolled-back latest, mirror lag): the+ * download already happened, so hiding the install button would strand the+ * user with a permanent "downloaded" badge and no way to install it (#13562).+ */+const appUpdateActionsVisible = computed(() => props.updateInfo?.update_available === true || props.updateDownloaded || props.updateReady);const mcpAvailable = computed(() => (props.mcpUpdate ? mcpUpdateAvailability(props.mcpUpdate) === true : false));/** 历史版本每页条数(与更新日志一致,避免一次性铺开所有版本) */@@ -364,7 +373,7 @@ watch(})}}</p>- <p v-else-if="!checkingUpdates" class="text-muted-foreground">+ <p v-else-if="!checkingUpdates && !updateDownloaded && !updateReady" class="text-muted-foreground">{{ updateCheckMessage || t("updates.upToDate", { version: updateInfo?.current_version || "" }) }}</p><div@@ -393,7 +402,7 @@ watch(<Loader2 class="h-4 w-4 animate-spin" />{{ t("updates.checking") }}</p>- <p v-if="updateDownloaded && !isInstallingUpdate" class="mt-3">{{ t("updates.downloadedReady", { version: updateInfo?.latest_version }) }}</p>+ <p v-if="updateDownloaded && !isInstallingUpdate" class="mt-3">{{ t("updates.downloadedReady", { version: updateDownloadedVersion || updateInfo?.latest_version }) }}</p><p v-if="updateCheckFailed && updateInfo?.update_available" role="alert" class="mt-3 text-destructive">{{ updateCheckMessage }}</p><div v-if="olderReleases.length || historyError" data-update-history class="mt-4 border-t pt-3">@@ -511,15 +520,15 @@ watch(</SelectContent></Select></div>- <template v-if="updateInfo?.update_available">- <div class="flex min-w-0 flex-wrap items-center gap-2 sm:justify-end">+ <template v-if="appUpdateActionsVisible">+ <div v-if="updateInfo?.update_available" class="flex min-w-0 flex-wrap items-center gap-2 sm:justify-end"><Button v-if="canIgnoreVersion" variant="ghost" class="shrink-0" :disabled="isIgnoringUpdate" @click="emit('ignore-version')"><Loader2 v-if="isIgnoringUpdate" class="h-4 w-4 animate-spin" />{{ t("updates.ignoreVersion") }}</Button><Button variant="outline" class="shrink-0" @click="emit('open-latest-release')">{{ t("updates.openRelease") }}</Button></div>- <template v-if="canDownloadAndInstallUpdate(updateInfo, isDesktop)">+ <template v-if="canDownloadAndInstallUpdate(updateInfo, isDesktop) || updateDownloaded || updateReady"><Button v-if="updateReady" class="shrink-0" :disabled="activeTaskCount > 0 || isIgnoringUpdate || isUpdatingAll" @click="emit('restart')">{{ t("updates.restart") }}</Button><Button v-else-if="isInstallingUpdate" class="shrink-0" disabled><Loader2 class="h-4 w-4 animate-spin" />diff --git a/apps/desktop/src/composables/__tests__/useAppUpdater.spec.ts b/apps/desktop/src/composables/__tests__/useAppUpdater.spec.tsindex bea37ce004..97bb027468 100644--- a/apps/desktop/src/composables/__tests__/useAppUpdater.spec.ts+++ b/apps/desktop/src/composables/__tests__/useAppUpdater.spec.ts@@ -2,7 +2,7 @@import { createApp, defineComponent, h, reactive, nextTick, type App } from "vue";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import i18n from "@/i18n";-import { effectiveUpdateInfo, isNewerRemoteVersion, resolveReleaseTagUrl, useAppUpdater } from "@/composables/useAppUpdater";+import { effectiveUpdateInfo, isNewerRemoteVersion, isPreparedUpdateObsolete, resolveReleaseTagUrl, useAppUpdater } from "@/composables/useAppUpdater";const mocks = vi.hoisted(() => ({checkForUpdates: vi.fn(),downloadUpdate: vi.fn(),@@ -90,6 +90,16 @@ describe("older version release pages", () => {});});+describe("prepared update reconciliation (#13562)", () => {+ it("treats a package the running build already satisfies as obsolete", () => {+ expect(isPreparedUpdateObsolete("0.5.60", "0.5.60")).toBe(true);+ expect(isPreparedUpdateObsolete("0.5.59", "v0.5.60")).toBe(true);+ expect(isPreparedUpdateObsolete("0.5.61", "0.5.60")).toBe(false);+ expect(isPreparedUpdateObsolete("", "0.5.60")).toBe(false);+ expect(isPreparedUpdateObsolete("0.5.61", "")).toBe(false);+ });+});+describe("silent update lifecycle", () => {it("does not check or download updates when disabled for an isolated dev client", async () => {vi.stubEnv("VITE_DBX_DISABLE_UPDATER", "1");@@ -467,6 +477,35 @@ describe("silent update lifecycle", () => {expect(updater.phase.value).toBe("ready");});+ it("discards a prepared package the running build already satisfies", async () => {+ mocks.getDownloadedUpdate.mockResolvedValue(cache);+ mocks.getAppVersion.mockResolvedValue("1.1.0");+ mocks.checkForUpdates.mockResolvedValue({ ...info, current_version: "1.1.0", latest_version: "1.1.0", update_available: false });+ const updater = mount();+ await updater.initialize();+ await flush();++ expect(mocks.discardDownloadedUpdate).toHaveBeenCalledWith("cached");+ expect(updater.updateDownloaded.value).toBe(false);+ expect(updater.hasUpdateAvailable.value).toBe(false);+ expect(updater.updateInfo.value?.update_available).toBe(false);+ expect(updater.phase.value).toBe("idle");+ });++ it("keeps a prepared package installable when the remote stops advertising it", async () => {+ mocks.getDownloadedUpdate.mockResolvedValue({ ...cache, version: "1.2.0" });+ mocks.checkForUpdates.mockResolvedValue({ ...info, latest_version: "1.1.0", update_available: false });+ const updater = mount();+ await updater.initialize();+ await flush();++ expect(mocks.discardDownloadedUpdate).not.toHaveBeenCalled();+ expect(updater.updateDownloaded.value).toBe(true);+ expect(updater.updateDownloadedVersion.value).toBe("1.2.0");+ expect(updater.updateInfo.value?.latest_version).toBe("1.1.0");+ expect(updater.phase.value).toBe("ready");+ });+it("does not disturb an installation that starts while a recheck is in flight", async () => {mocks.getDownloadedUpdate.mockResolvedValue(cache);const gate = deferred<typeof info>();diff --git a/apps/desktop/src/composables/useAppUpdater.ts b/apps/desktop/src/composables/useAppUpdater.tsindex 83d7bf9636..6bccabe2f7 100644--- a/apps/desktop/src/composables/useAppUpdater.ts+++ b/apps/desktop/src/composables/useAppUpdater.ts@@ -99,6 +99,18 @@ export function isNewerRemoteVersion(latest: string, cached: string): boolean {return compareParsedUpdateVersions(parsedLatest, parsedCached) > 0;}+/**+ * A prepared package only stays meaningful while it is newer than the running+ * build. Replacing the app outside this process (manual DMG/installer upgrade,+ * or a bundle swapped by an external updater) leaves the old package in the+ * update cache, and the badge then advertises a version the app already runs+ * (#13562). An unknown version is never treated as obsolete.+ */+export function isPreparedUpdateObsolete(preparedVersion: string, currentVersion: string): boolean {+ if (!preparedVersion || !currentVersion) return false;+ return !isNewerRemoteVersion(preparedVersion, currentVersion);+}+export function normalizeUpdateDownloadSource(value: unknown): SettingsUpdateDownloadSource {// Old persisted AtomGit preferences should retain their mainland mirror behavior.if (value === "atomgit") return "cnb";@@ -157,6 +169,7 @@ export function useAppUpdater(options: UseAppUpdaterOptions = {}) {const checkingUpdates = computed(() => phase.value === "checking");const isDownloadingUpdate = computed(() => phase.value === "downloading");const updateDownloaded = computed(() => downloaded.value !== null);+ const updateDownloadedVersion = computed(() => downloaded.value?.version ?? "");const isPreparingUpdate = computed(() => phase.value === "preparing");const isInstallingUpdate = computed(() => phase.value === "installing" || isPreparingUpdate.value);const updateReady = computed(() => phase.value === "restart");@@ -268,7 +281,19 @@ export function useAppUpdater(options: UseAppUpdaterOptions = {}) {// Installation may have started while the check was in flight; only restore// the phase this check itself owns.if (phase.value === "checking") phase.value = downloaded.value ? "ready" : "idle";- if (!info.update_available) updateCheckMessage.value = t("updates.upToDate", { version: info.current_version });+ if (!info.update_available) {+ updateCheckMessage.value = t("updates.upToDate", { version: info.current_version });+ // The remote no longer offers a newer release, but a package from an+ // earlier download can still sit in the cache. Drop it once the running+ // build already satisfies it, otherwise the update badge never clears+ // and the dialog claims an update is downloaded with no way to install+ // it (#13562).+ const prepared = downloaded.value;+ if (prepared && isPreparedUpdateObsolete(prepared.version, info.current_version)) {+ await discardSupersededUpdate(prepared);+ if (token !== generation || disposed) return;+ }+ }if (canDownloadAndInstallUpdate(info, isTauriRuntime()) && !isUpdateIgnored(info, settingsStore.editorSettings.ignoredUpdateVersion)) {const cached = downloaded.value;if (cached && !isNewerRemoteVersion(info.latest_version, cached.version)) {@@ -478,6 +503,12 @@ export function useAppUpdater(options: UseAppUpdaterOptions = {}) {else {setDownloaded(cache);updateInfo.value!.current_version = await api.getAppVersion();+ // An upgrade that happened outside this process leaves the previous+ // package in the cache. Adopting it would pin the dialog to "already+ // up to date" while still advertising a downloaded update (#13562).+ if (isPreparedUpdateObsolete(cache.version, updateInfo.value!.current_version)) {+ await discardSupersededUpdate(cache);+ }}}} catch (error) {@@ -547,6 +578,7 @@ export function useAppUpdater(options: UseAppUpdaterOptions = {}) {isDownloadingUpdate,downloadProgress,updateDownloaded,+ updateDownloadedVersion,isInstallingUpdate,isPreparingUpdate,updateReady,