fix(plugins): check and update installed plugins with provenance guards

This commit is contained in:
Abeautifulsnow authored and GitHub committed 2026-09-21 00:09:50 +08:00
1 parent d715b16ba5
commit cab674299a
26 files changed
+1180 -44

No files matched your search

+27
View File
@@ -512,4 +512,31 @@ describe("UpdateDialog aggregate update center", () => {
expect(installComponentUpdates).toHaveBeenCalledWith("drivers");
});
it("marks only a plugin whose update source changed as needing confirmation in the Plugin Center", async () => {
const listing = (id: string, provenance: Record<string, string>) => ({
key: `official:${id}`,
status: "update",
artifact: { target: "universal", url: "https://example.com/plugin.dbxp", sha256: "hash", signingKeyId: "key-a" },
repository: { id: "official" },
plugin: { id, latestVersion: "1.1.0", publisher: "DBX" },
installed: { manifest: { id, version: "1.0.0" }, provenance },
name: `${id} plugin`,
});
await mountDialog(0, {}, undefined, {
updateInfo: null,
pluginUpdates: [listing("same", { repositoryId: "official" }), listing("moved", { repositoryId: "other-repo" })],
});
const pluginsTab = document.body.querySelector<HTMLButtonElement>('[data-update-tab="plugins"]');
pluginsTab?.click();
await flushDialog();
// "Update all" skips the changed-source plugin, so the dialog has to explain why it stays.
const hint = "Confirm the change in the Plugin Center first";
const rows = [...document.body.querySelectorAll<HTMLElement>(".rounded-md.border.p-3")];
const rowFor = (name: string) => rows.find((row) => row.textContent?.includes(name));
expect(rowFor("moved plugin")?.textContent).toContain(hint);
expect(rowFor("same plugin")?.textContent).not.toContain(hint);
});
});
@@ -8,7 +8,7 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@
import type { UpdateInfo } from "@/lib/backend/api";
import type { AgentDriverInfo, McpServerStatus, UpdateDownloadSource } from "@/lib/backend/tauri";
import type { JdbcPluginStatus } from "@/types/database";
import type { MarketplacePluginListing } from "@/lib/plugins/pluginMarketplace";
import { pluginSourceChange, type MarketplacePluginListing } from "@/lib/plugins/pluginMarketplace";
import { mcpUpdateAvailability } from "@/lib/mcp/mcpUpdateStatus";
import { isTauriRuntime } from "@/lib/backend/tauriRuntime";
import { isUpdatePreviewMockEnabled } from "@/lib/updates/updatePreviewMock";
@@ -302,6 +302,9 @@ watch(
<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>
<!-- "Update all" deliberately skips a changed source: the user has to confirm it in
the Plugin Center, so say so instead of leaving an item that never updates. -->
<div v-if="pluginSourceChange(plugin)" class="mt-1 text-xs text-amber-600 dark:text-amber-400">{{ t("pluginPlatform.updateSourceChangeRequired") }}</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>