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): stop silent app-update checks when the toolbar entry is hidden (#11059)
弈秋b9563ee439b6
diff --git a/apps/desktop/src/composables/__tests__/useAppUpdater.spec.ts b/apps/desktop/src/composables/__tests__/useAppUpdater.spec.tsindex a625d7448c..b056ef440d 100644--- a/apps/desktop/src/composables/__tests__/useAppUpdater.spec.ts+++ b/apps/desktop/src/composables/__tests__/useAppUpdater.spec.ts@@ -21,7 +21,7 @@ vi.mock("@/lib/backend/tauriRuntime", () => ({ isTauriRuntime: () => true }));vi.mock("@tauri-apps/api/event", () => ({ listen: mocks.listen }));vi.mock("@tauri-apps/plugin-process", () => ({ relaunch: mocks.relaunch }));vi.mock("@/composables/useToast", () => ({ useToast: () => ({ toast: mocks.toast }) }));-const settings = reactive({ updateDownloadSource: "official", ignoredUpdateVersion: "", updateNotificationsEnabled: true, autoDownloadUpdates: true, autoUpdateApp: true });+const settings = reactive({ updateDownloadSource: "official", ignoredUpdateVersion: "", updateNotificationsEnabled: true, autoDownloadUpdates: true, autoUpdateApp: true, toolbarItems: { checkUpdates: true } });vi.mock("@/stores/settingsStore", () => ({ useSettingsStore: () => ({ editorSettings: settings, updateEditorSettingsAndPersist: mocks.persist }) }));const info = { current_version: "1.0.0", latest_version: "1.1.0", update_available: true, portable_mode: false, manual_update_only: false, release_name: "v1.1.0", release_url: "https://example.com", release_notes: "Changes" };const cache = { cache_id: "cached", version: "1.1.0", portable_mode: false, release_url: "https://example.com", release_notes: "Changes", downloaded_at: 1 };@@ -61,6 +61,7 @@ beforeEach(() => {settings.updateNotificationsEnabled = true;settings.autoDownloadUpdates = true;settings.autoUpdateApp = true;+ settings.toolbarItems.checkUpdates = true;mocks.checkForUpdates.mockResolvedValue(info);mocks.downloadUpdate.mockResolvedValue(cache);mocks.getDownloadedUpdate.mockResolvedValue(null);@@ -494,3 +495,67 @@ describe("silent update lifecycle", () => {expect(updater.updateCheckMessage.value).toContain("file busy");});});++describe("toolbar update entry visibility (#11041)", () => {+ it("does not start an automatic download when a silent check completes after the entry is hidden", async () => {+ const pendingCheck = deferred<typeof info>();+ mocks.checkForUpdates.mockReturnValue(pendingCheck.promise);+ const updater = mount();+ await updater.initialize();+ await flush();+ expect(mocks.checkForUpdates).toHaveBeenCalledOnce();++ settings.toolbarItems.checkUpdates = false;+ await flush();+ pendingCheck.resolve(info);+ await flush();++ expect(mocks.downloadUpdate).not.toHaveBeenCalled();+ expect(updater.hasUpdateAvailable.value).toBe(false);+ });++ it("skips silent checks while the toolbar update entry is hidden", async () => {+ settings.toolbarItems.checkUpdates = false;+ const updater = mount();+ await updater.initialize();+ await flush();+ expect(mocks.checkForUpdates).not.toHaveBeenCalled();+ expect(updater.showUpdateDialog.value).toBe(false);+ });++ it("keeps the explicit check-for-updates action working while the entry is hidden", async () => {+ settings.toolbarItems.checkUpdates = false;+ const updater = mount();+ await updater.initialize();+ await flush();+ await updater.checkUpdates();+ expect(mocks.checkForUpdates).toHaveBeenCalledOnce();+ expect(updater.showUpdateDialog.value).toBe(true);+ });++ it("resumes silent checks when the entry is shown again", async () => {+ settings.toolbarItems.checkUpdates = false;+ const updater = mount();+ await updater.initialize();+ await flush();+ expect(mocks.checkForUpdates).not.toHaveBeenCalled();+ settings.toolbarItems.checkUpdates = true;+ await flush();+ expect(mocks.checkForUpdates).toHaveBeenCalledOnce();+ });++ it("stops an in-flight automatic download when the entry is hidden mid-session", async () => {+ const updater = mount();+ await updater.initialize();+ await flush();+ expect(mocks.checkForUpdates).toHaveBeenCalledOnce();+ let releaseDownload!: (value: typeof cache) => void;+ mocks.downloadUpdate.mockReturnValue(new Promise<typeof cache>((resolve) => (releaseDownload = resolve)));+ const background = updater.downloadUpdateInBackground(true);+ settings.toolbarItems.checkUpdates = false;+ await flush();+ expect(mocks.cancelUpdateDownload).toHaveBeenCalled();+ releaseDownload(cache);+ await background;+ });+});diff --git a/apps/desktop/src/composables/useAppUpdater.ts b/apps/desktop/src/composables/useAppUpdater.tsindex 0a52f3610e..f84e25045b 100644--- a/apps/desktop/src/composables/useAppUpdater.ts+++ b/apps/desktop/src/composables/useAppUpdater.ts@@ -149,11 +149,16 @@ export function useAppUpdater(options: UseAppUpdaterOptions = {}) {const updateReady = computed(() => phase.value === "restart");const activeTaskCount = computed(() => Math.max(0, Math.trunc(options.getActiveTaskCount?.() ?? 0)));const autoUpdateEnabled = computed(() => settingsStore.editorSettings.autoUpdateApp !== false);+ // Hiding the toolbar update entry opts the app out of background update+ // nagging (#11041): silent startup/hourly/retry checks stop, while the+ // explicit "Check for updates" action in settings keeps working.+ const updateEntryVisible = computed(() => settingsStore.editorSettings.toolbarItems?.checkUpdates !== false);const hasUpdateAvailable = computed(() => (updateDownloaded.value || updateReady.value || updateInfo.value?.update_available === true) && !isUpdateIgnored(updateInfo.value, settingsStore.editorSettings.ignoredUpdateVersion));const latestReleaseUrl = "https://github.com/t8y2/dbx/releases/latest";let generation = 0;let activeDownload: Promise<void> | undefined;let automaticDownload = false;+ let silentCheck = false;let cancellation: Promise<void> | undefined;let cancelOperation: Promise<void> | undefined;let retryTimer: ReturnType<typeof setTimeout> | undefined;@@ -225,12 +230,14 @@ export function useAppUpdater(options: UseAppUpdaterOptions = {}) {}async function checkUpdates(checkOptions: { silent?: boolean } = {}) {if (updaterDisabled || disposed || isIgnoringUpdate.value) return;+ if (checkOptions.silent && !updateEntryVisible.value) return;if (!checkOptions.silent) showUpdateDialog.value = true;// A downloaded-but-uninstalled update keeps the app in the ready phase; checks// continue so a newer release can replace the cached package.if (phase.value !== "idle" && phase.value !== "ready") return;clearRetry();const token = ++generation;+ silentCheck = checkOptions.silent === true;phase.value = "checking";clearError();try {@@ -488,11 +495,28 @@ export function useAppUpdater(options: UseAppUpdaterOptions = {}) {}).catch(fail);});+ // Hiding the toolbar entry mid-session must also stop background activity,+ // and re-showing it resumes the silent checks.+ const stopUpdateEntryWatch = watch(updateEntryVisible, (visible) => {+ if (disposed) return;+ if (!visible) {+ clearRetry();+ if (automaticDownload || (checkingUpdates.value && silentCheck)) void cancelDownload().catch(fail);+ return;+ }+ if (!initialized) return;+ void (cancelOperation ?? Promise.resolve())+ .then(() => {+ if (updateEntryVisible.value && !disposed) void checkUpdates({ silent: true });+ })+ .catch(fail);+ });function dispose() {disposed = true;clearRetry();clearInterval(hourlyTimer);stopSettingsWatch();+ stopUpdateEntryWatch();updatePreparationRelease?.();updatePreparationRelease = undefined;void cancelDownload().catch(() => {});