Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

feat(plugins): unify marketplace catalog cards

tianma-if3e97125e34e8
diff --git a/apps/web/src/components/plugins/PluginCatalogCard.tsx b/apps/web/src/components/plugins/PluginCatalogCard.tsx
new file mode 100644
index 00000000..00a4da30
--- /dev/null
+++ b/apps/web/src/components/plugins/PluginCatalogCard.tsx
@@ -0,0 +1,238 @@
+import { BadgeCheck, Download, PanelRightOpen, Play, Settings2, Trash2 } from "lucide-react";
+import { Link } from "react-router";
+import { useTranslation } from "react-i18next";
+import { Button } from "@/components/ui/button";
+import { Switch } from "@/components/ui/switch";
+import { GitHubMark, GitHubRepositoryLink } from "@/components/GitHubRepositoryLink";
+import {
+ canReplaceWithVerifiedMarketplace,
+ getPluginCatalogDescription,
+ getPluginCatalogName,
+ getPluginCatalogRepositoryUrl,
+ getPluginCatalogSourceKey,
+ getPluginCatalogVersion,
+ type PluginCatalogItem,
+} from "@/lib/plugins/plugin-catalog";
+import { getPluginDetailPath, hasPluginSettings } from "@/lib/plugins/plugin-navigation";
+import type { PluginUpdateInfo } from "@/lib/plugins/plugin-updates";
+import type { RegisteredPluginCommand, RegisteredPluginPanel } from "@/lib/plugins/plugin-host";
+
+const permissionLabel = (permission: string) => permission.replace(":", " · ");
+
+const sourceBadgeClassName = (sourceKey: ReturnType<typeof getPluginCatalogSourceKey>) =>
+ sourceKey === "github" || sourceKey === "manifest"
+ ? "bg-amber-50 text-amber-700"
+ : "bg-emerald-50 text-emerald-700";
+
+export const PluginCatalogCard = ({
+ item,
+ update,
+ commands,
+ panels,
+ pendingId,
+ onOpenPlugin,
+ onToggle,
+ onInstallMarketplace,
+ onUpdate,
+ onRunCommand,
+ onOpenPanel,
+ onUninstall,
+}: {
+ item: PluginCatalogItem;
+ update?: PluginUpdateInfo;
+ commands: RegisteredPluginCommand[];
+ panels: RegisteredPluginPanel[];
+ pendingId: string | null;
+ onOpenPlugin?: (pluginId: string) => void;
+ onToggle: (enabled: boolean) => void;
+ onInstallMarketplace: () => void;
+ onUpdate: () => void;
+ onRunCommand: (command: RegisteredPluginCommand) => void;
+ onOpenPanel: (panel: RegisteredPluginPanel) => void;
+ onUninstall: () => void;
+}) => {
+ const { t } = useTranslation();
+ const extension = item.extension;
+ const name = getPluginCatalogName(item);
+ const description = getPluginCatalogDescription(item);
+ const repositoryUrl = getPluginCatalogRepositoryUrl(item);
+ const version = getPluginCatalogVersion(item);
+ const sourceKey = getPluginCatalogSourceKey(item);
+ const marketplaceActionId = `marketplace:${item.id}`;
+ const replaceWithVerified = canReplaceWithVerifiedMarketplace(item);
+
+ return (
+ <article
+ role={extension ? "link" : undefined}
+ tabIndex={extension ? 0 : undefined}
+ aria-label={extension ? t("plugins.details.open", { name }) : undefined}
+ className={`flex min-w-0 flex-col rounded-lg border border-slate-200 bg-white p-3 ${
+ extension
+ ? "cursor-pointer transition-colors hover:border-emerald-300 hover:bg-emerald-50/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-500/70"
+ : ""
+ }`}
+ onClick={extension ? (event) => {
+ if ((event.target as HTMLElement).closest("button, a")) return;
+ onOpenPlugin?.(item.id);
+ } : undefined}
+ onKeyDown={extension ? (event) => {
+ if (event.target === event.currentTarget && (event.key === "Enter" || event.key === " ")) {
+ event.preventDefault();
+ onOpenPlugin?.(item.id);
+ }
+ } : undefined}
+ >
+ <div className="flex items-start justify-between gap-3">
+ <div className="min-w-0 flex-1">
+ <div className="flex flex-wrap items-center gap-1.5">
+ <span className="truncate text-sm font-semibold text-slate-900">{name}</span>
+ {extension ? (
+ <span className="rounded bg-slate-100 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-slate-500">
+ {extension.manifest.type}
+ </span>
+ ) : null}
+ {extension && version ? <span className="text-[11px] text-slate-400">v{version}</span> : null}
+ {sourceKey === "official" ? (
+ <span className="rounded-full bg-emerald-50 px-2 py-0.5 text-[10px] font-semibold text-emerald-700">
+ {t("plugins.marketplace.officialAutoUpdate")}
+ </span>
+ ) : sourceKey ? (
+ <span className={`inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[10px] ${sourceBadgeClassName(sourceKey)}`}>
+ {sourceKey === "verified" ? <BadgeCheck className="h-3 w-3" /> : sourceKey === "github" ? <GitHubMark className="h-3 w-3" /> : null}
+ {t(`plugins.sources.${sourceKey}`)}
+ </span>
+ ) : null}
+ {update ? (
+ <span className="rounded-full bg-emerald-100 px-2 py-0.5 text-[10px] font-semibold text-emerald-700">
+ {t("plugins.updates.available", { version: update.latestVersion })}
+ </span>
+ ) : null}
+ </div>
+ {!extension && item.marketplaceEntry ? (
+ <div className="mt-0.5 text-[10px] text-slate-400">
+ {item.marketplaceEntry.author} · {item.marketplaceEntry.category}{version ? ` · v${version}` : ""}
+ </div>
+ ) : null}
+ {description ? <p className="mt-1 line-clamp-2 text-xs leading-5 text-slate-500">{description}</p> : null}
+ </div>
+ <div className="flex shrink-0 items-center gap-1">
+ {repositoryUrl ? (
+ <GitHubRepositoryLink
+ href={repositoryUrl}
+ label={t("plugins.marketplace.openRepository", { name })}
+ showTooltip={false}
+ className="h-7 w-7 justify-center rounded p-1 text-slate-400 hover:bg-slate-100 hover:text-slate-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-500/70"
+ iconClassName="h-3.5 w-3.5"
+ />
+ ) : null}
+ {extension ? (
+ <Switch
+ aria-label={t("plugins.toggle", { name })}
+ checked={extension.enabled}
+ disabled={pendingId === item.id}
+ onCheckedChange={onToggle}
+ />
+ ) : null}
+ </div>
+ </div>
+
+ {extension?.manifest.type === "plugin" && extension.manifest.permissions.length > 0 ? (
+ <div className="mt-2 flex flex-wrap gap-1">
+ {extension.manifest.permissions.slice(0, 3).map((permission) => (
+ <span key={permission} className="rounded-full bg-slate-100 px-2 py-0.5 text-[10px] text-slate-600">
+ {permission === "network:public" ? t("plugins.permissions.publicNetwork") : permissionLabel(permission)}
+ </span>
+ ))}
+ {extension.manifest.permissions.length > 3 ? (
+ <span className="rounded-full bg-slate-100 px-2 py-0.5 text-[10px] text-slate-600">
+ +{extension.manifest.permissions.length - 3}
+ </span>
+ ) : null}
+ </div>
+ ) : null}
+
+ {extension?.error ? <div className="mt-2 text-xs text-rose-600">{extension.error}</div> : null}
+
+ <div className="mt-auto flex flex-wrap items-center gap-1.5 pt-3">
+ {extension && hasPluginSettings(extension.manifest) ? (
+ <Button asChild size="sm" variant="outline" className="h-8 gap-1.5 text-xs">
+ <Link to={getPluginDetailPath(item.id, "settings")} aria-label={t("plugins.settings.open", { name })}>
+ <Settings2 className="h-3.5 w-3.5" />
+ {t("plugins.settings.title")}
+ </Link>
+ </Button>
+ ) : null}
+ {update ? (
+ <Button
+ size="sm"
+ className="h-8 gap-1.5 text-xs"
+ disabled={pendingId === `update:${item.id}`}
+ onClick={onUpdate}
+ >
+ <Download className="h-3.5 w-3.5" />
+ {t("plugins.updates.update")}
+ </Button>
+ ) : null}
+ {!extension && item.marketplaceEntry ? (
+ <Button
+ size="sm"
+ className="h-8 gap-1.5 text-xs"
+ disabled={pendingId === marketplaceActionId}
+ onClick={onInstallMarketplace}
+ >
+ <Download className="h-3.5 w-3.5" />
+ {pendingId === marketplaceActionId ? t("plugins.installing") : t("plugins.install")}
+ </Button>
+ ) : null}
+ {replaceWithVerified && !update ? (
+ <Button
+ size="sm"
+ className="h-8 gap-1.5 text-xs"
+ disabled={pendingId === marketplaceActionId}
+ onClick={onInstallMarketplace}
+ >
+ <Download className="h-3.5 w-3.5" />
+ {pendingId === marketplaceActionId ? t("plugins.installing") : t("plugins.marketplace.installVerified")}
+ </Button>
+ ) : null}
+ {extension ? commands.map((command) => (
+ <Button
+ key={command.id}
+ size="sm"
+ variant="outline"
+ className="h-8 gap-1.5 text-xs"
+ disabled={pendingId === `${item.id}:${command.id}`}
+ onClick={() => onRunCommand(command)}
+ >
+ <Play className="h-3.5 w-3.5" />
+ {command.title}
+ </Button>
+ )) : null}
+ {extension ? panels.map((panel) => (
+ <Button
+ key={panel.id}
+ size="sm"
+ variant="outline"
+ className="h-8 gap-1.5 text-xs"
+ onClick={() => onOpenPanel(panel)}
+ >
+ <PanelRightOpen className="h-3.5 w-3.5" />
+ {panel.title}
+ </Button>
+ )) : null}
+ {extension ? (
+ <Button
+ size="sm"
+ variant="ghost"
+ className="ml-auto h-8 gap-1.5 text-xs text-rose-600 hover:bg-rose-50 hover:text-rose-700"
+ disabled={pendingId === `remove:${item.id}`}
+ onClick={onUninstall}
+ >
+ <Trash2 className="h-3.5 w-3.5" />
+ {t("plugins.uninstall")}
+ </Button>
+ ) : null}
+ </div>
+ </article>
+ );
+};
diff --git a/apps/web/src/components/settings/PluginManagerCard.test.mjs b/apps/web/src/components/settings/PluginManagerCard.test.mjs
index 6adf2952..0aaa7d21 100644
--- a/apps/web/src/components/settings/PluginManagerCard.test.mjs
+++ b/apps/web/src/components/settings/PluginManagerCard.test.mjs
@@ -2,19 +2,21 @@ import { describe, expect, test } from "bun:test";
import { readFileSync } from "node:fs";
const source = readFileSync(new URL("./PluginManagerCard.tsx", import.meta.url), "utf8");
+const catalogCard = readFileSync(new URL("../plugins/PluginCatalogCard.tsx", import.meta.url), "utf8");
describe("plugin manager card layout", () => {
test("uses one responsive grid for marketplace and installed extension cards", () => {
expect(source).toContain('const PLUGIN_CARD_GRID_CLASS_NAME = "grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3";');
- expect(source.match(/className=\{PLUGIN_CARD_GRID_CLASS_NAME\}/g)).toHaveLength(2);
+ expect(source.match(/className=\{PLUGIN_CARD_GRID_CLASS_NAME\}/g)).toHaveLength(1);
+ expect(source).toContain("buildPluginCatalogItems");
+ expect(source).toContain("<PluginCatalogCard");
expect(source).not.toContain("md:grid-cols-2");
});
test("uses GitHub icon links for marketplace and installed extension repositories", () => {
- expect(source.match(/<GitHubRepositoryLink/g)).toHaveLength(2);
- expect(source.match(/showTooltip=\{false\}/g)).toHaveLength(2);
- expect(source).toContain("href={entry.repositoryUrl}");
- expect(source).toContain("href={extension.source.repositoryUrl}");
+ expect(catalogCard.match(/<GitHubRepositoryLink/g)).toHaveLength(1);
+ expect(catalogCard).toContain("showTooltip={false}");
+ expect(catalogCard).toContain("getPluginCatalogRepositoryUrl(item)");
});
test("shows update checks when marketplace plugins exist without installed extensions", () => {
@@ -28,3 +30,14 @@ describe("plugin manager card layout", () => {
expect(source).toContain("marketplaceQuery.refetch()");
});
});
+
+describe("unified plugin catalog cards", () => {
+ test("uses one card component for official, community, and sideloaded plugins", () => {
+ expect(catalogCard).toContain("getPluginCatalogSourceKey");
+ expect(catalogCard).toContain("officialAutoUpdate");
+ expect(catalogCard).toContain("canReplaceWithVerifiedMarketplace");
+ expect(catalogCard).toContain('role={extension ? "link" : undefined}');
+ expect(catalogCard).not.toContain("marketplace.installed");
+ expect(source).not.toContain("border-emerald-100");
+ });
+});
diff --git a/apps/web/src/components/settings/PluginManagerCard.tsx b/apps/web/src/components/settings/PluginManagerCard.tsx
index 9452b00e..c09423c1 100644
--- a/apps/web/src/components/settings/PluginManagerCard.tsx
+++ b/apps/web/src/components/settings/PluginManagerCard.tsx
@@ -1,5 +1,5 @@
import { useEffect, useState, useSyncExternalStore } from "react";
-import { BadgeCheck, BookOpen, CalendarClock, Download, ExternalLink, History, PanelRightOpen, Play, Puzzle, RefreshCw, Settings2, Trash2 } from "lucide-react";
+import { BookOpen, CalendarClock, Download, ExternalLink, History, PanelRightOpen, Play, Puzzle, RefreshCw, Settings2, Trash2 } from "lucide-react";
import { Link } from "react-router";
import { useTranslation } from "react-i18next";
import { useQuery, useQueryClient } from "@tanstack/react-query";
@@ -8,12 +8,14 @@ import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { Switch } from "@/components/ui/switch";
import type { EdgeEverPluginHost, InstalledExtension, RegisteredPluginCommand, RegisteredPluginPanel } from "@/lib/plugins/plugin-host";
+import { PluginCatalogCard } from "@/components/plugins/PluginCatalogCard";
import { PluginPanelDialog } from "@/components/plugins/PluginPanelDialog";
import { loadResolvedPluginMarketplace } from "@/lib/plugins/plugin-marketplace";
-import { GitHubMark, GitHubRepositoryLink } from "@/components/GitHubRepositoryLink";
+import { GitHubMark } from "@/components/GitHubRepositoryLink";
import { applyPluginUpdate, checkPluginUpdates, type PluginUpdateInfo } from "@/lib/plugins/plugin-updates";
import { PluginUpdateDialog } from "@/components/plugins/PluginUpdateDialog";
import { PluginSettingsSection } from "@/components/plugins/PluginSettingsSection";
+import { buildPluginCatalogItems } from "@/lib/plugins/plugin-catalog";
import { getPluginDetailPage, getPluginDetailPath, hasPluginSettings, type PluginDetailPage } from "@/lib/plugins/plugin-navigation";
import type { ScheduledTask } from "@edgeever/shared";
import { api, getOrCreateClientDeviceId } from "@/lib/api";
@@ -324,6 +326,7 @@ export const PluginManagerCard = ({
refetchInterval: 30 * 60_000,
refetchOnWindowFocus: true,
});
+ const catalogItems = buildPluginCatalogItems(marketplaceQuery.data?.entries ?? [], snapshot.extensions);
const selectedExtension = selectedPluginId
? snapshot.extensions.find((extension) => extension.manifest.id === selectedPluginId)
: undefined;
@@ -508,67 +511,6 @@ export const PluginManagerCard = ({
)
) : (
<>
- {(marketplaceQuery.data?.entries.length ?? 0) > 0 ? (
- <div className={PLUGIN_CARD_GRID_CLASS_NAME}>
- {(marketplaceQuery.data?.entries ?? []).map((entry) => {
- const installed = snapshot.extensions.find((extension) => extension.manifest.id === entry.id);
- const currentVerified = installed?.source.verified && installed.manifest.version === entry.verification.version;
- const marketplaceUpdate = updateQuery.data?.updates.find((update) => update.pluginId === entry.id && update.marketplaceEntry);
- const actionId = `marketplace:${entry.id}`;
- return (
- <article key={entry.id} className="flex min-w-0 flex-col rounded-lg border border-emerald-100 bg-white p-3">
- <div className="flex items-start justify-between gap-2">
- <div className="min-w-0">
- <div className="flex items-center gap-1.5">
- <span className="truncate text-sm font-semibold text-slate-900">{entry.name}</span>
- <BadgeCheck className="h-4 w-4 shrink-0 text-emerald-600" aria-label={t("plugins.marketplace.verified")} />
- {entry.publisher === "edgeever" ? (
- <span className="rounded-full bg-emerald-50 px-2 py-0.5 text-[10px] font-semibold text-emerald-700">
- {t("plugins.marketplace.officialAutoUpdate")}
- </span>
- ) : null}
- </div>
- <div className="mt-0.5 text-[10px] text-slate-400">{entry.author} · {entry.category} · v{entry.verification.version}</div>
- </div>
- <GitHubRepositoryLink
- href={entry.repositoryUrl}
- label={t("plugins.marketplace.openRepository", { name: entry.name })}
- showTooltip={false}
- className="h-7 w-7 shrink-0 justify-center rounded p-1 text-slate-400 hover:bg-slate-100 hover:text-slate-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-500/70"
- iconClassName="h-3.5 w-3.5"
- />
- </div>
- <p className="mt-2 line-clamp-2 text-xs leading-5 text-slate-500">{entry.description}</p>
- <Button
- size="sm"
- variant={currentVerified ? "soft" : "outline"}
- className="mt-3 h-8 gap-1.5 text-xs"
- disabled={Boolean(currentVerified) || pendingId === actionId || Boolean(installed?.source.kind === "marketplace" && !marketplaceUpdate)}
- onClick={() => {
- if (marketplaceUpdate) {
- setPendingUpdate(marketplaceUpdate);
- return;
- }
- void run(actionId, async () => { await host.installMarketplaceEntry(entry); });
- }}
- >
- <Download className="h-3.5 w-3.5" />
- {pendingId === actionId
- ? t("plugins.installing")
- : marketplaceUpdate
- ? t("plugins.updates.update")
- : currentVerified
- ? t("plugins.marketplace.installed")
- : installed
- ? t("plugins.marketplace.installVerified")
- : t("plugins.install")}
- </Button>
- </article>
- );
- })}
- </div>
- ) : null}
-
<div className="flex flex-col gap-2 sm:flex-row">
<Input
aria-label={t("plugins.installSource")}
@@ -582,150 +524,43 @@ export const PluginManagerCard = ({
</Button>
</div>
- {snapshot.extensions.length === 0 ? (
+ {marketplaceQuery.isLoading && catalogItems.length === 0 ? null : catalogItems.length === 0 ? (
<div className="rounded-lg border border-dashed border-slate-200 p-5 text-center text-xs text-slate-500">
{t("plugins.empty")}
</div>
) : (
<div className={PLUGIN_CARD_GRID_CLASS_NAME}>
- {snapshot.extensions.map((extension) => {
- const id = extension.manifest.id;
- const availableUpdate = updateQuery.data?.updates.find((update) => update.pluginId === id);
- const commands = snapshot.commands.filter((command) => command.pluginId === id);
- const panels = snapshot.panels.filter((panel) => panel.pluginId === id);
- return (
- <section
- key={id}
- role="link"
- tabIndex={0}
- aria-label={t("plugins.details.open", { name: extension.manifest.name })}
- className="flex min-w-0 cursor-pointer flex-col rounded-lg border border-slate-200 bg-white p-3 transition-colors hover:border-emerald-300 hover:bg-emerald-50/20 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-500/70"
- onClick={(event) => {
- if ((event.target as HTMLElement).closest("button, a")) return;
- onOpenPlugin?.(id);
- }}
- onKeyDown={(event) => {
- if (event.target === event.currentTarget && (event.key === "Enter" || event.key === " ")) {
- event.preventDefault();
- onOpenPlugin?.(id);
- }
- }}
- >
- <div className="flex items-start justify-between gap-3">
- <div className="min-w-0 flex-1">
- <div className="flex flex-wrap items-center gap-1.5">
- <span className="truncate text-sm font-semibold text-slate-900">{extension.manifest.name}</span>
- <span className="rounded bg-slate-100 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-slate-500">
- {extension.manifest.type}
- </span>
- <span className="text-[11px] text-slate-400">v{extension.manifest.version}</span>
- {availableUpdate ? (
- <span className="rounded-full bg-emerald-100 px-2 py-0.5 text-[10px] font-semibold text-emerald-700">
- {t("plugins.updates.available", { version: availableUpdate.latestVersion })}
- </span>
- ) : null}
- <span className={`inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[10px] ${extension.source.verified ? "bg-emerald-50 text-emerald-700" : "bg-amber-50 text-amber-700"}`}>
- {extension.source.verified ? <BadgeCheck className="h-3 w-3" /> : extension.source.kind === "github" ? <GitHubMark className="h-3 w-3" /> : null}
- {t(`plugins.sources.${extension.source.verified ? "verified" : extension.source.kind}`)}
- </span>
- </div>
- {extension.manifest.description ? <p className="mt-1 line-clamp-2 text-xs leading-5 text-slate-500">{extension.manifest.description}</p> : null}
- </div>
- <div className="flex shrink-0 items-center gap-1">
- {extension.source.repositoryUrl ? (
- <GitHubRepositoryLink
- href={extension.source.repositoryUrl}
- label={t("plugins.marketplace.openRepository", { name: extension.manifest.name })}
- showTooltip={false}
- className="h-7 w-7 justify-center rounded p-1 text-slate-400 hover:bg-slate-100 hover:text-slate-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-emerald-500/70"
- iconClassName="h-3.5 w-3.5"
- />
- ) : null}
- <Switch
- aria-label={t("plugins.toggle", { name: extension.manifest.name })}
- checked={extension.enabled}
- disabled={pendingId === id}
- onCheckedChange={(enabled) => toggleExtension(extension, enabled)}
- />
- </div>
- </div>
-
- {extension.manifest.type === "plugin" && extension.manifest.permissions.length > 0 ? (
- <div className="mt-2 flex flex-wrap gap-1">
- {extension.manifest.permissions.slice(0, 3).map((permission) => (
- <span key={permission} className="rounded-full bg-slate-100 px-2 py-0.5 text-[10px] text-slate-600">
- {permission === "network:public" ? t("plugins.permissions.publicNetwork") : permissionLabel(permission)}
- </span>
- ))}
- {extension.manifest.permissions.length > 3 ? (
- <span className="rounded-full bg-slate-100 px-2 py-0.5 text-[10px] text-slate-600">
- +{extension.manifest.permissions.length - 3}
- </span>
- ) : null}
- </div>
- ) : null}
-
- {extension.error ? <div className="mt-2 text-xs text-rose-600">{extension.error}</div> : null}
-
- <div className="mt-auto flex flex-wrap items-center gap-1.5 pt-3">
- {hasPluginSettings(extension.manifest) ? (
- <Button asChild size="sm" variant="outline" className="h-8 gap-1.5 text-xs">
- <Link to={getPluginDetailPath(id, "settings")} aria-label={t("plugins.settings.open", { name: extension.manifest.name })}>
- <Settings2 className="h-3.5 w-3.5" />
- {t("plugins.settings.title")}
- </Link>
- </Button>
- ) : null}
- {availableUpdate ? (
- <Button
- size="sm"
- className="h-8 gap-1.5 text-xs"
- disabled={pendingId === `update:${id}`}
- onClick={() => setPendingUpdate(availableUpdate)}
- >
- <Download className="h-3.5 w-3.5" />
- {t("plugins.updates.update")}
- </Button>
- ) : null}
- {commands.map((command) => (
- <Button
- key={command.id}
- size="sm"
- variant="outline"
- className="h-8 gap-1.5 text-xs"
- disabled={pendingId === `${id}:${command.id}`}
- onClick={() => void run(`${id}:${command.id}`, () => host.runCommand(id, command.id))}
- >
- <Play className="h-3.5 w-3.5" />
- {command.title}
- </Button>
- ))}
- {panels.map((panel) => (
- <Button
- key={panel.id}
- size="sm"
- variant="outline"
- className="h-8 gap-1.5 text-xs"
- onClick={() => setActivePanel(panel)}
- >
- <PanelRightOpen className="h-3.5 w-3.5" />
- {panel.title}
- </Button>
- ))}
- <Button
- size="sm"
- variant="ghost"
- className="ml-auto h-8 gap-1.5 text-xs text-rose-600 hover:bg-rose-50 hover:text-rose-700"
- disabled={pendingId === `remove:${id}`}
- onClick={() => void run(`remove:${id}`, () => host.uninstall(id))}
- >
- <Trash2 className="h-3.5 w-3.5" />
- {t("plugins.uninstall")}
- </Button>
- </div>
- </section>
- );
- })}
+ {catalogItems.map((item) => (
+ <PluginCatalogCard
+ key={item.id}
+ item={item}
+ update={updateQuery.data?.updates.find((update) => update.pluginId === item.id)}
+ commands={snapshot.commands.filter((command) => command.pluginId === item.id)}
+ panels={snapshot.panels.filter((panel) => panel.pluginId === item.id)}
+ pendingId={pendingId}
+ onOpenPlugin={onOpenPlugin}
+ onToggle={(enabled) => {
+ if (item.extension) toggleExtension(item.extension, enabled);
+ }}
+ onInstallMarketplace={() => {
+ const entry = item.marketplaceEntry;
+ if (!entry) return;
+ void run(`marketplace:${item.id}`, async () => {
+ await host.installMarketplaceEntry(entry);
+ });
+ }}
+ onUpdate={() => {
+ const nextUpdate = updateQuery.data?.updates.find((candidate) => candidate.pluginId === item.id);
+ if (nextUpdate) setPendingUpdate(nextUpdate);
+ }}
+ onRunCommand={(command) => void run(
+ `${item.id}:${command.id}`,
+ () => host.runCommand(item.id, command.id),
+ )}
+ onOpenPanel={setActivePanel}
+ onUninstall={() => void run(`remove:${item.id}`, () => host.uninstall(item.id))}
+ />
+ ))}
</div>
)}
</>
diff --git a/apps/web/src/lib/plugins/plugin-catalog.test.mjs b/apps/web/src/lib/plugins/plugin-catalog.test.mjs
new file mode 100644
index 00000000..db948c5f
--- /dev/null
+++ b/apps/web/src/lib/plugins/plugin-catalog.test.mjs
@@ -0,0 +1,133 @@
+import { describe, expect, test } from "bun:test";
+import {
+ buildPluginCatalogItems,
+ canReplaceWithVerifiedMarketplace,
+ getPluginCatalogDescription,
+ getPluginCatalogName,
+ getPluginCatalogRepositoryUrl,
+ getPluginCatalogSourceKey,
+ getPluginCatalogVersion,
+} from "./plugin-catalog.ts";
+
+const marketplaceEntry = (overrides = {}) => ({
+ id: "org.edgeever.plugins.ai-rss",
+ name: "EdgeEver AI RSS",
+ description: "Official RSS digest",
+ author: "EdgeEver",
+ publisher: "edgeever",
+ category: "News & AI",
+ repositoryUrl: "https://github.com/tianma-if/edgeever-ai-rss",
+ distribution: { type: "github", repositoryUrl: "https://github.com/tianma-if/edgeever-ai-rss" },
+ verification: { version: "0.5.3" },
+ ...overrides,
+});
+
+const extension = (overrides = {}) => {
+ const { manifest, source, ...rest } = overrides;
+ return {
+ manifestUrl: "https://example.com/manifest.json",
+ manifest: {
+ type: "plugin",
+ id: "org.edgeever.plugins.ai-rss",
+ name: "EdgeEver AI RSS",
+ version: "0.5.3",
+ description: "Installed RSS digest",
+ ...manifest,
+ },
+ enabled: true,
+ installedAt: "2026-09-01T00:00:00.000Z",
+ error: null,
+ source: {
+ kind: "marketplace",
+ verified: true,
+ repositoryUrl: "https://github.com/tianma-if/edgeever-ai-rss",
+ ...source,
+ },
+ ...rest,
+ };
+};
+
+describe("plugin catalog items", () => {
+ test("keeps marketplace order, attaches installs, and appends sideloaded plugins once", () => {
+ const official = marketplaceEntry();
+ const community = marketplaceEntry({
+ id: "com.example.tasks",
+ name: "Tasks",
+ publisher: undefined,
+ repositoryUrl: "https://github.com/example/tasks",
+ });
+ const installedOfficial = extension();
+ const sideloaded = extension({
+ manifest: { id: "com.example.calendar", name: "Calendar", version: "1.0.0" },
+ source: { kind: "github", verified: false, repositoryUrl: "https://github.com/example/calendar" },
+ });
+
+ const items = buildPluginCatalogItems([official, community], [installedOfficial, sideloaded]);
+
+ expect(items.map((item) => item.id)).toEqual([official.id, community.id, sideloaded.manifest.id]);
+ expect(items[0]?.extension).toBe(installedOfficial);
+ expect(items[1]?.extension).toBeUndefined();
+ expect(items[2]?.marketplaceEntry).toBeUndefined();
+ });
+
+ test("does not duplicate an installed marketplace plugin", () => {
+ const official = marketplaceEntry();
+ const items = buildPluginCatalogItems([official], [extension()]);
+ expect(items).toHaveLength(1);
+ expect(items[0]?.marketplaceEntry).toBe(official);
+ expect(items[0]?.extension?.manifest.id).toBe(official.id);
+ });
+
+ test("treats official publisher as a badge, not a separate catalog group", () => {
+ const official = { id: "official", marketplaceEntry: marketplaceEntry() };
+ const community = {
+ id: "community",
+ marketplaceEntry: marketplaceEntry({ id: "com.example.tasks", publisher: undefined }),
+ };
+ const github = {
+ id: "github",
+ extension: extension({
+ manifest: { id: "com.example.calendar" },
+ source: { kind: "github", verified: false },
+ }),
+ };
+
+ expect(getPluginCatalogSourceKey(official)).toBe("official");
+ expect(getPluginCatalogSourceKey(community)).toBe("verified");
+ expect(getPluginCatalogSourceKey(github)).toBe("github");
+ });
+
+ test("offers replace-with-verified only for sideloaded installs listed in the marketplace", () => {
+ const marketplaceInstall = {
+ id: "org.edgeever.plugins.ai-rss",
+ marketplaceEntry: marketplaceEntry(),
+ extension: extension(),
+ };
+ const sideloadedListed = {
+ id: "org.edgeever.plugins.ai-rss",
+ marketplaceEntry: marketplaceEntry(),
+ extension: extension({ source: { kind: "github", verified: false } }),
+ };
+ const uninstalled = { id: "org.edgeever.plugins.ai-rss", marketplaceEntry: marketplaceEntry() };
+
+ expect(canReplaceWithVerifiedMarketplace(marketplaceInstall)).toBe(false);
+ expect(canReplaceWithVerifiedMarketplace(sideloadedListed)).toBe(true);
+ expect(canReplaceWithVerifiedMarketplace(uninstalled)).toBe(false);
+ });
+
+ test("prefers installed metadata when a marketplace plugin is already present", () => {
+ const item = {
+ id: "org.edgeever.plugins.ai-rss",
+ marketplaceEntry: marketplaceEntry({ name: "Market name", description: "Market copy", verification: { version: "0.5.2" } }),
+ extension: extension({
+ manifest: { name: "Installed name", description: "Installed copy", version: "0.5.3" },
+ source: { repositoryUrl: "https://github.com/tianma-if/edgeever-ai-rss" },
+ }),
+ };
+
+ expect(getPluginCatalogName(item)).toBe("Installed name");
+ expect(getPluginCatalogDescription(item)).toBe("Installed copy");
+ expect(getPluginCatalogVersion(item)).toBe("0.5.3");
+ expect(getPluginCatalogRepositoryUrl(item)).toBe("https://github.com/tianma-if/edgeever-ai-rss");
+ });
+});
diff --git a/apps/web/src/lib/plugins/plugin-catalog.ts b/apps/web/src/lib/plugins/plugin-catalog.ts
new file mode 100644
index 00000000..a7fda5c4
--- /dev/null
+++ b/apps/web/src/lib/plugins/plugin-catalog.ts
@@ -0,0 +1,50 @@
+import type { MarketplaceEntry } from "@edgeever/plugin-api";
+import type { InstalledExtension } from "./plugin-host";
+
+export interface PluginCatalogItem {
+ id: string;
+ marketplaceEntry?: MarketplaceEntry;
+ extension?: InstalledExtension;
+}
+
+export type PluginCatalogSourceKey = "official" | "verified" | "github" | "manifest" | "marketplace";
+
+export const buildPluginCatalogItems = (
+ marketplaceEntries: readonly MarketplaceEntry[],
+ extensions: readonly InstalledExtension[],
+): PluginCatalogItem[] => {
+ const extensionsById = new Map(extensions.map((extension) => [extension.manifest.id, extension]));
+ const items: PluginCatalogItem[] = marketplaceEntries.map((marketplaceEntry) => ({
+ id: marketplaceEntry.id,
+ marketplaceEntry,
+ extension: extensionsById.get(marketplaceEntry.id),
+ }));
+ const marketplaceIds = new Set(marketplaceEntries.map((entry) => entry.id));
+ for (const extension of extensions) {
+ if (!marketplaceIds.has(extension.manifest.id)) {
+ items.push({ id: extension.manifest.id, extension });
+ }
+ }
+ return items;
+};
+
+export const getPluginCatalogSourceKey = (item: PluginCatalogItem): PluginCatalogSourceKey | null => {
+ if (item.marketplaceEntry?.publisher === "edgeever") return "official";
+ if (item.marketplaceEntry || item.extension?.source.verified) return "verified";
+ return item.extension?.source.kind ?? null;
+};
+
+export const getPluginCatalogName = (item: PluginCatalogItem) =>
+ item.extension?.manifest.name ?? item.marketplaceEntry?.name ?? item.id;
+
+export const getPluginCatalogDescription = (item: PluginCatalogItem) =>
+ item.extension?.manifest.description ?? item.marketplaceEntry?.description ?? "";
+
+export const getPluginCatalogRepositoryUrl = (item: PluginCatalogItem) =>
+ item.extension?.source.repositoryUrl ?? item.marketplaceEntry?.repositoryUrl;
+
+export const getPluginCatalogVersion = (item: PluginCatalogItem) =>
+ item.extension?.manifest.version ?? item.marketplaceEntry?.verification.version;
+
+export const canReplaceWithVerifiedMarketplace = (item: PluginCatalogItem) =>
+ Boolean(item.extension && item.marketplaceEntry && item.extension.source.kind !== "marketplace");
diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.ts
index 00be90a5..514beb32 100644
--- a/packages/shared/src/i18n/en-US.ts
+++ b/packages/shared/src/i18n/en-US.ts
@@ -753,9 +753,7 @@ export const enUS = {
loading: "Loading plugin marketplace…",
loadFailed: "Could not load the plugin marketplace: {{message}}",
retry: "Try again",
- verified: "Verified by EdgeEver",
officialAutoUpdate: "Official · auto-updates",
- installed: "Verified version installed",
installVerified: "Replace with verified version",
openRepository: "Open the source repository for {{name}}",
},
diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.ts
index 311dfa3f..f637774a 100644
--- a/packages/shared/src/i18n/zh-CN.ts
+++ b/packages/shared/src/i18n/zh-CN.ts
@@ -753,9 +753,7 @@ export const zhCN = {
loading: "正在加载插件市场…",
loadFailed: "无法加载插件市场:{{message}}",
retry: "重试",
- verified: "EdgeEver 已验证",
officialAutoUpdate: "官方 · 自动更新",
- installed: "已安装验证版本",
installVerified: "替换为验证版本",
openRepository: "打开 {{name}} 的源代码仓库",
},