fix(updates): sync entry-point states after component updates

This commit is contained in:
zipg authored and GitHub committed 2026-09-20 11:03:31 +08:00
1 parent db5e6f106b
commit 6babd1bf9b
7 files changed
+86 -7

No files matched your search

+13 -5
View File
@@ -27,6 +27,7 @@ import { useTheme } from "@/composables/useTheme";
import { canDownloadAndInstallUpdate, useAppUpdater } from "@/composables/useAppUpdater";
import { useMcpUpdateBadge } from "@/composables/useMcpUpdateBadge";
import { useComponentUpdates, type ComponentUpdateCategory } from "@/composables/useComponentUpdates";
import { notifyComponentPluginsUpdated } from "@/lib/updates/componentUpdateEvents";
import { driverStoreUpdateBadgeCount, showMcpUpdateBadge } from "@/lib/updates/updateBadges";
import { markPendingComponentUpdatesAfterAppUpdate, resolveUpdateAllAction, runPendingComponentUpdatePlan, shouldCloseUpdateCenterAfterComponentUpdate, takePendingComponentUpdatesAfterAppRestart, type PendingComponentUpdatePlan } from "@/lib/updates/componentUpdateOrchestration";
import { isUpdatePreviewMockEnabled } from "@/lib/updates/updatePreviewMock";
@@ -314,7 +315,7 @@ const activeAiRunCount = computed(() => (isDesktop ? activeDesktopAiRuns().lengt
/** Runs waiting for a write confirmation — the panel-entry badge shows these
* with a higher-priority indicator (parent PRD §4 line 71 / §9). */
const awaitingAiRunCount = computed(() => (isDesktop ? activeDesktopAiRuns().filter((run) => run.status === "awaiting_write_confirmation").length : 0));
const { mcpUpdateAvailable, refreshMcpUpdateStatus, handleMcpStatusChanged } = useMcpUpdateBadge({
const { mcpUpdateAvailable, refreshMcpUpdateStatus, handleMcpStatusChanged, applyMcpStatus } = useMcpUpdateBadge({
isDesktop,
// Update availability remains visible when every auto-update switch is off;
// the switches control installation, not whether the user can be reminded.
@@ -1206,7 +1207,8 @@ async function checkAllUpdates() {
manualCheckingAllUpdates.value = true;
const startedAt = Date.now();
try {
await Promise.allSettled([checkUpdates({ silent: true }), componentUpdates.refresh()]);
const [, componentRefresh] = await Promise.allSettled([checkUpdates({ silent: true }), componentUpdates.refresh()]);
if (componentRefresh.status === "fulfilled" && componentRefresh.value) syncToolbarComponentUpdateState();
const remaining = 500 - (Date.now() - startedAt);
if (remaining > 0) await new Promise((resolve) => setTimeout(resolve, remaining));
} finally {
@@ -1221,13 +1223,19 @@ function openDriverStoreFromUpdate(target?: DriverStoreTab) {
function handleToolbarUpdateClick() {
showUpdateDialog.value = true;
if (!toolbarHasUpdateAvailable.value && !checkingAllUpdates.value) void checkAllUpdates();
if (!checkingAllUpdates.value) void checkAllUpdates();
}
function syncToolbarComponentUpdateState() {
agentDriverUpdateCount.value = componentUpdates.driverUpdateCount.value;
applyMcpStatus(componentUpdates.mcpUpdateAvailable.value);
}
function reportComponentUpdateResult(result: Awaited<ReturnType<typeof componentUpdates.installCategory>>) {
const updatedComponents = [result.drivers > 0 ? t("settings.updateDrivers") : "", result.jdbc ? t("settings.updateJdbc") : "", result.mcp ? t("settings.updateMcp") : "", result.plugins > 0 ? t("settings.updatePlugins") : ""].filter(Boolean);
// Only a clean refresh is authoritative; a failed registry check must not clear the toolbar count.
if (result.failed.length === 0) agentDriverUpdateCount.value = componentUpdates.driverUpdateCount.value;
// Only a clean refresh is authoritative; a failed registry check must not clear stale toolbar state.
if (result.failed.length === 0) syncToolbarComponentUpdateState();
if (result.plugins > 0) notifyComponentPluginsUpdated();
if (updatedComponents.length) toast(t("updates.componentsAutoUpdated", { components: updatedComponents.join(t("updates.componentListSeparator")) }));
if (result.skippedDrivers > 0) toast(t("updates.componentsAutoUpdateSkipped"), 6000);
if (result.failed.length) toast(t("updates.componentsAutoUpdateFailed", { count: result.failed.length }), 6000);