fix(updates): include MCP updates in toolbar update check

This commit is contained in:
zipg
2026-09-24 19:20:27 +08:00
committed by GitHub
parent 1eb429e137
commit a6f841293b
2 changed files with 25 additions and 3 deletions
+4 -3
View File
@@ -1264,11 +1264,12 @@ function openPluginConnectionDialog(pluginId: string, providerId: string) {
showConnectionDialog.value = true;
}
async function checkAllUpdates() {
if (manualCheckingAllUpdates.value) return;
if (manualCheckingAllUpdates.value || componentUpdates.updating.value) return;
manualCheckingAllUpdates.value = true;
const startedAt = Date.now();
try {
const [, componentRefresh] = await Promise.allSettled([checkUpdates({ silent: true }), componentUpdates.refresh()]);
// A user-triggered check must replace any in-flight background snapshot that may predate the update.
const [, componentRefresh] = await Promise.allSettled([checkUpdates({ silent: true }), componentUpdates.refresh({ force: true })]);
if (componentRefresh.status === "fulfilled" && componentRefresh.value) syncToolbarComponentUpdateState();
const remaining = 500 - (Date.now() - startedAt);
if (remaining > 0) await new Promise((resolve) => setTimeout(resolve, remaining));
@@ -1284,7 +1285,7 @@ function openDriverStoreFromUpdate(target?: DriverStoreTab) {
function handleToolbarUpdateClick() {
showUpdateDialog.value = true;
if (!checkingAllUpdates.value) void checkAllUpdates();
void checkAllUpdates();
}
function syncToolbarComponentUpdateState() {
@@ -108,6 +108,27 @@ describe("useComponentUpdates", () => {
expect(updates.driverUpdateCount.value).toBe(0);
});
it("starts a fresh MCP check for an explicit user action instead of reusing a background result", async () => {
const backgroundMcp = deferred<typeof mcpStatus>();
const userMcp = deferred<typeof mcpStatus>();
mocks.checkMcpServerStatus.mockReturnValueOnce(backgroundMcp.promise).mockReturnValueOnce(userMcp.promise);
const updates = useComponentUpdates({ isDesktop: true });
const backgroundRefresh = updates.refresh();
await Promise.resolve();
const userRefresh = updates.refresh({ force: true });
await Promise.resolve();
userMcp.resolve(mcpStatus);
expect(await userRefresh).toBe(true);
expect(updates.mcpUpdateAvailable.value).toBe(true);
backgroundMcp.resolve({ ...mcpStatus, latest_version: mcpStatus.current_version, update_available: false });
expect(await backgroundRefresh).toBe(false);
expect(updates.mcpUpdateAvailable.value).toBe(true);
expect(mocks.checkMcpServerStatus).toHaveBeenCalledTimes(2);
});
it("clears driver and MCP update state after a successful update and refresh", async () => {
mocks.listInstalledAgents.mockResolvedValueOnce([{ db_type: "mysql", update_available: true }]).mockResolvedValueOnce([{ db_type: "mysql", update_available: false }]);
mocks.checkMcpServerStatus.mockResolvedValueOnce(mcpStatus).mockResolvedValueOnce({ ...mcpStatus, latest_version: "1.0.0", update_available: false });