fix(updates): sync update center state after manual component changes

This commit is contained in:
zipg authored and GitHub committed 2026-09-20 18:43:02 +08:00
1 parent 1ef865008a
commit 4d150fc909
13 files changed
+143 -11

No files matched your search

+11 -2
View File
@@ -27,7 +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 { COMPONENT_UPDATES_CHANGED_EVENT, notifyComponentPluginsUpdated, notifyComponentUpdatesChanged } 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";
@@ -200,13 +200,14 @@ const savedSqlStore = useSavedSqlStore();
const promptTemplateStore = usePromptTemplateStore();
const recentConnectionIds = ref<readonly string[]>(parseRecentConnectionIds(safeLocalStorageGet(RECENT_CONNECTION_IDS_STORAGE_KEY)));
connectionStore.setBeforeConnectHandler(async (config) => {
await ensureJdbcxRuntimeDrivers(config, api);
const jdbcxRuntime = await ensureJdbcxRuntimeDrivers(config, api);
const jdbcProductRuntimeBefore = JSON.stringify({
connectionString: config.connection_string ?? null,
driverClass: config.jdbc_driver_class ?? null,
driverPaths: config.jdbc_driver_paths ?? [],
});
const jdbcProductRuntime = await ensureRegisteredJdbcProductRuntimeDrivers(config, api);
if (jdbcxRuntime || jdbcProductRuntime) notifyComponentUpdatesChanged();
const jdbcProductRuntimeAfter = JSON.stringify({
connectionString: config.connection_string ?? null,
driverClass: config.jdbc_driver_class ?? null,
@@ -1234,6 +1235,12 @@ function syncToolbarComponentUpdateState() {
applyMcpStatus(componentUpdates.mcpUpdateAvailable.value);
}
function handleComponentUpdatesChanged() {
void componentUpdates.refresh({ force: true }).then((refreshed) => {
if (refreshed) syncToolbarComponentUpdateState();
});
}
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 stale toolbar state.
@@ -3840,6 +3847,7 @@ onMounted(async () => {
window.addEventListener("blur", handleTabSwitcherWindowBlur);
document.addEventListener("visibilitychange", handleTabSwitcherVisibilityChange);
window.addEventListener("dbx-open-driver-store", openDriverStoreFromEvent);
window.addEventListener(COMPONENT_UPDATES_CHANGED_EVENT, handleComponentUpdatesChanged);
window.addEventListener("dbx:activate-query-surface", activateQuerySurface);
window.addEventListener(OBJECT_BROWSER_SEARCH_FOCUS_EVENT, focusRequestedObjectBrowserSearch);
window.addEventListener("dbx-mcp-status-changed", handleMcpStatusChanged);
@@ -3925,6 +3933,7 @@ onUnmounted(() => {
document.removeEventListener("visibilitychange", handleTabSwitcherVisibilityChange);
tabSwitcherKeyboard.reset();
window.removeEventListener("dbx-open-driver-store", openDriverStoreFromEvent);
window.removeEventListener(COMPONENT_UPDATES_CHANGED_EVENT, handleComponentUpdatesChanged);
window.removeEventListener("dbx:activate-query-surface", activateQuerySurface);
window.removeEventListener(OBJECT_BROWSER_SEARCH_FOCUS_EVENT, focusRequestedObjectBrowserSearch);
window.removeEventListener("dbx-mcp-status-changed", handleMcpStatusChanged);