feat(updates): centralize client and component update management

This commit is contained in:
zipg authored and GitHub committed 2026-09-18 23:14:00 +08:00
1 parent 0f6db4b2c7
commit f0342ad3d9
36 files changed
+2229 -298

No files matched your search

@@ -6196,7 +6196,6 @@ async function loadSshConfigHosts() {
async function loadAgentDrivers() {
try {
agentDrivers.value = await api.listInstalledAgentsLocal();
if (!settingsStore.editorSettings.updateNotificationsEnabled) return;
api
.listInstalledAgents()
.then((drivers) => {
@@ -113,6 +113,7 @@ import { EDITOR_FONT_FAMILY_CSS_VAR, EDITOR_FONT_SIZE_CSS_VAR, createRunStatemen
import { orderAiConfigsForDisplay } from "@/lib/ai/aiConfigOrdering";
import { isAiConnectionTestConfigCurrent } from "@/lib/ai/aiConnectionTest";
import { MAX_AGENT_TURNS_DEFAULT, MAX_AGENT_TURNS_MAX, MAX_AGENT_TURNS_MIN, maxAgentTurnsOutOfRange, normalizeMaxAgentTurns } from "@/lib/ai/maxAgentTurns";
import type { DriverStoreTab } from "@/lib/connection/agentDriverInstallHint";
import ThemeCustomizerDialog from "./ThemeCustomizerDialog.vue";
import DataGridTypeColorSchemeDialog from "@/components/grid/DataGridTypeColorSchemeDialog.vue";
import { DATA_GRID_TYPE_COLOR_SCHEME_AUTO_ID, cloneDataGridTypeColorSchemes, type DataGridTypeColorScheme } from "@/lib/dataGrid/dataGridTypeColorScheme";
@@ -383,14 +384,60 @@ const props = defineProps<{
aiConfigRequestId?: number;
appVersion?: string;
checkingUpdates?: boolean;
updatingAllUpdates?: boolean;
appUpdateAvailable?: boolean;
appUpdateVersion?: string;
driverUpdateCount?: number;
jdbcUpdateAvailable?: boolean;
mcpUpdateAvailable?: boolean;
pluginUpdateCount?: number;
}>();
const emit = defineEmits<{
"update:open": [value: boolean];
"check-updates": [];
"update-all": [];
"open-driver-store": [target?: DriverStoreTab];
"open-plugin-center": [];
"open-mcp-settings": [];
"open-update-center": [];
"ai-config-deep-link-handled": [];
}>();
const hasAnyUpdate = computed(() => Boolean(props.appUpdateAvailable || (props.driverUpdateCount || 0) > 0 || props.jdbcUpdateAvailable || props.mcpUpdateAvailable || (props.pluginUpdateCount || 0) > 0));
const updateCheckItemKeys = ["app", "drivers", "jdbc", "mcp", "plugins"] as const;
type UpdateCheckItem = (typeof updateCheckItemKeys)[number];
const updateCheckLoading = ref<Record<UpdateCheckItem, boolean>>({ app: false, drivers: false, jdbc: false, mcp: false, plugins: false });
let updateCheckRevealTimers: ReturnType<typeof setTimeout>[] = [];
let updateCheckWasActive = false;
watch(
() => props.checkingUpdates,
(checking) => {
for (const timer of updateCheckRevealTimers) clearTimeout(timer);
updateCheckRevealTimers = [];
if (checking) {
updateCheckWasActive = true;
for (const key of updateCheckItemKeys) updateCheckLoading.value[key] = true;
return;
}
if (!updateCheckWasActive) return;
updateCheckWasActive = false;
updateCheckItemKeys.forEach((key, index) => {
updateCheckRevealTimers.push(
setTimeout(() => {
updateCheckLoading.value[key] = false;
}, index * 120),
);
});
},
{ immediate: true },
);
onUnmounted(() => {
for (const timer of updateCheckRevealTimers) clearTimeout(timer);
});
const isSettingsPage = computed(() => props.variant === "page");
const settingsVisible = computed(() => isSettingsPage.value || props.open === true);
const settingsRootComponent = computed(() => (isSettingsPage.value ? "div" : Dialog));
@@ -688,8 +735,11 @@ const tableHoverLookupModeDescription = computed(() => {
return t(key);
});
const editClickTableNavigationTarget = ref<ClickTableNavigationTarget>(settingsStore.editorSettings.clickTableNavigationTarget);
const editUpdateNotificationsEnabled = ref(settingsStore.editorSettings.updateNotificationsEnabled);
const editAutoDownloadUpdates = ref(settingsStore.editorSettings.autoDownloadUpdates);
const editAutoUpdateApp = ref(settingsStore.editorSettings.autoUpdateApp);
const editAutoUpdateDrivers = ref(settingsStore.editorSettings.autoUpdateDrivers);
const editAutoUpdateJdbc = ref(settingsStore.editorSettings.autoUpdateJdbc);
const editAutoUpdateMcp = ref(settingsStore.editorSettings.autoUpdateMcp);
const editAutoUpdatePlugins = ref(settingsStore.editorSettings.autoUpdatePlugins);
const editSidebarHiddenTablePrefixes = ref(settingsStore.editorSettings.sidebarHiddenTablePrefixes.join("\n"));
const editSidebarCopyTableNameSeparator = ref<ColumnNameCopySeparator>(settingsStore.editorSettings.sidebarCopyTableNameSeparator);
const editSidebarCopyTableNameIncludeSchema = ref(settingsStore.editorSettings.sidebarCopyTableNameIncludeSchema);
@@ -920,8 +970,13 @@ function currentEditorSettingsDraft(): EditorSettingsDraft {
formatSqlOnSqlFileSave: editFormatSqlOnSqlFileSave.value,
showTableDdlHoverPreview: editShowTableDdlHoverPreview.value,
tableHoverLookupMode: editTableHoverLookupMode.value,
updateNotificationsEnabled: editUpdateNotificationsEnabled.value,
autoDownloadUpdates: editAutoDownloadUpdates.value,
updateNotificationsEnabled: editAutoUpdateApp.value,
autoDownloadUpdates: editAutoUpdateApp.value,
autoUpdateApp: editAutoUpdateApp.value,
autoUpdateDrivers: editAutoUpdateDrivers.value,
autoUpdateJdbc: editAutoUpdateJdbc.value,
autoUpdateMcp: editAutoUpdateMcp.value,
autoUpdatePlugins: editAutoUpdatePlugins.value,
sidebarObjectInfoMode: editSidebarObjectInfoMode.value,
sidebarAllowHorizontalScroll: editSidebarAllowHorizontalScroll.value,
sidebarShowTooltips: editSidebarShowTooltips.value,
@@ -1555,8 +1610,11 @@ function syncEditorSettingsDraftFromStore() {
editShowTableDdlHoverPreview.value = settingsStore.editorSettings.showTableDdlHoverPreview;
editTableHoverLookupMode.value = settingsStore.editorSettings.tableHoverLookupMode;
editClickTableNavigationTarget.value = settingsStore.editorSettings.clickTableNavigationTarget;
editUpdateNotificationsEnabled.value = settingsStore.editorSettings.updateNotificationsEnabled;
editAutoDownloadUpdates.value = settingsStore.editorSettings.autoDownloadUpdates;
editAutoUpdateApp.value = settingsStore.editorSettings.autoUpdateApp;
editAutoUpdateDrivers.value = settingsStore.editorSettings.autoUpdateDrivers;
editAutoUpdateJdbc.value = settingsStore.editorSettings.autoUpdateJdbc;
editAutoUpdateMcp.value = settingsStore.editorSettings.autoUpdateMcp;
editAutoUpdatePlugins.value = settingsStore.editorSettings.autoUpdatePlugins;
editSidebarHiddenTablePrefixes.value = settingsStore.editorSettings.sidebarHiddenTablePrefixes.join("\n");
editSidebarCopyTableNameSeparator.value = settingsStore.editorSettings.sidebarCopyTableNameSeparator;
editSidebarCopyTableNameIncludeSchema.value = settingsStore.editorSettings.sidebarCopyTableNameIncludeSchema;
@@ -1676,8 +1734,13 @@ const editorSettingsDraftRefs: EditorSettingsDraftRefMap = {
formatSqlOnSqlFileSave: editFormatSqlOnSqlFileSave,
showTableDdlHoverPreview: editShowTableDdlHoverPreview,
tableHoverLookupMode: editTableHoverLookupMode,
updateNotificationsEnabled: editUpdateNotificationsEnabled,
autoDownloadUpdates: editAutoDownloadUpdates,
updateNotificationsEnabled: editAutoUpdateApp,
autoDownloadUpdates: editAutoUpdateApp,
autoUpdateApp: editAutoUpdateApp,
autoUpdateDrivers: editAutoUpdateDrivers,
autoUpdateJdbc: editAutoUpdateJdbc,
autoUpdateMcp: editAutoUpdateMcp,
autoUpdatePlugins: editAutoUpdatePlugins,
sidebarObjectInfoMode: editSidebarObjectInfoMode,
sidebarAllowHorizontalScroll: editSidebarAllowHorizontalScroll,
sidebarShowTooltips: editSidebarShowTooltips,
@@ -2164,10 +2227,13 @@ function resetDefaultsForTab(tab: SettingsCategory) {
editShortcuts.value = normalizeShortcutSettings(DEFAULT_EDITOR_SETTINGS.shortcuts);
} else if (tab === "snippets") {
editSnippets.value = DEFAULT_SQL_SNIPPETS.map((s) => ({ ...s }));
} else if (tab === "about") {
} else if (tab === "updates") {
editAutoUpdateApp.value = DEFAULT_EDITOR_SETTINGS.autoUpdateApp;
editAutoUpdateDrivers.value = DEFAULT_EDITOR_SETTINGS.autoUpdateDrivers;
editAutoUpdateJdbc.value = DEFAULT_EDITOR_SETTINGS.autoUpdateJdbc;
editAutoUpdateMcp.value = DEFAULT_EDITOR_SETTINGS.autoUpdateMcp;
editAutoUpdatePlugins.value = DEFAULT_EDITOR_SETTINGS.autoUpdatePlugins;
editUpdateDownloadSource.value = DEFAULT_EDITOR_SETTINGS.updateDownloadSource;
editUpdateNotificationsEnabled.value = DEFAULT_EDITOR_SETTINGS.updateNotificationsEnabled;
editAutoDownloadUpdates.value = DEFAULT_EDITOR_SETTINGS.autoDownloadUpdates;
}
}
@@ -2266,8 +2332,11 @@ function resetAllDefaults() {
editFormatSqlOnSqlFileSave.value = DEFAULT_EDITOR_SETTINGS.formatSqlOnSqlFileSave;
editShowTableDdlHoverPreview.value = DEFAULT_EDITOR_SETTINGS.showTableDdlHoverPreview;
editTableHoverLookupMode.value = DEFAULT_EDITOR_SETTINGS.tableHoverLookupMode;
editUpdateNotificationsEnabled.value = DEFAULT_EDITOR_SETTINGS.updateNotificationsEnabled;
editAutoDownloadUpdates.value = DEFAULT_EDITOR_SETTINGS.autoDownloadUpdates;
editAutoUpdateApp.value = DEFAULT_EDITOR_SETTINGS.autoUpdateApp;
editAutoUpdateDrivers.value = DEFAULT_EDITOR_SETTINGS.autoUpdateDrivers;
editAutoUpdateJdbc.value = DEFAULT_EDITOR_SETTINGS.autoUpdateJdbc;
editAutoUpdateMcp.value = DEFAULT_EDITOR_SETTINGS.autoUpdateMcp;
editAutoUpdatePlugins.value = DEFAULT_EDITOR_SETTINGS.autoUpdatePlugins;
editSidebarObjectInfoMode.value = DEFAULT_EDITOR_SETTINGS.sidebarObjectInfoMode;
editSidebarAllowHorizontalScroll.value = DEFAULT_EDITOR_SETTINGS.sidebarAllowHorizontalScroll;
editSidebarShowTooltips.value = DEFAULT_EDITOR_SETTINGS.sidebarShowTooltips;
@@ -2689,10 +2758,11 @@ const settingsCategoryNav = computed<{ value: SettingsCategory; label: string }[
{ value: "sync", label: t("settings.syncTab") },
{ value: "ai", label: t("settings.aiTab") },
{ value: "mcp" as const, label: t("settings.mcpTab") },
{ value: "updates" as const, label: t("settings.updatesTab") },
...(isWeb ? [{ value: "security" as const, label: t("settings.securityTab") }] : []),
{ value: "about", label: t("settings.aboutTab") },
]);
const settingsTabsWithApplyFooter = new Set<SettingsCategory>(["editor", "formatter", "appearance", "navigation", "data", "shortcuts", "snippets"]);
const settingsTabsWithApplyFooter = new Set<SettingsCategory>(["editor", "formatter", "appearance", "navigation", "data", "shortcuts", "snippets", "updates"]);
function hasSettingsApplyFooter(value: SettingsCategory): boolean {
return settingsTabsWithApplyFooter.has(value);
@@ -9860,6 +9930,111 @@ LIMIT 100;</pre
</Tabs>
</section>
<section v-else-if="activeSettingsTab === 'updates'" data-settings-search-id="updates" :class="['flex flex-col gap-5 py-2', settingsSearchTargetClass('updates')]">
<div class="space-y-3 rounded-lg border bg-muted/20 p-4">
<div class="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
<div class="min-w-0 space-y-1">
<Label>{{ t("settings.updateStatusTitle") }}</Label>
<p class="text-sm text-muted-foreground">{{ t("settings.updateStatusDescription") }}</p>
</div>
<div class="flex shrink-0 items-center gap-2">
<Button type="button" variant="outline" size="sm" class="h-8 min-w-20" :disabled="props.checkingUpdates || props.updatingAllUpdates" :aria-label="t('settings.checkUpdates')" @click="emit('check-updates')">
<Loader2 v-if="props.checkingUpdates" class="h-3.5 w-3.5 animate-spin" />
<span v-else>{{ t("settings.checkUpdates") }}</span>
</Button>
<Button v-if="hasAnyUpdate" type="button" size="sm" class="h-8" :disabled="props.checkingUpdates || props.updatingAllUpdates" @click="emit('update-all')">
<Loader2 v-if="props.updatingAllUpdates" class="h-3.5 w-3.5 animate-spin" />
<RefreshCw v-else class="h-3.5 w-3.5" />
{{ t("settings.updateAll") }}
</Button>
</div>
</div>
<div class="grid gap-2 sm:grid-cols-2">
<div class="flex items-center justify-between gap-3 rounded-md border bg-background px-3 py-2.5 text-sm">
<button type="button" class="min-w-0 space-y-0.5 rounded-sm text-left transition-colors hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50" @click="emit('open-update-center')">
<div class="font-medium">{{ t("settings.updateClient") }}</div>
<div class="flex items-center gap-1.5" :class="updateCheckLoading.app ? 'text-muted-foreground' : props.appUpdateAvailable ? 'text-primary' : 'text-muted-foreground'">
<Loader2 v-if="updateCheckLoading.app" class="h-3 w-3 animate-spin" />
<span>{{ updateCheckLoading.app ? t("updates.checking") : props.appUpdateAvailable ? props.appUpdateVersion || t("settings.updateAvailable") : t("settings.upToDate") }}</span>
</div>
</button>
<div class="flex shrink-0 items-center gap-2">
<Label for="auto-update-app" class="text-xs font-normal text-muted-foreground">{{ t("settings.autoUpdate") }}</Label>
<Switch id="auto-update-app" v-model="editAutoUpdateApp" :aria-label="t('settings.autoUpdateApp')" />
</div>
</div>
<div class="flex items-center justify-between gap-3 rounded-md border bg-background px-3 py-2.5 text-sm">
<button type="button" class="min-w-0 space-y-0.5 rounded-sm text-left transition-colors hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50" @click="emit('open-driver-store', 'agent')">
<div class="font-medium">{{ t("settings.updateDrivers") }}</div>
<div class="flex items-center gap-1.5" :class="updateCheckLoading.drivers ? 'text-muted-foreground' : (props.driverUpdateCount || 0) > 0 ? 'text-primary' : 'text-muted-foreground'">
<Loader2 v-if="updateCheckLoading.drivers" class="h-3 w-3 animate-spin" />
<span>{{ updateCheckLoading.drivers ? t("updates.checking") : (props.driverUpdateCount || 0) > 0 ? t("settings.updateCount", { count: props.driverUpdateCount }) : t("settings.upToDate") }}</span>
</div>
</button>
<div class="flex shrink-0 items-center gap-2">
<Label for="auto-update-drivers" class="text-xs font-normal text-muted-foreground">{{ t("settings.autoUpdate") }}</Label>
<Switch id="auto-update-drivers" v-model="editAutoUpdateDrivers" :aria-label="t('settings.autoUpdateDrivers')" />
</div>
</div>
<div class="flex items-center justify-between gap-3 rounded-md border bg-background px-3 py-2.5 text-sm">
<button type="button" class="min-w-0 space-y-0.5 rounded-sm text-left transition-colors hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50" @click="emit('open-driver-store', 'jdbc')">
<div class="font-medium">{{ t("settings.updateJdbc") }}</div>
<div class="flex items-center gap-1.5" :class="updateCheckLoading.jdbc ? 'text-muted-foreground' : props.jdbcUpdateAvailable ? 'text-primary' : 'text-muted-foreground'">
<Loader2 v-if="updateCheckLoading.jdbc" class="h-3 w-3 animate-spin" />
<span>{{ updateCheckLoading.jdbc ? t("updates.checking") : props.jdbcUpdateAvailable ? t("settings.updateAvailable") : t("settings.upToDate") }}</span>
</div>
</button>
<div class="flex shrink-0 items-center gap-2">
<Label for="auto-update-jdbc" class="text-xs font-normal text-muted-foreground">{{ t("settings.autoUpdate") }}</Label>
<Switch id="auto-update-jdbc" v-model="editAutoUpdateJdbc" :aria-label="t('settings.autoUpdateJdbc')" />
</div>
</div>
<div class="flex items-center justify-between gap-3 rounded-md border bg-background px-3 py-2.5 text-sm">
<button type="button" class="min-w-0 space-y-0.5 rounded-sm text-left transition-colors hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50" @click="emit('open-mcp-settings')">
<div class="font-medium">{{ t("settings.updateMcp") }}</div>
<div class="flex items-center gap-1.5" :class="updateCheckLoading.mcp ? 'text-muted-foreground' : props.mcpUpdateAvailable ? 'text-primary' : 'text-muted-foreground'">
<Loader2 v-if="updateCheckLoading.mcp" class="h-3 w-3 animate-spin" />
<span>{{ updateCheckLoading.mcp ? t("updates.checking") : props.mcpUpdateAvailable ? t("settings.updateAvailable") : t("settings.upToDate") }}</span>
</div>
</button>
<div class="flex shrink-0 items-center gap-2">
<Label for="auto-update-mcp" class="text-xs font-normal text-muted-foreground">{{ t("settings.autoUpdate") }}</Label>
<Switch id="auto-update-mcp" v-model="editAutoUpdateMcp" :aria-label="t('settings.autoUpdateMcp')" />
</div>
</div>
<div class="flex items-center justify-between gap-3 rounded-md border bg-background px-3 py-2.5 text-sm">
<button type="button" class="min-w-0 space-y-0.5 rounded-sm text-left transition-colors hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50" @click="emit('open-plugin-center')">
<div class="font-medium">{{ t("settings.updatePlugins") }}</div>
<div class="flex items-center gap-1.5" :class="updateCheckLoading.plugins ? 'text-muted-foreground' : (props.pluginUpdateCount || 0) > 0 ? 'text-primary' : 'text-muted-foreground'">
<Loader2 v-if="updateCheckLoading.plugins" class="h-3 w-3 animate-spin" />
<span>{{ updateCheckLoading.plugins ? t("updates.checking") : (props.pluginUpdateCount || 0) > 0 ? t("settings.updateCount", { count: props.pluginUpdateCount }) : t("settings.upToDate") }}</span>
</div>
</button>
<div class="flex shrink-0 items-center gap-2">
<Label for="auto-update-plugins" class="text-xs font-normal text-muted-foreground">{{ t("settings.autoUpdate") }}</Label>
<Switch id="auto-update-plugins" v-model="editAutoUpdatePlugins" :aria-label="t('settings.autoUpdatePlugins')" />
</div>
</div>
</div>
<p class="border-t pt-3 text-xs text-muted-foreground">{{ t("settings.updateRestartHint") }}</p>
</div>
<div class="flex flex-col gap-3 rounded-lg border p-4 sm:flex-row sm:items-center sm:justify-between">
<div class="min-w-0 space-y-1">
<Label>{{ t("settings.updateDownloadSource") }}</Label>
<p class="text-sm text-muted-foreground">{{ t("settings.updateDownloadSourceDescription") }}</p>
</div>
<Select :model-value="editUpdateDownloadSource" @update:model-value="onUpdateDownloadSourceChange">
<SelectTrigger class="h-9 w-full sm:w-[180px]"><SelectValue /></SelectTrigger>
<SelectContent>
<SelectItem value="official">{{ t("settings.updateDownloadSourceOfficial") }}</SelectItem>
<SelectItem value="cnb">{{ t("settings.updateDownloadSourceCnb") }}</SelectItem>
</SelectContent>
</Select>
</div>
<ChangelogPanel :checking-updates="props.checkingUpdates" @check-updates="emit('check-updates')" />
</section>
<section v-else-if="activeSettingsTab === 'security' && isWeb" data-settings-search-id="security" :class="['flex flex-col gap-5 py-2', settingsSearchTargetClass('security')]">
<div class="space-y-3">
<Label class="text-base">{{ t("auth.changePassword") }}</Label>
@@ -9959,46 +10134,6 @@ LIMIT 100;</pre
</div>
</div>
<div class="settings-item flex flex-col gap-4 rounded-lg border p-4">
<div class="flex items-center justify-between gap-4">
<div class="min-w-0 space-y-1">
<Label for="update-notifications-enabled">{{ t("settings.updateNotificationsEnabled") }}</Label>
<p class="text-sm text-muted-foreground">
{{ t("settings.updateNotificationsEnabledDescription") }}
</p>
</div>
<Switch id="update-notifications-enabled" v-model="editUpdateNotificationsEnabled" />
</div>
<div class="flex items-center justify-between gap-4">
<div class="min-w-0 space-y-1">
<Label for="auto-download-updates">{{ t("settings.autoDownloadUpdates") }}</Label>
<p class="text-sm text-muted-foreground">
{{ t("settings.autoDownloadUpdatesDescription") }}
</p>
</div>
<Switch id="auto-download-updates" v-model="editAutoDownloadUpdates" />
</div>
<div class="flex flex-col gap-3 border-t border-border/60 pt-4 sm:flex-row sm:items-center sm:justify-between">
<div class="min-w-0 space-y-1">
<Label>{{ t("settings.updateDownloadSource") }}</Label>
<p class="text-sm text-muted-foreground">
{{ t("settings.updateDownloadSourceDescription") }}
</p>
</div>
<Select :model-value="editUpdateDownloadSource" @update:model-value="onUpdateDownloadSourceChange">
<SelectTrigger class="h-9 w-full sm:w-[180px]">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="official">{{ t("settings.updateDownloadSourceOfficial") }}</SelectItem>
<SelectItem value="cnb">{{ t("settings.updateDownloadSourceCnb") }}</SelectItem>
</SelectContent>
</Select>
</div>
</div>
<ChangelogPanel :checking-updates="props.checkingUpdates" @check-updates="emit('check-updates')" />
<div class="grid gap-3 sm:grid-cols-3">
<button type="button" class="rounded-lg border p-4 text-left transition-colors hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring" @click="openExternalUrl('https://qm.qq.com/cgi-bin/qm/qr?k=&group_code=1087880322')">
<div class="flex items-center gap-2 text-sm font-medium">
@@ -622,9 +622,21 @@ const toolbarStyle = computed(() => {
<template v-if="toolbarItems.checkUpdates">
<Tooltip>
<TooltipTrigger as-child>
<Button v-show="isRightItemVisible('checkUpdates')" data-toolbar-update-trigger variant="ghost" size="icon" class="toolbar-action-button relative h-8 w-8 shrink-0" @click="emit('check-updates')">
<ToolbarUpdateIcon />
<span v-if="hasUpdateAvailable" class="absolute right-1.5 top-1.5 h-2 w-2 rounded-full bg-red-500 ring-2 ring-background" />
<Button
v-show="isRightItemVisible('checkUpdates')"
data-toolbar-update-trigger
:data-toolbar-update-action="hasUpdateAvailable ? '' : undefined"
:variant="hasUpdateAvailable ? 'default' : 'ghost'"
:size="hasUpdateAvailable ? 'sm' : 'icon'"
class="toolbar-action-button shrink-0"
:class="hasUpdateAvailable ? 'h-7 gap-1.5 px-2 text-xs' : 'relative h-8 w-8'"
@click="emit('check-updates')"
>
<template v-if="hasUpdateAvailable">
<CloudDownload class="h-3.5 w-3.5" />
<span>{{ t("updates.updateAction") }}</span>
</template>
<ToolbarUpdateIcon v-else :available="false" />
</Button>
</TooltipTrigger>
<TooltipContent>{{ updateTooltip }}</TooltipContent>
@@ -1,11 +1,11 @@
<script setup lang="ts">
import { CloudDownload } from "@lucide/vue";
// Background checking/downloading deliberately never animates the toolbar.
defineProps<{ loading?: boolean; downloading?: boolean; progress?: number | null }>();
defineProps<{ loading?: boolean; downloading?: boolean; progress?: number | null; available?: boolean }>();
</script>
<template>
<span data-toolbar-update-icon class="relative block h-4 w-4" aria-hidden="true">
<CloudDownload data-toolbar-update-idle class="h-4 w-4" />
<CloudDownload data-toolbar-update-idle class="h-4 w-4" :class="available ? 'text-primary' : undefined" />
</span>
</template>
+93 -6
View File
@@ -5,8 +5,10 @@ import { afterEach, describe, expect, it, vi } from "vitest";
import i18n from "@/i18n";
import UpdateDialog from "@/components/layout/UpdateDialog.vue";
const runtimeState = vi.hoisted(() => ({ tauri: true }));
vi.mock("@/lib/backend/tauriRuntime", () => ({
isTauriRuntime: () => true,
isTauriRuntime: () => runtimeState.tauri,
}));
const mountedApps: App[] = [];
@@ -29,7 +31,7 @@ async function flushDialog() {
await new Promise((resolve) => setTimeout(resolve, 0));
}
async function mountDialog(activeTaskCount: number, initialState: Partial<DialogState> = {}, installDownloaded = vi.fn(async () => {})) {
async function mountDialog(activeTaskCount: number, initialState: Partial<DialogState> = {}, installDownloaded = vi.fn(async () => {}), extraProps: Record<string, unknown> = {}) {
const state = reactive<DialogState>({
open: true,
portableMode: false,
@@ -91,6 +93,7 @@ async function mountDialog(activeTaskCount: number, initialState: Partial<Dialog
updateReady: state.updateReady,
isIgnoringUpdate: state.isIgnoringUpdate,
activeTaskCount,
...extraProps,
"onDownload-in-background": downloadInBackground,
"onCancel-download": cancelDownload,
"onInstall-downloaded": handleInstallDownloaded,
@@ -134,10 +137,25 @@ async function clickOutside() {
}
afterEach(() => {
runtimeState.tauri = true;
for (const app of mountedApps.splice(0)) app.unmount();
document.body.innerHTML = "";
});
describe("UpdateDialog web runtime", () => {
it("keeps web updates as Docker instructions without desktop install controls", async () => {
runtimeState.tauri = false;
await mountDialog(0);
expect(document.body.textContent).toContain("Docker users should run");
expect(document.body.textContent).toContain("docker compose pull && docker compose up -d");
expect(buttonWithText("Open Release")).toBeDefined();
expect(downloadButton()).toBeUndefined();
expect(installDownloadedButton()).toBeUndefined();
});
});
describe("UpdateDialog active task guard", () => {
it("shows the task warning but still allows starting a background download while work is running", async () => {
await mountDialog(2);
@@ -252,7 +270,6 @@ describe("UpdateDialog close protection", () => {
it("allows closing while a downloaded update is idle", async () => {
const { state } = await mountDialog(0, { updateDownloaded: true, downloadProgress: 100 });
expect(buttonWithText("Cancel")).toBeDefined();
expect(document.body.querySelector('[data-slot="dialog-close"]')).not.toBeNull();
await pressEscape();
@@ -262,7 +279,6 @@ describe("UpdateDialog close protection", () => {
it("prevents closing while installation is in progress", async () => {
const { state } = await mountDialog(0, { updateDownloaded: true, isInstallingUpdate: true });
expect(buttonWithText("Cancel")).toBeUndefined();
expect(document.body.querySelector('[data-slot="dialog-close"]')).toBeNull();
await pressEscape();
@@ -286,7 +302,7 @@ describe("UpdateDialog close protection", () => {
rejectInstall(new Error("install failed"));
await flushDialog();
expect(buttonWithText("Cancel")).toBeDefined();
expect(document.body.querySelector('[data-slot="dialog-close"]')).not.toBeNull();
await pressEscape();
expect(state.open).toBe(false);
@@ -320,7 +336,6 @@ describe("UpdateDialog close protection", () => {
expect(state.updateDownloaded).toBe(false);
expect(state.updateReady).toBe(true);
expect(buttonWithText("Restart")).toBeDefined();
expect(buttonWithText("Cancel")).toBeDefined();
await pressEscape();
expect(state.open).toBe(false);
expect(installDownloaded).toHaveBeenCalledOnce();
@@ -363,3 +378,75 @@ describe("UpdateDialog release notes safety", () => {
expect(Array.from(document.body.querySelectorAll("a")).every((anchor) => anchor.href.startsWith("https://"))).toBe(true);
});
});
describe("UpdateDialog aggregate update center", () => {
it("keeps the client restart gated while update all is still updating components", async () => {
await mountDialog(0, { updateDownloaded: true, downloadProgress: 100 }, undefined, { isUpdatingAll: true });
expect(installDownloadedButton()?.disabled).toBe(true);
expect(buttonWithText("Ignore this version")).toBeUndefined();
});
it("disables component actions while an automatic update is active", async () => {
await mountDialog(0, {}, undefined, {
componentUpdatesUpdating: true,
driverUpdates: [{ db_type: "mysql", label: "MySQL", version: "9.0.0", installed_version: "8.0.0", update_available: true }],
});
expect(buttonWithText("Update all")?.disabled).toBe(true);
const driversTab = document.body.querySelector<HTMLButtonElement>('[data-update-tab="drivers"]');
driversTab?.dispatchEvent(new PointerEvent("pointerdown", { bubbles: true, cancelable: true }));
driversTab?.click();
await flushDialog();
expect(buttonWithText("Update Now")?.disabled).toBe(true);
});
it("organizes component updates into tabs and installs the selected category", async () => {
const installComponentUpdates = vi.fn();
const updateAll = vi.fn();
await mountDialog(0, {}, undefined, {
driverUpdates: [{ db_type: "mysql", label: "MySQL", version: "9.0.0", installed_version: "8.0.0", update_available: true }],
jdbcUpdate: { installed: true, version: "0.1.0", latest_version: "0.2.0", update_available: true, compatible: true, path: "/tmp/jdbc" },
mcpUpdate: { installed: true, npm_available: true, current_version: "1.0.0", latest_version: "1.1.0", update_available: true },
pluginUpdates: [
{
key: "official:example",
status: "update",
artifact: { target: "universal", url: "https://example.com/plugin.dbxp", sha256: "hash" },
repository: { id: "official" },
plugin: { id: "example", latestVersion: "1.1.0" },
name: "Example plugin",
},
],
"onInstall-component-updates": installComponentUpdates,
"onUpdate-all": updateAll,
});
expect(document.body.querySelector('[data-update-tab="app"]')).not.toBeNull();
expect(document.body.querySelector('[data-update-tab="drivers"]')?.textContent).toContain("Database drivers");
expect(document.body.querySelector('[data-update-tab="jdbc"]')?.textContent).toContain("JDBC");
expect(document.body.querySelector('[data-update-tab="mcp"]')?.textContent).toContain("MCP");
expect(document.body.querySelector('[data-update-tab="plugins"]')?.textContent).toContain("Plugins");
expect(document.body.querySelector<HTMLElement>("[data-update-scroll-region]")?.classList.contains("overflow-auto")).toBe(true);
expect(document.body.querySelector<HTMLElement>("[data-update-footer]")?.className).toContain("mx-0");
expect(document.body.querySelector<HTMLElement>("[data-update-footer]")?.className).toContain("px-[22px]");
expect(document.body.querySelector<HTMLElement>("[data-update-footer]")?.className).toContain("pb-2.5");
expect(document.body.querySelector<HTMLElement>("[data-update-footer]")?.className).toContain("pt-2.5");
expect(buttonWithText("Cancel")).toBeUndefined();
buttonWithText("Update all")?.click();
await flushDialog();
expect(updateAll).toHaveBeenCalledOnce();
const driversTab = document.body.querySelector<HTMLButtonElement>('[data-update-tab="drivers"]');
driversTab?.dispatchEvent(new PointerEvent("pointerdown", { bubbles: true, cancelable: true }));
driversTab?.click();
await flushDialog();
buttonWithText("Update Now")?.click();
await flushDialog();
expect(installComponentUpdates).toHaveBeenCalledWith("drivers");
});
});
@@ -1,32 +1,61 @@
<script setup lang="ts">
import { computed, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import { AlertTriangle, Loader2 } from "@lucide/vue";
import { AlertTriangle, CheckCircle2, Loader2, RefreshCw } from "@lucide/vue";
import { Button } from "@/components/ui/button";
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import type { UpdateInfo } from "@/lib/backend/api";
import type { UpdateDownloadSource } from "@/lib/backend/tauri";
import type { AgentDriverInfo, McpServerStatus, UpdateDownloadSource } from "@/lib/backend/tauri";
import type { JdbcPluginStatus } from "@/types/database";
import type { MarketplacePluginListing } from "@/lib/plugins/pluginMarketplace";
import { mcpUpdateAvailability } from "@/lib/mcp/mcpUpdateStatus";
import { isTauriRuntime } from "@/lib/backend/tauriRuntime";
import { isUpdatePreviewMockEnabled } from "@/lib/updates/updatePreviewMock";
import { canDownloadAndInstallUpdate } from "@/composables/useAppUpdater";
import type { ComponentUpdateCategory } from "@/composables/useComponentUpdates";
type UpdateTab = "app" | ComponentUpdateCategory;
const open = defineModel<boolean>("open", { required: true });
const props = defineProps<{
updateInfo: UpdateInfo | null;
updateCheckMessage: string;
isDownloadingUpdate: boolean;
downloadProgress: number | null;
updateDownloaded: boolean;
isInstallingUpdate: boolean;
isPreparingUpdate?: boolean;
updateReady: boolean;
isIgnoringUpdate: boolean;
activeTaskCount: number;
checkingUpdates: boolean;
updateCheckFailed: boolean;
updateDownloadSource: UpdateDownloadSource;
}>();
const props = withDefaults(
defineProps<{
updateInfo: UpdateInfo | null;
updateCheckMessage: string;
isDownloadingUpdate: boolean;
downloadProgress: number | null;
updateDownloaded: boolean;
isInstallingUpdate: boolean;
isPreparingUpdate?: boolean;
updateReady: boolean;
isIgnoringUpdate: boolean;
activeTaskCount: number;
checkingUpdates: boolean;
updateCheckFailed: boolean;
updateDownloadSource: UpdateDownloadSource;
driverUpdates?: AgentDriverInfo[];
jdbcUpdate?: JdbcPluginStatus | null;
mcpUpdate?: McpServerStatus | null;
pluginUpdates?: MarketplacePluginListing[];
componentUpdatesLoading?: boolean;
componentUpdatesError?: string;
componentUpdatesUpdating?: boolean;
updatingComponent?: ComponentUpdateCategory | null;
isUpdatingAll?: boolean;
}>(),
{
driverUpdates: () => [],
jdbcUpdate: null,
mcpUpdate: null,
pluginUpdates: () => [],
componentUpdatesLoading: false,
componentUpdatesError: "",
componentUpdatesUpdating: false,
updatingComponent: null,
isUpdatingAll: false,
},
);
const emit = defineEmits<{
"open-latest-release": [];
@@ -36,21 +65,49 @@ const emit = defineEmits<{
restart: [];
"ignore-version": [];
"change-download-source": [source: UpdateDownloadSource];
"install-component-updates": [category: ComponentUpdateCategory];
"update-all": [];
}>();
const { t } = useI18n();
const isDesktop = isTauriRuntime();
const isDesktop = isTauriRuntime() || isUpdatePreviewMockEnabled();
const selectedTab = ref<UpdateTab>("app");
const renderedNotes = ref("");
// Only active file replacement (installation) must trap the dialog. A background
// download survives the dialog closing, so closing it never cancels the download.
const isCloseBlocked = computed(() => props.isInstallingUpdate);
const blocksImplicitDismiss = computed(() => props.isInstallingUpdate);
const canIgnoreVersion = computed(() => props.updateInfo?.update_available === true && !props.isDownloadingUpdate && !props.isInstallingUpdate && !props.updateReady);
function handleCancel() {
handleOpenChange(false);
}
const hasAppUpdate = computed(() => props.updateDownloaded || props.updateReady || props.updateInfo?.update_available === true);
const mcpAvailable = computed(() => (props.mcpUpdate ? mcpUpdateAvailability(props.mcpUpdate) === true : false));
const tabs = computed(() => {
const available: Array<{ id: UpdateTab; label: string; count: number }> = [];
if (hasAppUpdate.value) available.push({ id: "app", label: t("settings.updateClient"), count: 1 });
if (props.driverUpdates.length) available.push({ id: "drivers", label: t("settings.updateDrivers"), count: props.driverUpdates.length });
if (props.jdbcUpdate?.update_available) available.push({ id: "jdbc", label: t("settings.updateJdbc"), count: 1 });
if (mcpAvailable.value) available.push({ id: "mcp", label: t("settings.updateMcp"), count: 1 });
if (props.pluginUpdates.length) available.push({ id: "plugins", label: t("settings.updatePlugins"), count: props.pluginUpdates.length });
return available.length ? available : [{ id: "app" as const, label: t("settings.updateClient"), count: 0 }];
});
const totalUpdateCount = computed(() => tabs.value.reduce((total, tab) => total + tab.count, 0));
const hasComponentUpdates = computed(() => props.driverUpdates.length > 0 || props.jdbcUpdate?.update_available === true || mcpAvailable.value || props.pluginUpdates.length > 0);
const selectedCategory = computed<ComponentUpdateCategory | null>(() => (selectedTab.value === "app" ? null : selectedTab.value));
const selectedCategoryHasUpdate = computed(() => {
if (selectedTab.value === "drivers") return props.driverUpdates.length > 0;
if (selectedTab.value === "jdbc") return props.jdbcUpdate?.update_available === true;
if (selectedTab.value === "mcp") return mcpAvailable.value;
if (selectedTab.value === "plugins") return props.pluginUpdates.length > 0;
return false;
});
const isUpdatingSelectedCategory = computed(() => selectedCategory.value !== null && props.updatingComponent === selectedCategory.value);
const isAnyComponentUpdating = computed(() => props.componentUpdatesUpdating || props.updatingComponent !== null);
const isCloseBlocked = computed(() => props.isInstallingUpdate || isUpdatingSelectedCategory.value);
const blocksImplicitDismiss = computed(() => isCloseBlocked.value);
const canIgnoreVersion = computed(() => props.updateInfo?.update_available === true && !props.isDownloadingUpdate && !props.isInstallingUpdate && !props.updateReady && !props.isUpdatingAll);
watch(
tabs,
(nextTabs) => {
if (!nextTabs.some((tab) => tab.id === selectedTab.value)) selectedTab.value = nextTabs[0]?.id ?? "app";
},
{ immediate: true },
);
function handleOpenChange(nextOpen: boolean) {
if (nextOpen) {
@@ -106,6 +163,7 @@ watch(
<Dialog :open="open" @update:open="handleOpenChange">
<DialogContent
class="sm:max-w-[700px]"
:class="'flex max-h-[min(720px,calc(var(--dbx-viewport-height)-48px))] flex-col gap-0 overflow-hidden p-0'"
:show-close-button="!isCloseBlocked"
@interact-outside="
(e: Event) => {
@@ -118,92 +176,195 @@ watch(
}
"
>
<DialogHeader>
<DialogTitle>{{ updateInfo?.update_available ? t("updates.availableTitle") : t("updates.title") }}</DialogTitle>
<DialogHeader class="border-b py-4 pl-5 pr-12">
<div class="flex items-center justify-between gap-4">
<DialogTitle class="flex min-w-0 items-center gap-2">
<span>{{ t("updates.centerTitle") }}</span>
<span v-if="totalUpdateCount > 0" class="rounded-full bg-primary/10 px-2 py-0.5 text-xs font-medium text-primary">{{ t("updates.centerAvailable", { count: totalUpdateCount }) }}</span>
</DialogTitle>
<Button v-if="hasComponentUpdates" type="button" size="sm" class="h-8 shrink-0" :disabled="props.isUpdatingAll || props.checkingUpdates || props.isDownloadingUpdate || props.isInstallingUpdate || isAnyComponentUpdating" @click="emit('update-all')">
<Loader2 v-if="props.isUpdatingAll" class="h-3.5 w-3.5 animate-spin" />
<RefreshCw v-else class="h-3.5 w-3.5" />
{{ t("updates.updateAll") }}
</Button>
</div>
</DialogHeader>
<div class="space-y-3 text-sm">
<p v-if="updateInfo?.update_available">
{{
t("updates.availableMessage", {
current: updateInfo.current_version,
latest: updateInfo.latest_version,
})
}}
</p>
<p v-else-if="!checkingUpdates" class="text-muted-foreground">
{{ updateCheckMessage || t("updates.upToDate", { version: updateInfo?.current_version || "" }) }}
</p>
<div
v-if="updateInfo?.update_available && updateInfo.release_notes"
class="max-h-48 overflow-auto rounded-md border bg-muted/30 p-3 text-xs [&_h1]:text-sm [&_h1]:font-semibold [&_h1]:mb-1 [&_h2]:text-sm [&_h2]:font-semibold [&_h2]:mb-1 [&_h3]:text-xs [&_h3]:font-semibold [&_h3]:mb-1 [&_ul]:list-disc [&_ul]:pl-4 [&_ul]:my-1 [&_ol]:list-decimal [&_ol]:pl-4 [&_ol]:my-1 [&_li]:my-0.5 [&_p]:my-1 [&_code]:bg-muted [&_code]:px-1 [&_code]:py-0.5 [&_code]:rounded [&_code]:text-[11px] [&_a]:text-primary [&_a]:underline"
v-html="renderedNotes"
@click="handleReleaseNotesClick"
/>
<p v-if="!isDesktop && updateInfo?.update_available" class="text-xs text-muted-foreground">
{{ t("updates.dockerUsersRun") }}
<code class="bg-muted px-1 py-0.5 rounded text-[11px]">docker compose pull && docker compose up -d</code>
{{ t("updates.toUpdate") }}
</p>
<p v-if="isDesktop && updateInfo?.update_available && updateInfo.portable_mode && !updateInfo.manual_update_only" class="text-xs text-muted-foreground">
{{ t("updates.portableAutomaticUpdate") }}
</p>
<p v-if="isDesktop && updateInfo?.update_available && updateInfo.manual_update_only" class="text-xs text-muted-foreground">
{{ t("updates.windows7ManualUpdate") }}
</p>
<div v-if="canDownloadAndInstallUpdate(updateInfo, isDesktop) && activeTaskCount > 0" role="alert" class="flex items-start gap-2 rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs text-amber-700 dark:text-amber-300">
<AlertTriangle class="mt-0.5 h-4 w-4 shrink-0" />
<span>{{ t("updates.activeTasksBlockUpdate", { count: activeTaskCount }) }}</span>
</div>
</div>
<p v-if="checkingUpdates" class="text-sm text-muted-foreground">{{ t("updates.checking") }}</p>
<p v-if="updateDownloaded && !isInstallingUpdate" class="text-sm">{{ t("updates.downloadedReady", { version: updateInfo?.latest_version }) }}</p>
<p v-if="updateCheckFailed && updateInfo?.update_available" role="alert" class="text-sm text-destructive">{{ updateCheckMessage }}</p>
<DialogFooter class="relative min-w-0 sm:justify-end">
<div v-if="!updateReady && !isInstallingUpdate && !updateDownloaded && (updateInfo?.update_available || updateCheckFailed)" class="flex items-center gap-1.5 self-start sm:absolute sm:left-4 sm:top-1/2 sm:-translate-y-1/2">
<span class="text-xs text-muted-foreground">{{ t("updates.source") }}</span>
<Select :model-value="updateDownloadSource" :disabled="checkingUpdates || isIgnoringUpdate" @update:model-value="(value) => value && emit('change-download-source', value as UpdateDownloadSource)">
<SelectTrigger class="h-8 w-[150px] text-xs">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="official">{{ t("updates.sourceOfficial") }}</SelectItem>
<SelectItem value="cnb">{{ t("updates.sourceCnb") }}</SelectItem>
</SelectContent>
</Select>
</div>
<template v-if="updateInfo?.update_available">
<div class="flex min-w-0 flex-wrap items-center gap-2 sm:justify-end">
<Button v-if="!isCloseBlocked" variant="outline" class="shrink-0" @click="handleCancel">{{ t("dangerDialog.cancel") }}</Button>
<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 class="flex min-h-0 flex-1 flex-col">
<div class="border-b px-4 py-2">
<div role="tablist" :aria-label="t('updates.centerTitle')" class="inline-flex h-9 w-full items-center justify-center rounded-md bg-muted p-[3px] text-muted-foreground">
<button
v-for="tab in tabs"
:key="tab.id"
type="button"
role="tab"
:aria-selected="selectedTab === tab.id"
:data-state="selectedTab === tab.id ? 'active' : 'inactive'"
:data-update-tab="tab.id"
class="relative inline-flex h-full flex-1 select-none items-center justify-center gap-1.5 whitespace-nowrap rounded-md border border-transparent px-2 text-sm font-medium transition-colors hover:text-foreground focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50"
:class="selectedTab === tab.id ? 'bg-background text-foreground shadow-sm' : 'text-foreground/60'"
@click="selectedTab = tab.id"
>
<span>{{ tab.label }}</span>
<span v-if="tab.count > 0" class="rounded-full bg-foreground/10 px-1.5 text-[11px]">{{ tab.count }}</span>
</button>
</div>
<template v-if="canDownloadAndInstallUpdate(updateInfo, isDesktop)">
<Button v-if="updateReady" class="shrink-0" :disabled="activeTaskCount > 0 || isIgnoringUpdate" @click="emit('restart')">{{ t("updates.restart") }}</Button>
<Button v-else-if="isInstallingUpdate" class="shrink-0" disabled>
</div>
<div data-update-scroll-region class="min-h-0 flex-1 overflow-auto px-5 py-4 text-sm">
<template v-if="selectedTab === 'app'">
<div class="space-y-3">
<p v-if="updateInfo?.update_available">
{{
t("updates.availableMessage", {
current: updateInfo.current_version,
latest: updateInfo.latest_version,
})
}}
</p>
<p v-else-if="!checkingUpdates" class="text-muted-foreground">
{{ updateCheckMessage || t("updates.upToDate", { version: updateInfo?.current_version || "" }) }}
</p>
<div
v-if="updateInfo?.update_available && updateInfo.release_notes"
class="max-h-64 overflow-auto rounded-md border bg-muted/30 p-3 text-xs [&_h1]:mb-1 [&_h1]:text-sm [&_h1]:font-semibold [&_h2]:mb-1 [&_h2]:text-sm [&_h2]:font-semibold [&_h3]:mb-1 [&_h3]:text-xs [&_h3]:font-semibold [&_ol]:my-1 [&_ol]:list-decimal [&_ol]:pl-4 [&_p]:my-1 [&_ul]:my-1 [&_ul]:list-disc [&_ul]:pl-4 [&_li]:my-0.5 [&_code]:rounded [&_code]:bg-muted [&_code]:px-1 [&_code]:py-0.5 [&_code]:text-[11px] [&_a]:text-primary [&_a]:underline"
v-html="renderedNotes"
@click="handleReleaseNotesClick"
/>
<p v-if="!isDesktop && updateInfo?.update_available" class="text-xs text-muted-foreground">
{{ t("updates.dockerUsersRun") }}
<code class="rounded bg-muted px-1 py-0.5 text-[11px]">docker compose pull && docker compose up -d</code>
{{ t("updates.toUpdate") }}
</p>
<p v-if="isDesktop && updateInfo?.update_available && updateInfo.portable_mode && !updateInfo.manual_update_only" class="text-xs text-muted-foreground">
{{ t("updates.portableAutomaticUpdate") }}
</p>
<p v-if="isDesktop && updateInfo?.update_available && updateInfo.manual_update_only" class="text-xs text-muted-foreground">
{{ t("updates.windows7ManualUpdate") }}
</p>
<div v-if="canDownloadAndInstallUpdate(updateInfo, isDesktop) && activeTaskCount > 0" role="alert" class="flex items-start gap-2 rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-xs text-amber-700 dark:text-amber-300">
<AlertTriangle class="mt-0.5 h-4 w-4 shrink-0" />
<span>{{ t("updates.activeTasksBlockUpdate", { count: activeTaskCount }) }}</span>
</div>
</div>
<p v-if="checkingUpdates" class="mt-3 flex items-center gap-2 text-muted-foreground">
<Loader2 class="h-4 w-4 animate-spin" />
{{ t(isPreparingUpdate ? "updates.preparing" : "updates.installing") }}
</Button>
<template v-else-if="isDownloadingUpdate">
<Button variant="ghost" class="shrink-0" @click="emit('cancel-download')">{{ t("updates.cancelDownload") }}</Button>
<Button class="w-52 shrink-0 tabular-nums" disabled>
<Loader2 class="h-4 w-4 animate-spin" />
{{ t("updates.downloading", { progress: downloadProgress ?? 0 }) }}
</Button>
</template>
<Button v-else-if="updateDownloaded" class="shrink-0" :disabled="activeTaskCount > 0 || isIgnoringUpdate" @click="emit('install-downloaded')">{{ t("updates.restartAndUpdate") }}</Button>
<Button v-else-if="!checkingUpdates" class="shrink-0" :disabled="isIgnoringUpdate" @click="emit('download-in-background')">{{ t(updateCheckFailed ? "updates.retryDownload" : "updates.downloadInBackground") }}</Button>
{{ t("updates.checking") }}
</p>
<p v-if="updateDownloaded && !isInstallingUpdate" class="mt-3">{{ t("updates.downloadedReady", { version: updateInfo?.latest_version }) }}</p>
<p v-if="updateCheckFailed && updateInfo?.update_available" role="alert" class="mt-3 text-destructive">{{ updateCheckMessage }}</p>
</template>
</template>
<template v-else>
<div class="flex min-w-0 flex-wrap items-center gap-2 sm:justify-end">
<Button v-if="!isCloseBlocked" variant="outline" class="shrink-0" @click="handleCancel">{{ t("dangerDialog.cancel") }}</Button>
<Button v-if="updateCheckMessage" class="shrink-0" @click="emit('open-latest-release')">{{ t("updates.openRelease") }}</Button>
<template v-else>
<div v-if="componentUpdatesLoading && !selectedCategoryHasUpdate" class="flex items-center justify-center gap-2 py-12 text-muted-foreground">
<Loader2 class="h-4 w-4 animate-spin" />
{{ t("updates.checking") }}
</div>
<div v-else class="space-y-2">
<div v-if="componentUpdatesError" class="mb-3 flex items-start gap-2 rounded-md border border-destructive/30 bg-destructive/5 p-3 text-destructive">
<AlertTriangle class="mt-0.5 h-4 w-4 shrink-0" />
<span>{{ componentUpdatesError }}</span>
</div>
<template v-if="selectedTab === 'drivers'">
<div v-for="driver in driverUpdates" :key="driver.db_type" class="flex items-center justify-between gap-4 rounded-md border p-3">
<div class="min-w-0">
<div class="font-medium">{{ driver.label }}</div>
<div class="mt-0.5 text-xs text-muted-foreground">{{ driver.installed_version || driver.version }} → {{ driver.version }}</div>
</div>
<span class="shrink-0 rounded-full bg-primary/10 px-2 py-0.5 text-xs font-medium text-primary">{{ t("settings.updateAvailable") }}</span>
</div>
</template>
<template v-else-if="selectedTab === 'jdbc' && jdbcUpdate?.update_available">
<div class="flex items-center justify-between gap-4 rounded-md border p-3">
<div class="min-w-0">
<div class="font-medium">{{ t("settings.updateJdbc") }}</div>
<div class="mt-0.5 text-xs text-muted-foreground">{{ jdbcUpdate.version || t("updates.notInstalled") }} → {{ jdbcUpdate.latest_version || t("settings.updateAvailable") }}</div>
</div>
<span class="shrink-0 rounded-full bg-primary/10 px-2 py-0.5 text-xs font-medium text-primary">{{ t("settings.updateAvailable") }}</span>
</div>
</template>
<template v-else-if="selectedTab === 'mcp' && mcpAvailable && mcpUpdate">
<div class="flex items-center justify-between gap-4 rounded-md border p-3">
<div class="min-w-0">
<div class="font-medium">{{ t("settings.updateMcp") }}</div>
<div class="mt-0.5 text-xs text-muted-foreground">{{ mcpUpdate.current_version || t("updates.notInstalled") }} → {{ mcpUpdate.latest_version || t("settings.updateAvailable") }}</div>
</div>
<span class="shrink-0 rounded-full bg-primary/10 px-2 py-0.5 text-xs font-medium text-primary">{{ t("settings.updateAvailable") }}</span>
</div>
</template>
<template v-else-if="selectedTab === 'plugins'">
<div v-for="plugin in pluginUpdates" :key="plugin.key" class="flex items-center justify-between gap-4 rounded-md border p-3">
<div class="min-w-0">
<div class="truncate font-medium">{{ plugin.name }}</div>
<div class="mt-0.5 text-xs text-muted-foreground">{{ plugin.installed?.manifest.version || t("updates.notInstalled") }} → {{ plugin.plugin.latestVersion }}</div>
</div>
<span class="shrink-0 rounded-full bg-primary/10 px-2 py-0.5 text-xs font-medium text-primary">{{ t("settings.updateAvailable") }}</span>
</div>
</template>
<div v-if="!selectedCategoryHasUpdate" class="flex flex-col items-center justify-center gap-2 py-12 text-muted-foreground">
<CheckCircle2 class="h-6 w-6 text-emerald-500" />
{{ t("settings.upToDate") }}
</div>
</div>
</template>
</div>
<DialogFooter v-if="selectedTab === 'app'" data-update-footer class="mx-0 mb-0 min-w-0 rounded-none border-t px-[22px] pb-2.5 pt-2.5 sm:items-center sm:justify-end">
<div v-if="!updateReady && !isInstallingUpdate && !updateDownloaded && (updateInfo?.update_available || updateCheckFailed)" class="flex items-center gap-1.5 self-start sm:mr-auto sm:self-center">
<span class="text-xs text-muted-foreground">{{ t("updates.source") }}</span>
<Select :model-value="updateDownloadSource" :disabled="checkingUpdates || isIgnoringUpdate" @update:model-value="(value) => value && emit('change-download-source', value as UpdateDownloadSource)">
<SelectTrigger class="h-8 w-[150px] text-xs">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="official">{{ t("updates.sourceOfficial") }}</SelectItem>
<SelectItem value="cnb">{{ t("updates.sourceCnb") }}</SelectItem>
</SelectContent>
</Select>
</div>
</template>
</DialogFooter>
<template v-if="updateInfo?.update_available">
<div 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)">
<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" />
{{ t(isPreparingUpdate ? "updates.preparing" : "updates.installing") }}
</Button>
<template v-else-if="isDownloadingUpdate">
<Button variant="ghost" class="shrink-0" @click="emit('cancel-download')">{{ t("updates.cancelDownload") }}</Button>
<Button class="w-52 shrink-0 tabular-nums" disabled>
<Loader2 class="h-4 w-4 animate-spin" />
{{ t("updates.downloading", { progress: downloadProgress ?? 0 }) }}
</Button>
</template>
<Button v-else-if="updateDownloaded" class="shrink-0" :disabled="activeTaskCount > 0 || isIgnoringUpdate || isUpdatingAll" @click="emit('install-downloaded')">{{ t("updates.restartAndUpdate") }}</Button>
<Button v-else-if="!checkingUpdates" class="shrink-0" :disabled="isIgnoringUpdate" @click="emit('download-in-background')">{{ t(updateCheckFailed ? "updates.retryDownload" : "updates.downloadInBackground") }}</Button>
</template>
</template>
<template v-else>
<div class="flex min-w-0 flex-wrap items-center gap-2 sm:justify-end">
<Button v-if="updateCheckMessage" class="shrink-0" @click="emit('open-latest-release')">{{ t("updates.openRelease") }}</Button>
</div>
</template>
</DialogFooter>
<DialogFooter v-else data-update-footer class="mx-0 mb-0 rounded-none border-t px-[22px] pb-2.5 pt-2.5 sm:items-center sm:justify-end">
<Button v-if="selectedCategory" :disabled="!selectedCategoryHasUpdate || isAnyComponentUpdating || isInstallingUpdate || isUpdatingAll" @click="emit('install-component-updates', selectedCategory)">
<Loader2 v-if="isUpdatingSelectedCategory" class="h-4 w-4 animate-spin" />
{{ t(isUpdatingSelectedCategory ? "updates.updating" : "updates.updateNow") }}
</Button>
</DialogFooter>
</div>
</DialogContent>
</Dialog>
</template>
@@ -1,5 +1,7 @@
// @vitest-environment happy-dom
import { createApp, h } from "vue";
import { readFileSync } from "node:fs";
import { resolve } from "node:path";
import { describe, expect, it } from "vitest";
import ToolbarUpdateIcon from "../ToolbarUpdateIcon.vue";
describe("silent toolbar update icon", () => {
@@ -11,4 +13,20 @@ describe("silent toolbar update icon", () => {
expect(container.querySelector("[data-toolbar-update-progress], [data-toolbar-update-scan]")).toBeNull();
app.unmount();
});
it("renders a text Update action whenever any aggregate update is available", () => {
const source = readFileSync(resolve(process.cwd(), "apps/desktop/src/components/layout/AppToolbar.vue"), "utf8");
expect(source).toContain('v-if="hasUpdateAvailable"');
expect(source).toContain("data-toolbar-update-action");
expect(source).toContain('t("updates.updateAction")');
});
it("passes only opt-out component badges to their separate toolbar entries", () => {
const source = readFileSync(resolve(process.cwd(), "apps/desktop/src/App.vue"), "utf8");
expect(source).toContain(':agent-driver-update-count="showDriverStoreUpdateBadge"');
expect(source).toContain(':has-mcp-update-available="showMcpSettingsUpdateBadge"');
expect(source).not.toContain(':agent-driver-update-count="toolbarDriverUpdateCount"');
});
});