Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(plugins): rebuild the plugin section as a directory with a sidebar (#639)

Ruben Lütke593f7b018124
diff --git a/jarvis/ui/web/frontend/src/components/layout/MainView.plugins.test.tsx b/jarvis/ui/web/frontend/src/components/layout/MainView.plugins.test.tsx
index 6fb27a5a9c..871adea4b0 100644
--- a/jarvis/ui/web/frontend/src/components/layout/MainView.plugins.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/layout/MainView.plugins.test.tsx
@@ -1,4 +1,4 @@
-import { act, cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
+import { act, cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
import { afterEach, beforeEach, expect, it, vi } from "vitest";
import { MainView } from "./MainView";
import { useEventStore } from "@/store/events";
@@ -7,7 +7,12 @@ vi.mock("@/views/ChatsSurface", () => ({
ChatsSurface: () => <input aria-label="Unsent message" defaultValue="A draft" />,
}));
vi.mock("@/views/PluginsView", () => ({
- PluginsView: ({ inDialog }: { inDialog: boolean }) => <div>Catalog {String(inDialog)}</div>,
+ PluginsView: () => <div>Catalog</div>,
+ // The section sidebar lists installed plugins from the shared catalog.
+ usePluginCatalog: () => ({ plugins: [], isLoading: false, error: null, refetch: () => {} }),
+ BrandTile: () => null,
+ matchesQuery: () => true,
+ sortPluginsByName: () => 0,
}));
vi.mock("@/views/SkillsView", () => ({ SkillsView: () => <input aria-label="Skill search" /> }));
vi.mock("@/views/McpsView", () => ({ McpsView: () => <div>MCP content</div> }));
@@ -21,7 +26,7 @@ it("opens a bounded dialog while preserving the current draft and restores that
fireEvent.change(draft, { target: { value: "Keep this draft" } });
act(() => useEventStore.getState().setActiveSection("plugins"));
await screen.findByRole("dialog", { name: "Plugins" });
- expect(screen.getByText("Catalog true")).toBeDefined();
+ expect(screen.getByText("Catalog")).toBeDefined();
expect(screen.getByLabelText("Unsent message")).toBe(draft);
fireEvent.click(screen.getByRole("button", { name: "Close" }));
await waitFor(() => expect(screen.queryByRole("dialog")).toBeNull());
@@ -36,14 +41,15 @@ it("routes Skills and MCPs into the same dialog and keeps the original backgroun
act(() => useEventStore.getState().setActiveSection("skills"));
await screen.findByLabelText("Skill search");
const dialog = screen.getByRole("dialog");
- expect(screen.getByRole("tab", { name: "Skills" }).getAttribute("aria-selected")).toBe("true");
+ expect(screen.getByRole("button", { name: "Skills" }).getAttribute("aria-current")).toBe("page");
act(() => useEventStore.getState().setActiveSection("mcps"));
await screen.findByText("MCP content");
expect(screen.getByRole("dialog")).toBe(dialog);
- expect(screen.getByRole("tab", { name: "MCPs" }).getAttribute("aria-selected")).toBe("true");
- expect(screen.getAllByRole("tab").map((tab) => tab.textContent)).toEqual(["Plugins", "MCPs", "Skills"]);
- fireEvent.mouseDown(screen.getByRole("tab", { name: "Plugins" }), { button: 0, ctrlKey: false });
- await screen.findByText("Catalog true");
+ expect(screen.getByRole("button", { name: "MCPs" }).getAttribute("aria-current")).toBe("page");
+ const areas = screen.getByRole("navigation", { name: "Plugins, MCPs & Skills" });
+ expect(within(areas).getAllByRole("button").map((area) => area.textContent)).toEqual(["Plugins", "MCPs", "Skills"]);
+ fireEvent.click(screen.getByRole("button", { name: "Plugins" }));
+ await screen.findByText("Catalog");
expect(useEventStore.getState().activeSection).toBe("plugins");
expect(screen.getByLabelText("Unsent message")).toBe(draft);
fireEvent.keyDown(document, { key: "Escape" });
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index 86ad3ff0ad..86d8744d7d 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -1627,6 +1627,29 @@
"discord_add_bot": "Bot zu meinem Server hinzufügen",
"owner_lock_digits": "Die Nutzer-ID darf nur Ziffern enthalten.",
"validating": "Wird geprüft…",
+ "subtitle": "Verbinde deine Tools, damit deine Agenten damit arbeiten können",
+ "breadcrumb": "Navigationspfad",
+ "section_popular": "Beliebt",
+ "section_uploaded": "Von dir hinzugefügt",
+ "section_community": "Aus der Community",
+ "open_section": "Alle aus {section} anzeigen",
+ "open_details": "Details öffnen",
+ "manage": "Installierte Plugins verwalten",
+ "manage_title": "Installierte Plugins",
+ "manage_subtitle": "Alle Plugins, die du verbunden oder hinzugefügt hast, mit ihrem Verbindungsstatus",
+ "scope_label": "Plugin-Verzeichnis",
+ "scope_catalog": "Mitgeliefert",
+ "scope_yours": "Deine",
+ "yours_empty_title": "Noch nichts hinzugefügt",
+ "yours_empty_body": "Füge ein Plugin über seine Serveradresse hinzu, lade einen Ordner hoch oder wähle eines aus der Community.",
+ "installed_heading": "Installiert",
+ "installed_search": "Installierte Plugins durchsuchen",
+ "installed_empty": "Noch keine Plugins verbunden",
+ "installed_no_match": "Keine passenden Plugins",
+ "frame_title": "Erweiterungen",
+ "plugin_fallback": "Plugin",
+ "detail_files": "Dateien",
+ "detail_information": "Informationen",
"longevity_note": {
"github": "Die Browser-Anmeldung erneuert sich automatisch. Eingefügte Tokens laufen ab wie beim Erstellen festgelegt.",
"discord": "OAuth-Tokens erneuern sich automatisch. Ein eingefügtes Bot-Token bleibt gültig, bis du es im Discord-Entwicklerportal zurücksetzt.",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index db84569e7a..169c7d6ec7 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -1627,6 +1627,29 @@
"discord_add_bot": "Add the bot to my server",
"owner_lock_digits": "User id must be digits only.",
"validating": "Validating…",
+ "subtitle": "Connect your tools so your agents can work across them",
+ "breadcrumb": "Breadcrumb",
+ "section_popular": "Popular",
+ "section_uploaded": "Added by you",
+ "section_community": "From the community",
+ "open_section": "Show all of {section}",
+ "open_details": "Open details",
+ "manage": "Manage installed plugins",
+ "manage_title": "Installed plugins",
+ "manage_subtitle": "Every plugin you connected or added, with its connection state",
+ "scope_label": "Plugin directory",
+ "scope_catalog": "Built in",
+ "scope_yours": "Yours",
+ "yours_empty_title": "Nothing added yet",
+ "yours_empty_body": "Add a plugin by its server address, upload a folder, or pick one from the community.",
+ "installed_heading": "Installed",
+ "installed_search": "Search installed plugins",
+ "installed_empty": "No plugins connected yet",
+ "installed_no_match": "No matching plugins",
+ "frame_title": "Extensions",
+ "plugin_fallback": "Plugin",
+ "detail_files": "Files",
+ "detail_information": "Information",
"longevity_note": {
"github": "Browser login renews automatically. Pasted tokens expire as configured at creation.",
"discord": "OAuth tokens refresh automatically. A pasted bot token stays valid until you reset it in the Discord developer portal.",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index 1001b00e50..111bcbc41d 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -1627,6 +1627,29 @@
"discord_add_bot": "Añadir el bot a mi servidor",
"owner_lock_digits": "El ID de usuario solo puede contener dígitos.",
"validating": "Validando…",
+ "subtitle": "Conecta tus herramientas para que tus agentes trabajen con ellas",
+ "breadcrumb": "Ruta de navegación",
+ "section_popular": "Populares",
+ "section_uploaded": "Añadidos por ti",
+ "section_community": "De la comunidad",
+ "open_section": "Mostrar todo en {section}",
+ "open_details": "Abrir detalles",
+ "manage": "Gestionar plugins instalados",
+ "manage_title": "Plugins instalados",
+ "manage_subtitle": "Todos los plugins que conectaste o añadiste, con su estado de conexión",
+ "scope_label": "Directorio de plugins",
+ "scope_catalog": "Incluidos",
+ "scope_yours": "Tuyos",
+ "yours_empty_title": "Aún no has añadido nada",
+ "yours_empty_body": "Añade un plugin con la dirección de su servidor, sube una carpeta o elige uno de la comunidad.",
+ "installed_heading": "Instalados",
+ "installed_search": "Buscar plugins instalados",
+ "installed_empty": "Aún no hay plugins conectados",
+ "installed_no_match": "Ningún plugin coincide",
+ "frame_title": "Extensiones",
+ "plugin_fallback": "Plugin",
+ "detail_files": "Archivos",
+ "detail_information": "Información",
"longevity_note": {
"github": "El inicio de sesión en el navegador se renueva automáticamente. Los tokens pegados caducan según lo configurado al crearlos.",
"discord": "Los tokens OAuth se renuevan automáticamente. Un token de bot pegado sigue siendo válido hasta que lo restablezcas en el portal para desarrolladores de Discord.",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/pt.json b/jarvis/ui/web/frontend/src/i18n/locales/pt.json
index 9df813de03..6b00cf2cc9 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/pt.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/pt.json
@@ -1627,6 +1627,29 @@
"discord_add_bot": "Adicionar o bot ao meu servidor",
"owner_lock_digits": "O ID de utilizador só pode ter algarismos.",
"validating": "A validar…",
+ "subtitle": "Liga as tuas ferramentas para que os teus agentes trabalhem com elas",
+ "breadcrumb": "Caminho de navegação",
+ "section_popular": "Populares",
+ "section_uploaded": "Adicionados por ti",
+ "section_community": "Da comunidade",
+ "open_section": "Mostrar tudo em {section}",
+ "open_details": "Abrir detalhes",
+ "manage": "Gerir plugins instalados",
+ "manage_title": "Plugins instalados",
+ "manage_subtitle": "Todos os plugins que ligaste ou adicionaste, com o estado da ligação",
+ "scope_label": "Diretório de plugins",
+ "scope_catalog": "Incluídos",
+ "scope_yours": "Teus",
+ "yours_empty_title": "Ainda nada adicionado",
+ "yours_empty_body": "Adiciona um plugin pelo endereço do servidor, envia uma pasta ou escolhe um da comunidade.",
+ "installed_heading": "Instalados",
+ "installed_search": "Procurar plugins instalados",
+ "installed_empty": "Ainda nenhum plugin ligado",
+ "installed_no_match": "Nenhum plugin corresponde",
+ "frame_title": "Extensões",
+ "plugin_fallback": "Plugin",
+ "detail_files": "Ficheiros",
+ "detail_information": "Informações",
"longevity_note": {
"github": "O início de sessão no browser renova-se automaticamente. Os tokens colados expiram conforme configurado na criação.",
"discord": "Os tokens OAuth renovam-se automaticamente. Um token de bot colado continua válido até o repores no portal de programadores do Discord.",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/zh.json b/jarvis/ui/web/frontend/src/i18n/locales/zh.json
index 940978d35f..2ab4704c80 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/zh.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/zh.json
@@ -1627,6 +1627,29 @@
"discord_add_bot": "将机器人添加到我的服务器",
"owner_lock_digits": "用户 ID 只能包含数字。",
"validating": "正在验证…",
+ "subtitle": "连接你的工具,让智能体可以跨工具工作",
+ "breadcrumb": "导航路径",
+ "section_popular": "热门",
+ "section_uploaded": "由你添加",
+ "section_community": "来自社区",
+ "open_section": "显示{section}的全部插件",
+ "open_details": "打开详情",
+ "manage": "管理已安装的插件",
+ "manage_title": "已安装的插件",
+ "manage_subtitle": "你连接或添加的所有插件及其连接状态",
+ "scope_label": "插件目录",
+ "scope_catalog": "内置",
+ "scope_yours": "我的",
+ "yours_empty_title": "尚未添加任何插件",
+ "yours_empty_body": "通过服务器地址添加插件、上传文件夹,或从社区中选择一个。",
+ "installed_heading": "已安装",
+ "installed_search": "搜索已安装的插件",
+ "installed_empty": "尚未连接任何插件",
+ "installed_no_match": "没有匹配的插件",
+ "frame_title": "扩展",
+ "plugin_fallback": "插件",
+ "detail_files": "文件",
+ "detail_information": "信息",
"longevity_note": {
"github": "浏览器登录会自动续期。粘贴的令牌按创建时的设置过期。",
"discord": "OAuth 令牌会自动刷新。粘贴的机器人令牌在你于 Discord 开发者门户中重置之前一直有效。",
diff --git a/jarvis/ui/web/frontend/src/views/MarketplaceOrigin.test.tsx b/jarvis/ui/web/frontend/src/views/MarketplaceOrigin.test.tsx
index 1cdaf67a47..7b7a94f677 100644
--- a/jarvis/ui/web/frontend/src/views/MarketplaceOrigin.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/MarketplaceOrigin.test.tsx
@@ -8,7 +8,7 @@
* cannot find it.
*/
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
-import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
+import { cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
import { afterEach, describe, expect, it, vi } from "vitest";
import { PluginsView } from "@/views/PluginsView";
@@ -72,7 +72,7 @@ afterEach(() => {
});
describe("an installed community plugin is findable", () => {
- it("counts in the Installed tab even before it is connected", async () => {
+ it("is listed under what the owner added, and as installed, before it is connected", async () => {
mockCatalog([SEED_PLUGIN, INSTALLED_COMMUNITY_PLUGIN]);
render(
<QueryClientProvider client={client()}>
@@ -81,18 +81,22 @@ describe("an installed community plugin is findable", () => {
);
// The shipped catalog is always "available", so a community plugin that
- // only showed up in the full list was indistinguishable from the ones the
- // app came with — Installed is where somebody looks for what they added.
- const installedTab = await screen.findByRole("tab", { name: /^Installed\b/i });
- await waitFor(() => {
- expect(installedTab.textContent).toContain("1");
- });
+ // only showed up among it was indistinguishable from the ones the app came
+ // with — its own scope is where somebody looks for what they added.
+ await screen.findByText("GitHub");
+ expect(screen.queryByText("TodoFox")).toBeNull();
+ fireEvent.click(screen.getByRole("tab", { name: "Yours" }));
+ const community = await screen.findByRole("region", { name: "From the community" });
+ expect(within(community).getByText("TodoFox")).toBeDefined();
+ // The seed plugin is NOT the owner's and must not have followed it in.
+ expect(screen.queryByText("GitHub")).toBeNull();
- fireEvent.click(installedTab);
+ // Installed, connected or not: the installed list carries it too.
+ fireEvent.click(screen.getByRole("button", { name: "Manage installed plugins" }));
await waitFor(() => {
- expect(screen.getByText("TodoFox")).toBeDefined();
+ expect(screen.getByText("Not connected")).toBeDefined();
});
- // The seed plugin is NOT installed and must not have followed it in.
+ expect(screen.getByText("TodoFox")).toBeDefined();
expect(screen.queryByText("GitHub")).toBeNull();
});
@@ -104,6 +108,7 @@ describe("an installed community plugin is findable", () => {
</QueryClientProvider>,
);
+ fireEvent.click(await screen.findByRole("tab", { name: "Yours" }));
await waitFor(() => {
expect(screen.getByText("TodoFox")).toBeDefined();
});
diff --git a/jarvis/ui/web/frontend/src/views/PluginsDialog.test.tsx b/jarvis/ui/web/frontend/src/views/PluginsDialog.test.tsx
index 79687bd84d..e64bf4ff9d 100644
--- a/jarvis/ui/web/frontend/src/views/PluginsDialog.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/PluginsDialog.test.tsx
@@ -20,51 +20,74 @@ function setup() {
render(<QueryClientProvider client={query}><PluginsDialog onClose={onClose} /></QueryClientProvider>);
return { onClose };
}
+/** The page beside the sidebar; the sidebar lists installed plugins by the same names. */
+const pane = () => within(screen.getByTestId("plugin-catalog-dialog").querySelector<HTMLElement>("[data-plugin-pane]")!);
+const installedList = () => within(screen.getByRole("list", { name: "Installed" }));
afterEach(() => { cleanup(); vi.unstubAllGlobals(); vi.restoreAllMocks(); });
-it("shows recommendations, larger icon tiles and descriptions with an always visible search", async () => {
+it("opens on the directory with its sections, descriptions and an always visible search", async () => {
setup();
- const gmail = await screen.findByRole("button", { name: "Gmail" });
- expect(gmail.querySelector(".h-12.w-12")).not.toBeNull();
- expect(screen.getByText("Search and read your mail")).toBeDefined();
- expect(screen.getByRole("tab", { name: "Recommended" }).getAttribute("aria-selected")).toBe("true");
- expect(screen.queryByRole("button", { name: "Outlook" })).toBeNull();
- fireEvent.change(screen.getByRole("searchbox"), { target: { value: "Microsoft" } });
- await screen.findByRole("button", { name: "Outlook" });
- expect(screen.queryByRole("button", { name: "Gmail" })).toBeNull();
+ await pane().findByRole("button", { name: "Gmail" });
+ expect(pane().getByText("Search and read your mail")).toBeDefined();
+ // Featured picks lead and are not repeated: GitHub is Developer's only plugin,
+ // so that section has nothing left to show on the home page.
+ expect(pane().getAllByRole("heading", { level: 3 }).map((heading) => heading.textContent)).toEqual(["Popular", "Calendar & Mail"]);
+ expect(pane().getAllByRole("button", { name: "GitHub" })).toHaveLength(1);
+ fireEvent.change(pane().getByRole("searchbox"), { target: { value: "Microsoft" } });
+ await pane().findByRole("button", { name: "Outlook" });
+ expect(pane().queryByRole("button", { name: "Gmail" })).toBeNull();
});
-it("groups all plugins in product category order and keeps installed filtering functional", async () => {
+it("lists what is installed in the sidebar and opens a plugin page from there", async () => {
setup();
- await screen.findByRole("button", { name: "Gmail" });
- fireEvent.click(screen.getByRole("tab", { name: "All 3" }));
- expect(screen.getAllByRole("heading", { level: 3 }).map((heading) => heading.textContent)).toEqual(["Calendar & Mail", "Developer"]);
- fireEvent.click(screen.getByRole("tab", { name: "Installed 1" }));
- expect(screen.getByRole("button", { name: "Gmail" })).toBeDefined();
- expect(screen.queryByRole("button", { name: "GitHub" })).toBeNull();
+ const gmail = await installedList().findByRole("button", { name: "Gmail" });
+ // Only what was connected or added: the untouched plugins stay in the directory.
+ expect(installedList().getAllByRole("listitem")).toHaveLength(1);
+ fireEvent.click(gmail);
+ const crumbs = within(await pane().findByRole("navigation", { name: "Breadcrumb" }));
+ expect(crumbs.getByText("Gmail").getAttribute("aria-current")).toBe("page");
+ expect(gmail.getAttribute("aria-current")).toBe("page");
+ // "Plugins" in the sidebar always returns to the directory's home page.
+ const areas = within(screen.getByRole("navigation", { name: "Plugins, MCPs & Skills" }));
+ fireEvent.click(areas.getByRole("button", { name: "Plugins" }));
+ await pane().findByRole("region", { name: "Popular" });
+ expect(gmail.getAttribute("aria-current")).toBeNull();
});
-it("opens the category list without dismissing the tab strip", async () => {
+it("opens a section's full list without leaving the window", async () => {
setup();
- await screen.findByRole("button", { name: "Gmail" });
+ await pane().findByRole("button", { name: "Gmail" });
const dialog = screen.getByTestId("plugin-catalog-dialog");
- fireEvent.click(screen.getByTestId("plugin-window-category"));
- expect(await screen.findByRole("option", { name: "All categories" })).toBeDefined();
- expect(screen.getByRole("option", { name: "Developer" })).toBeDefined();
- expect(screen.getByRole("option", { name: "Calendar & Mail" })).toBeDefined();
- expect(screen.getByRole("tab", { name: "Plugins" })).toBeDefined();
- expect(screen.getByRole("tab", { name: "Skills" })).toBeDefined();
+ fireEvent.click(pane().getByRole("button", { name: "Show all of Calendar & Mail" }));
+ await waitFor(() => expect(pane().queryByRole("button", { name: "GitHub" })).toBeNull());
+ expect(pane().getByRole("button", { name: "Gmail" })).toBeDefined();
+ expect(pane().getByRole("button", { name: "Outlook" })).toBeDefined();
+ const areas = within(screen.getByRole("navigation", { name: "Plugins, MCPs & Skills" }));
+ expect(areas.getAllByRole("button").map((area) => area.textContent)).toEqual(["Plugins", "MCPs", "Skills"]);
expect(dialog.scrollTop).toBe(0);
});
it("closes credential setup with Escape without closing the plugin window", async () => {
const { onClose } = setup();
- const github = await screen.findByRole("button", { name: "GitHub" });
+ const [github] = await pane().findAllByRole("button", { name: "GitHub" });
const row = github.closest("li")!;
- fireEvent.click(within(row).getByRole("button", { name: "Connect" }));
+ fireEvent.click(within(row).getByRole("button", { name: "Connect plugin" }));
await screen.findByRole("dialog", { name: "Connect GitHub" });
fireEvent.keyDown(document, { key: "Escape" });
await waitFor(() => expect(screen.queryByRole("dialog", { name: "Connect GitHub" })).toBeNull());
expect(onClose).not.toHaveBeenCalled();
expect(screen.getByRole("dialog", { name: "Plugins" })).toBeDefined();
});
+
+it("closes an open menu with Escape without closing the plugin window", async () => {
+ const { onClose } = setup();
+ await pane().findByRole("button", { name: "Gmail" });
+ fireEvent.click(pane().getByRole("button", { name: "Add" }));
+ expect(screen.getByRole("menu", { name: "Add" })).toBeDefined();
+ fireEvent.keyDown(document, { key: "Escape" });
+ await waitFor(() => expect(screen.queryByRole("menu", { name: "Add" })).toBeNull());
+ expect(onClose).not.toHaveBeenCalled();
+ // With nothing open inside, Escape closes the window itself.
+ fireEvent.keyDown(document, { key: "Escape" });
+ await waitFor(() => expect(onClose).toHaveBeenCalledTimes(1));
+});
diff --git a/jarvis/ui/web/frontend/src/views/PluginsDialog.tsx b/jarvis/ui/web/frontend/src/views/PluginsDialog.tsx
index e16a970a16..ba623e035c 100644
--- a/jarvis/ui/web/frontend/src/views/PluginsDialog.tsx
+++ b/jarvis/ui/web/frontend/src/views/PluginsDialog.tsx
@@ -1,13 +1,13 @@
import { SectionWindowButton } from "@/components/layout/SectionWindowButton";
import * as Dialog from "@radix-ui/react-dialog";
-import { useRef } from "react";
+import { useRef, useState } from "react";
import { X } from "lucide-react";
import { useT } from "@/i18n";
import { isComboboxPanelEvent } from "@/components/ui/combobox";
import { PluginsView } from "@/views/PluginsView";
import { SkillsView } from "@/views/SkillsView";
import { McpsView } from "@/views/McpsView";
-import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
+import { ExtensionsSidebar } from "@/views/plugins/ExtensionsSidebar";
/** The catalog floats over the user's current work; nested setup stays inside. */
export type PluginArea = "plugins" | "mcps" | "skills";
@@ -21,16 +21,36 @@ export function PluginsDialog({ onClose, area = "plugins", onAreaChange, standal
const t = useT();
const content = useRef<HTMLDivElement>(null);
const opener = useRef(document.activeElement);
- const tabs = (
- <Tabs defaultValue={area} value={onAreaChange ? area : undefined} onValueChange={(value) => onAreaChange?.(value as PluginArea)} className="flex min-h-0 flex-1 flex-col">
- <div className="mb-2 flex shrink-0 flex-wrap items-center justify-between gap-2 px-4 pt-3">
- <TabsList aria-label={t("nav.extensions")} className="w-fit">
- <TabsTrigger value="plugins">{t("nav.plugins")}</TabsTrigger>
- <TabsTrigger value="mcps">{t("nav.mcps")}</TabsTrigger>
- <TabsTrigger value="skills">{t("nav.skills")}</TabsTrigger>
- </TabsList>
+ const [ownArea, setOwnArea] = useState<PluginArea>(area);
+ const current = onAreaChange ? area : ownArea;
+ // The open plugin page lives here, not in the plugin view: the sidebar's
+ // installed list opens it from any area.
+ const [pluginId, setPluginId] = useState<string | null>(null);
+ // Bumped when "Plugins" is chosen in the sidebar, so the directory returns
+ // to its home page instead of staying wherever it was left.
+ const [directoryVisit, setDirectoryVisit] = useState(0);
+ const showArea = (next: PluginArea) => {
+ setOwnArea(next);
+ onAreaChange?.(next);
+ };
+ const frame = (
+ <div className="flex min-h-0 flex-1 flex-col md:flex-row">
+ <ExtensionsSidebar
+ area={current}
+ selectedPluginId={current === "plugins" ? pluginId : null}
+ onArea={(next) => {
+ setPluginId(null);
+ if (next === "plugins") setDirectoryVisit((visit) => visit + 1);
+ showArea(next);
+ }}
+ onOpenPlugin={(id) => {
+ setPluginId(id);
+ showArea("plugins");
+ }}
+ />
+ <div data-plugin-pane className="relative flex min-h-0 min-w-0 flex-1 flex-col">
{!standalone && (
- <div className="ml-auto flex items-center gap-1">
+ <div className="absolute right-3 top-2.5 z-10 flex items-center gap-1">
<SectionWindowButton />
<Dialog.Close asChild>
<button type="button" aria-label={t("common.close")} className="grid h-8 w-8 place-items-center rounded-lg text-muted-foreground hover:bg-secondary hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
@@ -39,13 +59,13 @@ export function PluginsDialog({ onClose, area = "plugins", onAreaChange, standal
</Dialog.Close>
</div>
)}
+ {current === "plugins" && <PluginsView key={directoryVisit} selectedId={pluginId} onSelect={setPluginId} />}
+ {current === "skills" && <div className="min-h-0 flex-1 overflow-hidden pt-10"><SkillsView /></div>}
+ {current === "mcps" && <div className="min-h-0 flex-1 overflow-hidden pt-10"><McpsView /></div>}
</div>
- <TabsContent value="skills" className="mt-0 min-h-0 flex-1 overflow-hidden"><SkillsView /></TabsContent>
- <TabsContent value="plugins" className="mt-0 min-h-0 flex-1 overflow-hidden"><PluginsView inDialog /></TabsContent>
- <TabsContent value="mcps" className="mt-0 min-h-0 flex-1 overflow-hidden"><McpsView /></TabsContent>
- </Tabs>
+ </div>
);
- if (standalone) return <div data-testid="plugin-catalog-window" className="flex h-full min-h-0 flex-col">{tabs}</div>;
+ if (standalone) return <div data-testid="plugin-catalog-window" className="flex h-full min-h-0 flex-col">{frame}</div>;
return (
<Dialog.Root open onOpenChange={(open) => { if (!open) onClose(); }}>
<Dialog.Portal>
@@ -54,6 +74,14 @@ export function PluginsDialog({ onClose, area = "plugins", onAreaChange, standal
data-testid="plugin-catalog-dialog"
ref={content}
aria-describedby={undefined}
+ onOpenAutoFocus={(event) => {
+ // Typing should search at once. An area without a search field
+ // keeps the focus on the window itself, so no sidebar entry is
+ // ringed as if it had been chosen.
+ const search = content.current?.querySelector<HTMLInputElement>('[data-plugin-pane] input[type="search"]');
+ event.preventDefault();
+ (search ?? content.current)?.focus({ preventScroll: true });
+ }}
onCloseAutoFocus={(event) => {
const previous = opener.current;
const target = previous instanceof HTMLElement && previous.isConnected && previous !== document.body
@@ -84,13 +112,16 @@ export function PluginsDialog({ onClose, area = "plugins", onAreaChange, standal
}
}}
onEscapeKeyDown={(event) => {
- // The existing credential dialogs own Escape while they are open.
- if (content.current?.querySelector('[aria-modal="true"]')) event.preventDefault();
+ // Escape belongs to whatever is open inside the window first: a
+ // credential dialog, a menu, or a search field with text in it.
+ const inner = content.current?.querySelector('[aria-modal="true"], [role="menu"]');
+ const local = document.activeElement?.closest("[data-escape-local]");
+ if (inner || local) event.preventDefault();
}}
- className="fixed left-1/2 top-1/2 z-40 flex h-[min(82dvh,780px)] w-[min(800px,calc(100vw-24px))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-border bg-popover text-foreground shadow-float outline-none [&_[aria-modal=true]]:overflow-y-auto"
+ className="fixed left-1/2 top-1/2 z-40 flex h-[min(88dvh,860px)] w-[min(1180px,calc(100vw-24px))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-border bg-popover text-foreground shadow-float outline-none [&_[aria-modal=true]]:overflow-y-auto"
>
<Dialog.Title className="sr-only">{t("plugins_view.title")}</Dialog.Title>
- {tabs}
+ {frame}
</Dialog.Content>
</Dialog.Portal>
</Dialog.Root>
diff --git a/jarvis/ui/web/frontend/src/views/PluginsView.connectors.test.tsx b/jarvis/ui/web/frontend/src/views/PluginsView.connectors.test.tsx
index 8513d95aa4..5c915843c8 100644
--- a/jarvis/ui/web/frontend/src/views/PluginsView.connectors.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/PluginsView.connectors.test.tsx
@@ -66,7 +66,7 @@ function setupLocal(available: boolean) {
it("enables a supported local device without opening an OAuth browser", async () => {
const { fetcher, alerts } = setupLocal(true);
fireEvent.click(await screen.findByRole("button", { name: "Connect plugin" }));
- await screen.findByRole("button", { name: "Disconnect plugin" });
+ await screen.findByRole("img", { name: "Connected" });
expect(fetcher.mock.calls.some(([url]) => String(url).endsWith("/amd_gpu/connect/start"))).toBe(true);
expect(alerts).not.toHaveBeenCalled();
});
@@ -79,7 +79,7 @@ it("keeps an unavailable device disconnected and explains the missing capability
fireEvent.click(connect);
expect(fetcher.mock.calls.some(([url]) => String(url).endsWith("/connect/start"))).toBe(false);
expect(alerts).not.toHaveBeenCalled();
- expect(screen.queryByRole("button", { name: "Disconnect plugin" })).toBeNull();
+ expect(screen.queryByRole("img", { name: "Connected" })).toBeNull();
});
diff --git a/jarvis/ui/web/frontend/src/views/PluginsView.test.tsx b/jarvis/ui/web/frontend/src/views/PluginsView.test.tsx
index def2084f98..f03bc58a5c 100644
--- a/jarvis/ui/web/frontend/src/views/PluginsView.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/PluginsView.test.tsx
@@ -1,9 +1,8 @@
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
-import { act, cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
+import { act, cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
import { afterEach, describe, expect, it, vi } from "vitest";
import {
- ConnectIconButton,
matchesNamePrefix,
matchesQuery,
matchesStatus,
@@ -13,6 +12,7 @@ import {
type Plugin,
PluginsView,
} from "@/views/PluginsView";
+import { PluginRow } from "@/views/plugins/PluginBrowse";
const CATALOG = {
version: 1,
@@ -27,7 +27,6 @@ const CATALOG = {
category: "Developer",
logo_slug: "github",
logo_color: "F4F4F5",
- featured: true,
auth: { mode: "pat_paste" },
status: "connected",
live_callable: true,
@@ -39,7 +38,6 @@ const CATALOG = {
category: "Developer",
logo_slug: "vercel",
logo_color: "F4F4F5",
- featured: true,
auth: { mode: "pat_paste" },
status: "not_connected",
live_callable: false,
@@ -84,33 +82,105 @@ function renderPluginsView() {
);
}
+/** One directory row on its own, for the controls a row owns. */
+function renderRow(
+ status: Plugin["status"],
+ onConnect: () => void | Promise<void>,
+ onDisconnect: (id: string) => void = () => {},
+) {
+ const plugin: Plugin = {
+ id: "row_plugin",
+ name: "Row Plugin",
+ description: "d",
+ category: "Developer",
+ logoSlug: "row",
+ authMode: "pat_paste",
+ authConfig: { mode: "pat_paste" },
+ status,
+ longevity: "permanent",
+ oauthClientConfigured: false,
+ fromMarketplace: false,
+ selfUploaded: false,
+ };
+ return render(
+ <ul>
+ <PluginRow
+ plugin={plugin}
+ onOpen={() => {}}
+ onConnect={onConnect}
+ onDisconnect={onDisconnect}
+ onRemove={() => {}}
+ />
+ </ul>,
+ );
+}
+
afterEach(() => {
cleanup();
vi.restoreAllMocks();
});
-describe("PluginsView lists the catalog as a table", () => {
- it("shows one row per plugin, a Browse button and the All/Installed filter", async () => {
+describe("PluginsView lists the catalog in sections", () => {
+ it("shows one row per plugin under its category, both scopes and the add menu", async () => {
installCatalogFetchMock();
renderPluginsView();
// One row per catalog entry, named after the plugin.
- await waitFor(() => {
- expect(screen.getByRole("row", { name: "GitHub" })).toBeDefined();
- });
- expect(screen.getByRole("row", { name: "Vercel" })).toBeDefined();
- expect(screen.getByRole("button", { name: /^Browse\b/i })).toBeDefined();
- // The status filter is a small tab strip, not a second page.
- expect(screen.getByRole("tab", { name: /^All\b/ })).toBeDefined();
- expect(screen.getByRole("tab", { name: /^Installed\b/ })).toBeDefined();
- // Nothing needs attention in this catalog, so that tab stays hidden.
- expect(screen.queryByRole("tab", { name: /Needs attention/ })).toBeNull();
+ await screen.findByRole("button", { name: "GitHub" });
+ expect(screen.getByRole("button", { name: "Vercel" })).toBeDefined();
+ // The category is a section; its heading opens the full list.
+ expect(screen.getByRole("button", { name: "Show all of Developer" })).toBeDefined();
+ // Two scopes: what ships with the app, and what the owner added.
+ expect(screen.getByRole("tab", { name: "Built in" }).getAttribute("aria-selected")).toBe("true");
+ expect(screen.getByRole("tab", { name: "Yours" })).toBeDefined();
+ expect(screen.getByRole("button", { name: "Add" })).toBeDefined();
+ // Nothing needs attention in this catalog, so no reconnect notice.
+ expect(screen.queryByText(/reconnecting/)).toBeNull();
// The roadmap tab carried a static "AVAILABLE" list of Codex plugins that
// were never installable in Jarvis — it has been removed entirely.
expect(screen.queryByRole("button", { name: /^Roadmap\b/i })).toBeNull();
expect(screen.queryByText("ChatGPT Codex plugins")).toBeNull();
});
+
+ it("leads with the featured plugins and caps a section at six rows", async () => {
+ const plugins = Array.from({ length: 8 }, (_, index) => ({
+ id: `tool_${index}`,
+ display_name: `Tool ${index}`,
+ description: "d",
+ category: "Developer",
+ logo_slug: "tool",
+ featured: index === 7,
+ auth: { mode: "pat_paste" },
+ status: "not_connected",
+ }));
+ (globalThis as unknown as { fetch: typeof fetch }).fetch = vi.fn(async () => ({
+ ok: true,
+ status: 200,
+ json: async () => ({ version: 1, schema_version: "t", total: 8, connected: 0, plugins }),
+ })) as unknown as typeof fetch;
+
+ renderPluginsView();
+
+ const popular = await screen.findByRole("region", { name: "Popular" });
+ expect(within(popular).getByRole("button", { name: "Tool 7" })).toBeDefined();
+ // Popular comes before the category sections.
+ expect(screen.getAllByRole("heading", { level: 3 }).map((h) => h.textContent)).toEqual([
+ "Popular",
+ "Developer",
+ ]);
+ // A plugin is on the home page once: the featured one is not repeated
+ // under its category.
+ expect(screen.getAllByRole("button", { name: "Tool 7" })).toHaveLength(1);
+ // Six of the eight show on the home page; the heading opens all of them.
+ const developer = screen.getByRole("region", { name: "Developer" });
+ expect(within(developer).getAllByRole("listitem")).toHaveLength(6);
+ fireEvent.click(screen.getByRole("button", { name: "Show all of Developer" }));
+ await waitFor(() => expect(screen.getAllByRole("listitem")).toHaveLength(8));
+ // The breadcrumb leads back to the directory.
+ fireEvent.click(screen.getByRole("button", { name: "Plugins" }));
+ await screen.findByRole("region", { name: "Popular" });
+ });
});
describe("PluginsView live badge", () => {
@@ -119,41 +189,34 @@ describe("PluginsView live badge", () => {
renderPluginsView();
- // Wait until the catalog data has loaded: the header subtitle shows
- // "2 available · 1 connected" once the fetch resolves.
- await waitFor(() => {
- expect(screen.getByText(/available.*connected/i)).toBeDefined();
- });
+ await screen.findByRole("button", { name: "GitHub" });
+ // The installed list states each connection in words.
+ fireEvent.click(screen.getByRole("button", { name: "Manage installed plugins" }));
- // GitHub is connected + live_callable: true → the status column says so.
- expect(screen.getByText("Connected · Live")).toBeDefined();
- // Vercel is not connected and must not carry the Live mark.
- expect(screen.getByText("Not connected")).toBeDefined();
+ // GitHub is connected + live_callable: true → its row says so.
+ expect(await screen.findByText("Connected · Live")).toBeDefined();
+ // Vercel was never connected, so the installed list does not carry it.
+ expect(screen.queryByRole("button", { name: "Vercel" })).toBeNull();
});
});
-describe("PluginsView window catalog states connection in connection words", () => {
+describe("PluginsView states connection in connection words", () => {
it("says Connect/Connected, never Add/Added, so install and auth cannot mix", async () => {
installCatalogFetchMock();
- const client = new QueryClient({
- defaultOptions: { queries: { retry: false }, mutations: { retry: false } },
- });
- render(
- <QueryClientProvider client={client}>
- <PluginsView inDialog />
- </QueryClientProvider>,
- );
- await waitFor(() => expect(screen.getByText("GitHub")).toBeDefined());
- expect(screen.getByText("Vercel")).toBeDefined();
- // Untouched card offers a connection, connected card names it. (The
- // window catalog buttons are labelled Connect/Disconnect.)
- expect(screen.getByRole("button", { name: "Connect" })).toBeDefined();
- expect(screen.getByRole("button", { name: "Disconnect" })).toBeDefined();
- expect(screen.getByText("Connect")).toBeDefined();
- expect(screen.getByText("Connected")).toBeDefined();
- // No install wording on connection buttons: "Installed" already names the
- // tab and the community badge, and "Added" read as done-before-authed.
+ renderPluginsView();
+
+ await screen.findByRole("button", { name: "GitHub" });
+ expect(screen.getByRole("button", { name: "Vercel" })).toBeDefined();
+ // The untouched row offers a connection, the connected row names it.
+ expect(screen.getByRole("button", { name: "Connect plugin" })).toBeDefined();
+ expect(screen.getByRole("img", { name: "Connected" })).toBeDefined();
+ // Disconnecting sits behind the row's menu, never one stray click away.
+ expect(screen.queryByRole("menuitem", { name: "Disconnect" })).toBeNull();
+ fireEvent.click(screen.getByRole("button", { name: "More actions" }));
+ expect(screen.getByRole("menuitem", { name: "Disconnect" })).toBeDefined();
+ // No install wording on connection controls: "Added" read as
+ // done-before-authed.
expect(screen.queryByText("Added")).toBeNull();
});
});
@@ -163,19 +226,13 @@ describe("PluginsView window catalog states connection in connection words", ()
// burst of browser tabs + multiple DCR client registrations. The button must
// lock itself (and show a spinner) while a connect is in flight, ignoring the
// extra clicks, then re-enable so a genuine retry still works.
-describe("ConnectIconButton click-lock", () => {
+describe("plugin row click-lock", () => {
it("ignores extra clicks while a connect is in flight", async () => {
let release: () => void = () => {};
const onConnect = vi.fn(
() => new Promise<void>((resolve) => { release = resolve; }),
);
- render(
- <ConnectIconButton
- status="not_connected"
- onConnect={onConnect}
- onDisconnect={() => {}}
- />,
- );
+ renderRow("not_connected", onConnect);
const btn = screen.getByRole("button", { name: "Connect plugin" });
fireEvent.click(btn);
@@ -184,28 +241,26 @@ describe("ConnectIconButton click-lock", () => {
// Only the first click started a flow; the rest were swallowed by the lock.
expect(onConnect).toHaveBeenCalledTimes(1);
- await waitFor(() => expect((btn as HTMLButtonElement).disabled).toBe(true));
+ const busy = await screen.findByRole("button", { name: "Connecting Row Plugin" });
+ expect((busy as HTMLButtonElement).disabled).toBe(true);
+ expect(screen.queryByRole("button", { name: "Connect plugin" })).toBeNull();
await act(async () => {
release();
});
- expect((btn as HTMLButtonElement).disabled).toBe(false);
+ expect(
+ (screen.getByRole("button", { name: "Connect plugin" }) as HTMLButtonElement).disabled,
+ ).toBe(false);
});
it("re-enables after the connect resolves so a retry still works", async () => {
const onConnect = vi.fn(() => Promise.resolve());
- render(
- <ConnectIconButton
- status="not_connected"
- onConnect={onConnect}
- onDisconnect={() => {}}
- />,
- );
- const btn = screen.getByRole("button", { name: "Connect plugin" });
+ renderRow("not_connected", onConnect);
await act(async () => {
- fireEvent.click(btn);
+ fireEvent.click(screen.getByRole("button", { name: "Connect plugin" }));
});
+ const btn = screen.getByRole("button", { name: "Connect plugin" });
expect((btn as HTMLButtonElement).disabled).toBe(false);
await act(async () => {
fireEvent.click(btn);
@@ -218,16 +273,10 @@ describe("ConnectIconButton click-lock", () => {
// A revoked / expired plugin (status needs_reauth) must NOT look like a never-
// connected one. It surfaces a distinct "Reconnect" affordance that re-runs the
// same connect flow — the one-click repair for a dead token.
-describe("ConnectIconButton reconnect state", () => {
+describe("plugin row reconnect state", () => {
it("renders a Reconnect button for needs_reauth that triggers onConnect", async () => {
const onConnect = vi.fn(() => Promise.resolve());
- render(
- <ConnectIconButton
- status="needs_reauth"
- onConnect={onConnect}
- onDisconnect={() => {}}
- />,
- );
+ renderRow("needs_reauth", onConnect);
const btn = screen.getByRole("button", { name: "Reconnect plugin" });
expect(btn).toBeDefined();
await act(async () => {
@@ -236,16 +285,19 @@ describe("ConnectIconButton reconnect state", () => {
expect(onConnect).toHaveBeenCalledTimes(1);
});
- it("never shows a plain Connect or Disconnect button for needs_reauth", () => {
- render(
- <ConnectIconButton
- status="needs_reauth"
- onConnect={() => {}}
- onDisconnect={() => {}}
- />,
- );
+ it("never shows a plain Connect button or a Connected mark for needs_reauth", () => {
+ renderRow("needs_reauth", () => {});
+ expect(screen.queryByRole("button", { name: "Connect plugin" })).toBeNull();
+ expect(screen.queryByRole("img", { name: "Connected" })).toBeNull();
+ });
+
+ it("keeps Disconnect for a connected plugin behind the row menu", () => {
+ const onDisconnect = vi.fn();
+ renderRow("connected", () => {}, onDisconnect);
expect(screen.queryByRole("button", { name: "Connect plugin" })).toBeNull();
- expect(screen.queryByRole("button", { name: "Disconnect plugin" })).toBeNull();
+ fireEvent.click(screen.getByRole("button", { name: "More actions" }));
+ fireEvent.click(screen.getByRole("menuitem", { name: "Disconnect" }));
+ expect(onDisconnect).toHaveBeenCalledWith("row_plugin");
});
});
@@ -259,13 +311,13 @@ describe("plugin row click", () => {
renderPluginsView();
await waitFor(() => {
- expect(screen.getByRole("row", { name: "Vercel" })).toBeDefined();
+ expect(screen.getByRole("button", { name: "Vercel" })).toBeDefined();
});
expect(screen.queryByRole("dialog")).toBeNull();
// A row opens the detail page — it never starts a flow by itself.
await act(async () => {
- fireEvent.click(screen.getByRole("row", { name: "Vercel" }));
+ fireEvent.click(screen.getByRole("button", { name: "Vercel" }));
});
await waitFor(() => {
expect(screen.getByRole("button", { name: "Plugins" })).toBeDefined();
@@ -286,11 +338,11 @@ describe("plugin row click", () => {
renderPluginsView();
await waitFor(() => {
- expect(screen.getByRole("row", { name: "GitHub" })).toBeDefined();
+ expect(screen.getByRole("button", { name: "GitHub" })).toBeDefined();
});
await act(async () => {
- fireEvent.click(screen.getByRole("row", { name: "GitHub" }));
+ fireEvent.click(screen.getByRole("button", { name: "GitHub" }));
});
// The detail page states the connection; nothing destructive fires.
@@ -573,7 +625,7 @@ describe("PluginsView publishes OAuth success immediately", () => {
await screen.findByText("Gmail connected");
expect(
- screen.getByRole("button", { name: "Disconnect plugin" }),
+ screen.getByRole("img", { name: "Connected" }),
).toBeDefined();
expect(catalogReads).toBeGreaterThan(1);
});
@@ -739,7 +791,7 @@ describe("PluginsView publishes every supported connection path immediately", ()
});
fireEvent.click(screen.getByRole("button", { name: /^connect$/i }));
- await screen.findByRole("button", { name: "Disconnect plugin" });
+ await screen.findByRole("img", { name: "Connected" });
expect(probe.catalogReads).toBeGreaterThan(1);
});
@@ -768,7 +820,7 @@ describe("PluginsView publishes every supported connection path immediately", ()
fireEvent.click(await screen.findByRole("button", { name: "Connect plugin" }));
await screen.findByText("DCR Service connected");
- expect(screen.getByRole("button", { name: "Disconnect plugin" })).toBeDefined();
+ expect(screen.getByRole("img", { name: "Connected" })).toBeDefined();
expect(probe.catalogReads).toBeGreaterThan(1);
});
@@ -801,13 +853,13 @@ describe("PluginsView publishes every supported connection path immediately", ()
fireEvent.click(await screen.findByRole("button", { name: "Connect plugin" }));
await screen.findByText("Device Service connected");
- expect(screen.getByRole("button", { name: "Disconnect plugin" })).toBeDefined();
+ expect(screen.getByRole("img", { name: "Connected" })).toBeDefined();
expect(probe.catalogReads).toBeGreaterThan(1);
});
});
describe("PluginsView keeps revoked plugins visible", () => {
- it("shows a needs_reauth plugin under Installed with a Reconnect-needed badge", async () => {
+ it("names a needs_reauth plugin up front and lists it as installed with a Reconnect control", async () => {
const fetchMock = vi.fn(async (input: RequestInfo | URL) => {
if (String(input) === "/api/marketplace/plugins") {
return {
@@ -840,23 +892,18 @@ describe("PluginsView keeps revoked plugins visible", () => {
renderPluginsView();
- // Open the Installed filter — the revoked plugin must be there, not hidden
- // in the full list as if never connected.
- await waitFor(() => {
- expect(screen.getByRole("tab", { name: /^Installed\b/i })).toBeDefined();
- });
- fireEvent.click(screen.getByRole("tab", { name: /^Installed\b/i }));
- // The attention filter appears as soon as something needs reconnecting.
- expect(screen.getByRole("tab", { name: /Needs attention/ })).toBeDefined();
+ // The directory says which connection broke before anything else.
+ await screen.findByText("Gmail needs reconnecting");
+ // Its row is a Reconnect, never a plain "+" as if it was never connected.
+ expect(screen.getByRole("button", { name: "Reconnect plugin" })).toBeDefined();
+ expect(screen.queryByRole("button", { name: "Connect plugin" })).toBeNull();
- await waitFor(() => {
- expect(screen.getByText("Gmail")).toBeDefined();
- });
- // The row carries the amber "Reconnect needed" badge AND a Reconnect button.
- expect(screen.getByText("Reconnect needed")).toBeDefined();
- expect(
- screen.getByRole("button", { name: "Reconnect plugin" }),
- ).toBeDefined();
+ // The installed list still carries it — a dead token does not drop the
+ // plugin back among the never-connected ones.
+ fireEvent.click(screen.getByRole("button", { name: "Manage installed plugins" }));
+ await screen.findByText("Reconnect needed");
+ expect(screen.getByRole("button", { name: "Gmail" })).toBeDefined();
+ expect(screen.getByRole("button", { name: "Reconnect plugin" })).toBeDefined();
});
});
@@ -963,17 +1010,18 @@ describe("PluginsView category sections are data-driven", () => {
renderPluginsView();
await waitFor(() => {
- expect(screen.getByRole("row", { name: "mystery" })).toBeDefined();
+ expect(screen.getByRole("button", { name: "mystery" })).toBeDefined();
});
expect(screen.getByText("Something Brand New")).toBeDefined();
- // The category menu is fed by the same data, so it offers the new one too.
- fireEvent.click(screen.getByRole("combobox", { name: "Category" }));
- expect(
- screen.getByRole("option", { name: "Something Brand New" }),
- ).toBeDefined();
+ // Its heading opens the section like any other, fed by the same data.
+ fireEvent.click(screen.getByRole("button", { name: "Show all of Something Brand New" }));
+ await waitFor(() => {
+ expect(screen.queryByRole("button", { name: "known" })).toBeNull();
+ });
+ expect(screen.getByRole("button", { name: "mystery" })).toBeDefined();
});
- it("orders rows by the catalog's category_order", async () => {
+ it("orders sections by the catalog's category_order", async () => {
catalogWith(
[row("b", "Second"), row("a", "First")],
["First", "Second"],
@@ -982,13 +1030,12 @@ describe("PluginsView category sections are data-driven", () => {
renderPluginsView();
await waitFor(() => {
- expect(screen.getByRole("row", { name: "a" })).toBeDefined();
+ expect(screen.getByRole("button", { name: "a" })).toBeDefined();
});
- const names = screen
- .getAllByRole("row")
- .map((r) => r.getAttribute("aria-label"))
- .filter(Boolean);
- expect(names.indexOf("a")).toBeLessThan(names.indexOf("b"));
+ expect(screen.getAllByRole("heading", { level: 3 }).map((h) => h.textContent)).toEqual([
+ "First",
+ "Second",
+ ]);
});
it("states how long the connection lasts before the user connects", async () => {
@@ -1003,17 +1050,17 @@ describe("PluginsView category sections are data-driven", () => {
renderPluginsView();
await waitFor(() => {
- expect(screen.getByRole("row", { name: "limited" })).toBeDefined();
+ expect(screen.getByRole("button", { name: "limited" })).toBeDefined();
});
// The detail page carries the longevity fact sheet.
- fireEvent.click(screen.getByRole("row", { name: "limited" }));
+ fireEvent.click(screen.getByRole("button", { name: "limited" }));
await waitFor(() => {
expect(screen.getByText("Sign in again periodically")).toBeDefined();
});
expect(screen.getByText("Google asks again every 7 days in Testing mode.")).toBeDefined();
fireEvent.click(screen.getByRole("button", { name: "Plugins" }));
- fireEvent.click(await screen.findByRole("row", { name: "forever" }));
+ fireEvent.click(await screen.findByRole("button", { name: "forever" }));
await waitFor(() => {
expect(screen.getByText("Stays connected")).toBeDefined();
});
@@ -1164,69 +1211,81 @@ describe("plugin status filter", () => {
});
});
-describe("PluginsView search and filter controls", () => {
- function openSearch() {
- fireEvent.click(screen.getByRole("button", { name: "Search plugins…" }));
- return screen.getByPlaceholderText("Search plugins…");
- }
+describe("PluginsView search and scope controls", () => {
+ const search = () => screen.getByRole("searchbox", { name: "Search plugins…" });
- it("offers the status filter as tabs next to the search", async () => {
+ it("offers the two scopes as tabs under the header", async () => {
installCatalogFetchMock();
renderPluginsView();
await waitFor(() => {
- expect(screen.getByRole("tablist", { name: "Show" })).toBeDefined();
+ expect(screen.getByRole("tablist", { name: "Plugin directory" })).toBeDefined();
});
- for (const label of [/^All\b/, /^Installed\b/]) {
+ for (const label of ["Built in", "Yours"]) {
expect(screen.getByRole("tab", { name: label })).toBeDefined();
}
});
- it("hides the match count and reset button until a filter is active", async () => {
+ it("invites adding a plugin when the owner has added none", async () => {
+ installCatalogFetchMock();
+ renderPluginsView();
+
+ await screen.findByRole("button", { name: "GitHub" });
+ fireEvent.click(screen.getByRole("tab", { name: "Yours" }));
+
+ expect(screen.getByText("Nothing added yet")).toBeDefined();
+ expect(screen.queryByRole("button", { name: "GitHub" })).toBeNull();
+ expect(screen.getByRole("button", { name: "Custom connector (URL)" })).toBeDefined();
+ });
+
+ it("hides the match count and clear button until a search is active", async () => {
installCatalogFetchMock();
renderPluginsView();
await waitFor(() => {
- expect(screen.getByRole("button", { name: "Disconnect plugin" })).toBeDefined();
+ expect(screen.getByRole("img", { name: "Connected" })).toBeDefined();
});
expect(screen.queryByRole("button", { name: "Clear filters" })).toBeNull();
expect(screen.queryByText(/matches$/)).toBeNull();
- fireEvent.change(openSearch(), { target: { value: "deployments" } });
+ fireEvent.change(search(), { target: { value: "deployments" } });
// Vercel's description carries "Deployments"; GitHub's does not.
await waitFor(() => {
expect(screen.getByText("1 matches")).toBeDefined();
});
- expect(screen.getByRole("row", { name: "Vercel" })).toBeDefined();
- expect(screen.queryByRole("row", { name: "GitHub" })).toBeNull();
+ expect(screen.getByRole("button", { name: "Vercel" })).toBeDefined();
+ expect(screen.queryByRole("button", { name: "GitHub" })).toBeNull();
expect(screen.getByRole("button", { name: "Clear filters" })).toBeDefined();
+ // A search lists results flat: the scope tabs step aside.
+ expect(screen.queryByRole("tablist", { name: "Plugin directory" })).toBeNull();
});
- it("restores the full list when the filters are cleared", async () => {
+ it("restores the full list when the search is cleared", async () => {
installCatalogFetchMock();
renderPluginsView();
await waitFor(() => {
- expect(screen.getByRole("button", { name: "Disconnect plugin" })).toBeDefined();
+ expect(screen.getByRole("img", { name: "Connected" })).toBeDefined();
});
- fireEvent.change(openSearch(), { target: { value: "kubernetes" } });
+ fireEvent.change(search(), { target: { value: "kubernetes" } });
await waitFor(() => {
expect(screen.getByText("0 matches")).toBeDefined();
});
+ expect(screen.getByText("No plugin matches the current filters.")).toBeDefined();
- fireEvent.click(screen.getByRole("button", { name: "Clear filters" }));
+ fireEvent.click(screen.getByRole("button", { name: "Show all plugins" }));
await waitFor(() => {
expect(screen.queryByRole("button", { name: "Clear filters" })).toBeNull();
});
- expect(screen.getByRole("button", { name: "Disconnect plugin" })).toBeDefined();
- expect(screen.getByRole("row", { name: "Vercel" })).toBeDefined();
+ expect(screen.getByRole("img", { name: "Connected" })).toBeDefined();
+ expect(screen.getByRole("button", { name: "Vercel" })).toBeDefined();
});
- it("explains an empty result from a non-text filter instead of blanking", async () => {
- // Filtering by connection state alone can empty the list. That path used
- // to render nothing at all — no message, no way back.
+ it("explains an empty installed list instead of blanking", async () => {
+ // With nothing connected the installed list is empty. That path used to
+ // render nothing at all — no message, no way back.
const fetchMock = vi.fn(async (input: RequestInfo | URL) => {
if (String(input) === "/api/marketplace/plugins") {
return {
@@ -1250,47 +1309,60 @@ describe("PluginsView search and filter controls", () => {
renderPluginsView();
await waitFor(() => {
- expect(screen.getByRole("row", { name: "GitHub" })).toBeDefined();
+ expect(screen.getByRole("button", { name: "GitHub" })).toBeDefined();
});
- fireEvent.click(screen.getByRole("tab", { name: /^Installed\b/ }));
+ fireEvent.click(screen.getByRole("button", { name: "Manage installed plugins" }));
await waitFor(() => {
- expect(screen.getByText("No plugin matches the current filters.")).toBeDefined();
+ expect(screen.getByText("No plugins connected yet")).toBeDefined();
});
- fireEvent.click(screen.getByRole("button", { name: "Show all plugins" }));
+ fireEvent.click(screen.getByRole("button", { name: "Plugins" }));
await waitFor(() => {
- expect(screen.getByRole("row", { name: "GitHub" })).toBeDefined();
+ expect(screen.getByRole("button", { name: "GitHub" })).toBeDefined();
});
});
- it("never claims nothing is connected while a filter is hiding the plugins", async () => {
+ it("never claims nothing is connected while a search is hiding the plugins", async () => {
installCatalogFetchMock();
renderPluginsView();
await waitFor(() => {
- expect(screen.getByRole("button", { name: "Disconnect plugin" })).toBeDefined();
+ expect(screen.getByRole("img", { name: "Connected" })).toBeDefined();
});
- fireEvent.click(screen.getByRole("tab", { name: /^Installed\b/ }));
- fireEvent.change(openSearch(), { target: { value: "kubernetes" } });
+ fireEvent.click(screen.getByRole("button", { name: "Manage installed plugins" }));
+ fireEvent.change(search(), { target: { value: "kubernetes" } });
await waitFor(() => {
expect(screen.getByText(/No plugin matches/)).toBeDefined();
});
- expect(screen.queryByText("Nothing connected yet")).toBeNull();
+ expect(screen.queryByText("No plugins connected yet")).toBeNull();
});
it("lists every plugin exactly once — no promo strip, no Coming-soon decoy", async () => {
// The carousel used to put GitHub on screen a second time, and the
// Coming-soon strip listed names that had long had real catalog entries.
- installCatalogFetchMock();
+ // A featured plugin leads under Popular and is not repeated below.
+ (globalThis as unknown as { fetch: typeof fetch }).fetch = vi.fn(async () => ({
+ ok: true,
+ status: 200,
+ json: async () => ({
+ ...CATALOG,
+ plugins: CATALOG.plugins.map((p) => ({ ...p, featured: p.id === "github" })),
+ }),
+ })) as unknown as typeof fetch;
renderPluginsView();
await waitFor(() => {
- expect(screen.getByRole("row", { name: "GitHub" })).toBeDefined();
+ expect(screen.getByRole("button", { name: "GitHub" })).toBeDefined();
});
expect(screen.getAllByText("GitHub")).toHaveLength(1);
+ expect(screen.getAllByText("Vercel")).toHaveLength(1);
+ expect(screen.getAllByRole("heading", { level: 3 }).map((h) => h.textContent)).toEqual([
+ "Popular",
+ "Developer",
+ ]);
expect(screen.queryByText("Coming soon")).toBeNull();
});
});
diff --git a/jarvis/ui/web/frontend/src/views/PluginsView.tsx b/jarvis/ui/web/frontend/src/views/PluginsView.tsx
index 49e12abce9..75a6ae1ac7 100644
--- a/jarvis/ui/web/frontend/src/views/PluginsView.tsx
+++ b/jarvis/ui/web/frontend/src/views/PluginsView.tsx
@@ -8,8 +8,6 @@ import {
import { useEventStore } from "@/store/events";
import {
ExternalLink,
- Search,
- RefreshCw,
RotateCw,
Plus,
Check,
@@ -17,41 +15,27 @@ import {
X,
Loader2,
AlertTriangle,
- Store,
MoreHorizontal,
ArrowRight,
- Link2,
- FolderUp,
Trash2,
} from "lucide-react";
import { CommunityTab } from "@/views/PluginsCommunity";
+import { Breadcrumbs, type Crumb, PluginBrowse, sectionTitle } from "@/views/plugins/PluginBrowse";
+import { homeSectionId, type PluginScope } from "@/views/plugins/sections";
import { PluginUploadDialog } from "@/views/PluginUploadDialog";
import { AddConnectorDialog, AddPluginTabs, type AddPluginMode } from "@/views/AddConnectorDialog";
import { removeAddedPlugin, takePluginFocus } from "@/lib/customConnector";
import { fill, translate, useLocaleChunk } from "@/i18n";
import { backendMessage } from "@/lib/backendMessage";
import { ScrollArea } from "@/components/ui/scroll-area";
-import { BrandedSelect } from "@/components/ui/select";
import {
ActionMenu,
- BackLink,
- Cell,
ClampedText,
- DetailHeader,
- EmptyRow,
FactRows,
IconButton,
- InlineSearch,
- MenuPill,
Panel,
- PanelHeader,
- SegmentedFilter,
SoftButton,
StatusDot,
- Table,
- TableHead,
- TableRow,
- type Column,
} from "@/components/extensions/primitives";
import { FileCard, type CardFile } from "@/components/extensions/FileCard";
import { cn } from "@/lib/utils";
@@ -285,7 +269,7 @@ export interface Plugin {
/** Why a plugin cannot run here, in the UI language when the backend named
* the reason with a code; otherwise its own sentence. */
-function unavailableReasonText(plugin: Plugin): string | undefined {
+export function unavailableReasonText(plugin: Plugin): string | undefined {
if (!plugin.unavailableReason) return undefined;
return backendMessage(
translate,
@@ -347,6 +331,22 @@ function adapt(p: CatalogPlugin): Plugin {
};
}
+/** The plugin catalog as one shared, polled query. Every surface of the section
+ * reads it through this hook, so a connection made on one page is seen by the
+ * sidebar and the directory at the same moment. */
+export function usePluginCatalog() {
+ const query = useQuery({
+ queryKey: ["marketplace-plugins"],
+ queryFn: fetchCatalog,
+ refetchInterval: 30_000,
+ });
+ const plugins = useMemo<Plugin[]>(
+ () => query.data?.plugins.map(adapt) ?? [],
+ [query.data],
+ );
+ return { ...query, plugins };
+}
+
// --- Brand marks -----------------------------------------------------------
// Three tiers, tried in order, so a card is never blank and never a broken
// image:
@@ -563,7 +563,6 @@ function loopbackRedirectUri(plugin: Plugin): string | undefined {
return `http://127.0.0.1:${port}${path}`;
}
-type FilterId = "all" | Category;
export type StatusFilterId = "all" | "connected" | "not_connected" | "attention";
/** Section order for the store, straight from the catalog. Any category the
@@ -621,6 +620,17 @@ export function matchesNamePrefix(plugin: Plugin, query: string): boolean {
return false;
}
+/** What a search box lists for `query`: the plugins whose name starts with it
+ * when any do, otherwise every plugin that mentions all its words — always
+ * A-Z, never grouped. An empty query returns the list untouched. */
+export function searchPlugins(plugins: Plugin[], query: string): Plugin[] {
+ const trimmed = query.trim();
+ if (trimmed === "") return plugins;
+ const prefixed = plugins.filter((p) => matchesNamePrefix(p, trimmed));
+ const hits = prefixed.length > 0 ? prefixed : plugins.filter((p) => matchesQuery(p, trimmed));
+ return [...hits].sort(sortPluginsByName);
+}
+
/** A-Z by display name, case-insensitive. Used whenever a search query is
* active so "G" lists Gmail before Google Drive instead of grouping by
* category. */
@@ -643,9 +653,9 @@ export function matchesStatus(plugin: Plugin, status: StatusFilterId): boolean {
}
}
-export type ListFilter = "all" | "installed" | "attention" | "recommended";
-
-const WINDOW_CATEGORY_ORDER = [
+/** The order the directory lists its category sections in. A category the
+ * catalog serves but this list does not name follows in catalog order. */
+const DIRECTORY_CATEGORY_ORDER = [
"Calendar & Mail", "Files & Photos", "Knowledge & Reading", "Messaging",
"Lists & Tasks", "Developer", "Media & Creativity", "Home & Devices",
];
@@ -671,12 +681,29 @@ export function categoryLabel(category: string): string {
return key ? translate(key) : category;
}
-export function PluginsView({ inDialog = false }: { inDialog?: boolean } = {}) {
+export function PluginsView({
+ selectedId: controlledId,
+ onSelect,
+}: {
+ /** The open plugin page, when the surrounding frame owns the selection (its
+ * sidebar opens installed plugins). Left out, the view keeps its own. */
+ selectedId?: string | null;
+ onSelect?: (id: string | null) => void;
+} = {}) {
const qc = useQueryClient();
const setActiveSection = useEventStore((s) => s.setActiveSection);
const [view, setView] = useState<"list" | "community" | "custom-apis">("list");
- const [selectedId, setSelectedId] = useState<string | null>(null);
- const [listFilter, setListFilter] = useState<ListFilter>(inDialog ? "recommended" : "all");
+ const [ownSelectedId, setOwnSelectedId] = useState<string | null>(null);
+ const selectedId = controlledId !== undefined ? controlledId : ownSelectedId;
+ const setSelectedId = (id: string | null) => {
+ setOwnSelectedId(id);
+ onSelect?.(id);
+ };
+ const [scope, setScope] = useState<PluginScope>("catalog");
+ // The section whose full list is open; null on the directory's home page.
+ const [sectionId, setSectionId] = useState<string | null>(null);
+ // The installed list with its connection states, instead of the directory.
+ const [managing, setManaging] = useState(false);
// Which half of the "Add a plugin" dialog is open: a server URL or a folder.
const [addMode, setAddMode] = useState<AddPluginMode | null>(null);
const [removingPlugin, setRemovingPlugin] = useState<Plugin | null>(null);
@@ -686,10 +713,10 @@ export function PluginsView({ inDialog = false }: { inDialog?: boolean } = {}) {
useEffect(() => {
const focus = takePluginFocus();
if (focus) setSelectedId(focus);
+ // Runs once on mount: the focus request is consumed by reading it.
+ // eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
- const [searchOpen, setSearchOpen] = useState(false);
const [query, setQuery] = useState("");
- const [filter, setFilter] = useState<FilterId>("all");
const [connectingPlugin, setConnectingPlugin] = useState<Plugin | null>(null);
const [instancePlugin, setInstancePlugin] = useState<Plugin | null>(null);
// Browser plugin awaiting publisher readiness or an optional expert override.
@@ -698,11 +725,8 @@ export function PluginsView({ inDialog = false }: { inDialog?: boolean } = {}) {
// Plugin awaiting a "really disconnect?" confirmation. Removing a plugin is
// destructive (tokens dropped, brain tools re-expanded), so it must ask first.
const [disconnectingPlugin, setDisconnectingPlugin] = useState<Plugin | null>(null);
- const { data, isLoading, error, refetch, isFetching } = useQuery({
- queryKey: ["marketplace-plugins"],
- queryFn: fetchCatalog,
- refetchInterval: 30_000,
- });
+ const { data, isLoading, error, refetch, isFetching, plugins: allPlugins } =
+ usePluginCatalog();
const publishPluginStatus = (pluginId: string, status: PluginStatus) => {
cachePluginStatus(qc, pluginId, status);
@@ -951,10 +975,6 @@ export function PluginsView({ inDialog = false }: { inDialog?: boolean } = {}) {
setConnectFailure(translate("plugins_view.err_pending_publisher"));
};
- const allPlugins = useMemo<Plugin[]>(
- () => data?.plugins.map(adapt) ?? [],
- [data],
- );
const handleDisconnect = (id: string) =>
setDisconnectingPlugin(allPlugins.find((p) => p.id === id) ?? null);
@@ -965,7 +985,10 @@ export function PluginsView({ inDialog = false }: { inDialog?: boolean } = {}) {
// card connected optimistically.
const handleFreshInstall = async (pluginId: string) => {
setView("list");
- setListFilter("installed");
+ setScope("yours");
+ setSectionId(null);
+ setManaging(false);
+ setQuery("");
try {
const fresh = await fetchCatalog();
qc.setQueryData<CatalogResponse>(["marketplace-plugins"], fresh);
@@ -979,37 +1002,13 @@ export function PluginsView({ inDialog = false }: { inDialog?: boolean } = {}) {
}
void qc.refetchQueries({ queryKey: ["marketplace-plugins"] });
};
- const categoryOrder = useMemo(
- () => orderedCategories(data, allPlugins),
- [data, allPlugins],
- );
- // "Installed" keeps every plugin the user ever connected — including a revoked
- // (needs_reauth) or errored one — so a dead token surfaces a Reconnect prompt
- // here instead of silently dropping back into the full list as a plain "+".
- //
- // A plugin installed from the marketplace belongs here from the moment it is
- // installed, connected or not: the shipped catalog is always "available", so
- // a community plugin that only appeared in the full list was indistinguishable
- // from the twenty the app came with — somebody who had just installed one had
- // no place to look for it.
- const installed = useMemo(
- () =>
- allPlugins.filter(
- (p) =>
- p.status === "connected" ||
- p.status === "needs_reauth" ||
- p.status === "error" ||
- p.fromMarketplace ||
- p.selfUploaded,
- ),
- [allPlugins],
- );
- const connectedCount = useMemo(
- () => allPlugins.filter((p) => p.status === "connected").length,
- [allPlugins],
- );
+ const categoryOrder = useMemo(() => {
+ const served = orderedCategories(data, allPlugins);
+ const ranked = DIRECTORY_CATEGORY_ORDER.filter((c) => served.includes(c));
+ return [...ranked, ...served.filter((c) => !ranked.includes(c))];
+ }, [data, allPlugins]);
// Every plugin that needs a reconnect (revoked/expired token) or errored —
- // the ones the "needs attention" banner names and the attention filter shows.
+ // the ones the "needs attention" banner names.
const attentionPlugins = useMemo(
() =>
allPlugins.filter(
@@ -1018,44 +1017,6 @@ export function PluginsView({ inDialog = false }: { inDialog?: boolean } = {}) {
[allPlugins],
);
- const visible = useMemo(() => {
- const base =
- listFilter === "recommended"
- ? allPlugins.filter((p) => p.featured || p.status === "connected")
- : listFilter === "installed"
- ? installed
- : listFilter === "attention"
- ? attentionPlugins
- : allPlugins;
- const inCategory = (p: Plugin) => filter === "all" || p.category === filter;
- const trimmed = query.trim();
- if (trimmed !== "") {
- const candidates = base.filter(inCategory);
- const prefixed = candidates.filter((p) => matchesNamePrefix(p, trimmed));
- if (prefixed.length > 0) return [...prefixed].sort(sortPluginsByName);
- return candidates.filter((p) => matchesQuery(p, trimmed)).sort(sortPluginsByName);
- }
- const order = inDialog ? [...WINDOW_CATEGORY_ORDER, ...categoryOrder] : categoryOrder;
- const ranked = [...base].sort((a, b) =>
- order.indexOf(a.category) - order.indexOf(b.category)
- || (inDialog ? a.name.localeCompare(b.name) : 0),
- );
- return ranked.filter((p) => {
- if (filter !== "all" && p.category !== filter) return false;
- return true;
- });
- }, [listFilter, query, filter, allPlugins, installed, attentionPlugins, categoryOrder, inDialog]);
-
- const filtersActive = query.trim() !== "" || filter !== "all";
- const resetFilters = () => {
- setQuery("");
- setFilter("all");
- };
- const closeSearch = () => {
- resetFilters();
- setSearchOpen(false);
- };
-
const selectedPlugin = selectedId
? allPlugins.find((p) => p.id === selectedId) ?? null
: null;
@@ -1216,18 +1177,30 @@ export function PluginsView({ inDialog = false }: { inDialog?: boolean } = {}) {
</>
);
+ // Each page of the section starts at the top: the scroll area is keyed on
+ // what it shows, so opening a plugin never lands mid-page.
+ const pageKey = view !== "list"
+ ? view
+ : selectedId ? `plugin:${selectedId}` : managing ? "manage" : sectionId ?? "home";
const shell = (content: React.ReactNode) => (
<div className="flex h-full min-h-0 flex-col bg-transparent">
- {inDialog && view === "list" && !selectedId ? content : (
- <ScrollArea className="flex-1">
- <div className={cn("mx-auto w-full max-w-4xl px-8 py-6", inDialog && (view === "custom-apis" ? "px-6 pt-5" : "pt-12"))}>{content}</div>
- </ScrollArea>
- )}
+ <ScrollArea key={pageKey} className="flex-1">
+ <div className="mx-auto w-full max-w-[880px] px-5 pb-12 pt-12 sm:px-8">{content}</div>
+ </ScrollArea>
{dialogs}
</div>
);
+ const directoryCrumb: Crumb = {
+ label: translate("plugins_view.title"),
+ onClick: () => {
+ setView("list");
+ setSelectedId(null);
+ setSectionId(null);
+ setManaging(false);
+ },
+ };
- // ---- Community marketplace (the "Browse" page) --------------------------
+ // ---- Own HTTP APIs and the community marketplace -------------------------
if (view === "custom-apis") {
return shell(<Suspense fallback={<p>{translate("custom_apis.loading")}</p>}>
<CustomApisView onBack={() => setView("list")} />
@@ -1237,19 +1210,41 @@ export function PluginsView({ inDialog = false }: { inDialog?: boolean } = {}) {
if (view === "community") {
return shell(
<>
- <BackLink label={translate("plugins_view.title")} onClick={() => setView("list")} />
- <div className="mt-5">
+ <Breadcrumbs crumbs={[directoryCrumb, { label: translate("plugins_view.add_community") }]} />
+ <div className="mt-6">
<CommunityTab onInstalled={(name) => void handleFreshInstall(name)} />
</div>
</>,
);
}
- // ---- Detail page -------------------------------------------------------
+ // ---- Plugin page ---------------------------------------------------------
if (selectedId) {
+ // The crumb between the directory and the plugin is the list the plugin
+ // belongs to — the installed list while managing, otherwise its section —
+ // so the path reads the same however the page was reached.
+ const home = selectedPlugin ? homeSectionId(selectedPlugin) : null;
+ const origin: Crumb | null = managing
+ ? { label: translate("plugins_view.manage_title"), onClick: () => setSelectedId(null) }
+ : home
+ ? {
+ label: sectionTitle(home),
+ onClick: () => {
+ setSectionId(home);
+ setQuery("");
+ setSelectedId(null);
+ },
+ }
+ : null;
return shell(
<>
- <BackLink label={translate("plugins_view.title")} onClick={() => setSelectedId(null)} />
+ <Breadcrumbs
+ crumbs={[
+ directoryCrumb,
+ ...(origin ? [origin] : []),
+ { label: selectedPlugin?.name ?? translate("plugins_view.plugin_fallback") },
+ ]}
+ />
{selectedPlugin ? (
<PluginDetail
plugin={selectedPlugin}
@@ -1266,160 +1261,32 @@ export function PluginsView({ inDialog = false }: { inDialog?: boolean } = {}) {
);
}
- // ---- List page ---------------------------------------------------------
- const subtitle = isLoading
- ? translate("plugins_view.loading")
- : error
- ? translate("plugins_view.unreachable")
- : fill(translate("plugins_view.count"), {
- n: allPlugins.length,
- connected: connectedCount,
- });
-
- if (inDialog) {
- return shell(
- <PluginWindowCatalog
- plugins={visible} installed={installed} total={allPlugins.length}
- listFilter={listFilter} onListFilter={(value) => { setListFilter(value); setFilter("all"); }}
- query={query} onQuery={(value) => { setQuery(value); if (value.trim()) setListFilter("all"); }}
- category={filter} categories={categoryOrder}
- onCategory={(value) => { setFilter(value); setListFilter("all"); }}
- loading={isLoading} error={error instanceof Error ? error.message : null}
- refreshing={isFetching} onRefresh={() => void refetch()}
- onBrowse={() => setView("community")} onAdd={setAddMode}
- onCustomApis={() => setView("custom-apis")}
- onOpen={setSelectedId} onConnect={handleConnect} onDisconnect={handleDisconnect}
- onReset={() => { resetFilters(); setListFilter("all"); }}
- attention={attentionPlugins.length} subtitle={subtitle}
- />,
- );
- }
-
+ // ---- Directory -----------------------------------------------------------
return shell(
- <>
- <PanelHeader
- title={translate("plugins_view.title")}
- subtitle={subtitle}
- actions={
- <>
- <IconButton
- label={translate("plugins_view.search_placeholder")}
- active={searchOpen}
- onClick={() => (searchOpen ? closeSearch() : setSearchOpen(true))}
- >
- <Search className="h-4 w-4" />
- </IconButton>
- <IconButton
- label={translate("plugins_view.refresh")}
- onClick={() => void refetch()}
- busy={isFetching && !data}
- >
- <RefreshCw className="h-4 w-4" />
- </IconButton>
- <SoftButton onClick={() => setView("community")} className="ml-1">
- {translate("plugins_view.browse")}
- </SoftButton>
- <SoftButton onClick={() => setView("custom-apis")}>{translate("custom_apis.title")}</SoftButton>
- <ActionMenu
- label={translate("plugins_view.add")}
- actions={[
- {
- id: "connector",
- label: translate("custom_connector.menu_connector"),
- icon: <Link2 className="h-3.5 w-3.5" />,
- onSelect: () => setAddMode("connector"),
- },
- {
- id: "upload",
- label: translate("custom_connector.menu_folder"),
- icon: <FolderUp className="h-3.5 w-3.5" />,
- onSelect: () => setAddMode("folder"),
- },
- {
- id: "community",
- label: translate("plugins_view.add_community"),
- icon: <Store className="h-3.5 w-3.5" />,
- separatorAbove: true,
- onSelect: () => setView("community"),
- },
- {
- id: "marketplace",
- label: translate("plugins_view.add_marketplace"),
- icon: <ExternalLink className="h-3.5 w-3.5" />,
- separatorAbove: true,
- onSelect: () => setActiveSection("marketplace"),
- },
- ]}
- trigger={({ open, toggle }) => (
- <MenuPill open={open} toggle={toggle}>
- {translate("plugins_view.add")}
- </MenuPill>
- )}
- />
- </>
- }
- />
-
- {searchOpen && (
- <div className="mt-4 flex items-center gap-2">
- <div className="flex-1">
- <InlineSearch
- value={query}
- onChange={setQuery}
- placeholder={translate("plugins_view.search_placeholder")}
- autoFocus
- />
- </div>
- <IconButton label={translate("common.close")} onClick={closeSearch}>
- <X className="h-4 w-4" />
- </IconButton>
- </div>
- )}
-
- <div className="mt-4 flex flex-wrap items-center gap-2">
- <SegmentedFilter<ListFilter>
- label={translate("plugins_view.filter_label")}
- value={listFilter}
- onChange={setListFilter}
- options={[
- { id: "all", label: translate("plugins_view.filter_all"), count: allPlugins.length },
- { id: "installed", label: translate("plugins_view.filter_installed"), count: installed.length },
- ...(attentionPlugins.length > 0
- ? [{ id: "attention" as const, label: translate("plugins_view.filter_attention"), count: attentionPlugins.length }]
- : []),
- ]}
- />
- <div className="ml-auto flex items-center gap-2">
- {filtersActive && (
- <>
- <span className="text-micro text-muted-foreground">
- {fill(translate("plugins_view.matches"), { n: visible.length })}
- </span>
- <button
- type="button"
- onClick={resetFilters}
- className="text-micro text-muted-foreground underline-offset-2 hover:text-foreground hover:underline"
- >
- {translate("plugins_view.clear_filters")}
- </button>
- </>
- )}
- {categoryOrder.length > 1 && (
- <BrandedSelect
- value={filter}
- onValueChange={(v) => setFilter((v || "all") as FilterId)}
- ariaLabel={translate("plugins_view.col_category")}
- className="h-7 w-auto rounded-md px-2 py-0 text-micro"
- options={[
- { value: "all", label: translate("plugins_view.all_categories") },
- ...categoryOrder.map((c) => ({ value: c, label: categoryLabel(c) })),
- ]}
- />
- )}
- </div>
- </div>
-
- <div className="mt-4">
+ <PluginBrowse
+ plugins={allPlugins}
+ categoryOrder={categoryOrder}
+ loading={isLoading}
+ error={error instanceof Error ? error.message : null}
+ refreshing={isFetching}
+ onRefresh={() => void refetch()}
+ scope={scope}
+ onScope={setScope}
+ sectionId={sectionId}
+ onSection={setSectionId}
+ query={query}
+ onQuery={setQuery}
+ managing={managing}
+ onManage={setManaging}
+ onAdd={setAddMode}
+ onCommunity={() => setView("community")}
+ onMarketplace={() => setActiveSection("marketplace")}
+ onCustomApis={() => setView("custom-apis")}
+ onOpen={setSelectedId}
+ onConnect={handleConnect}
+ onDisconnect={handleDisconnect}
+ onRemove={setRemovingPlugin}
+ banner={
<AttentionBanner
plugins={attentionPlugins}
onJump={() => {
@@ -1427,187 +1294,11 @@ export function PluginsView({ inDialog = false }: { inDialog?: boolean } = {}) {
if (target) setSelectedId(target.id);
}}
/>
- {error && (
- <div className="rounded-lg bg-secondary p-3 text-sm text-destructive">
- {(error as Error).message}
- </div>
- )}
- {!error && (
- <PluginTable
- plugins={visible}
- loading={isLoading}
- filtersActive={filtersActive || listFilter !== "all"}
- onOpen={(id) => setSelectedId(id)}
- onConnect={handleConnect}
- onDisconnect={handleDisconnect}
- onReset={() => {
- resetFilters();
- setListFilter("all");
- }}
- />
- )}
- </div>
- </>,
- );
-}
-
-// ---------------------------------------------------------------------------
-// Window catalog: larger original marks, readable descriptions and category groups.
-// The connection state and all actions are shared with the full detail view.
-// ---------------------------------------------------------------------------
-
-function PluginWindowCatalog({
- plugins, installed, total, listFilter, onListFilter, query, onQuery,
- category, categories, onCategory, loading, error, refreshing, onRefresh,
- onBrowse, onAdd, onCustomApis, onOpen, onConnect, onDisconnect, onReset, attention, subtitle,
-}: {
- plugins: Plugin[]; installed: Plugin[]; total: number; listFilter: ListFilter;
- onListFilter: (value: ListFilter) => void; query: string; onQuery: (value: string) => void;
- category: string; categories: string[]; onCategory: (value: string) => void;
- loading: boolean; error: string | null; refreshing: boolean; onRefresh: () => void;
- onBrowse: () => void; onAdd: (mode: AddPluginMode) => void; onOpen: (id: string) => void;
- onCustomApis: () => void;
- onReset: () => void; attention: number; subtitle: string;
-} & ConnectHandlers) {
- const tabs: { id: ListFilter; label: string; count?: number }[] = [
- { id: "all", label: translate("plugins_view.filter_all"), count: total },
- { id: "recommended", label: translate("plugins_view.filter_recommended") },
- { id: "installed", label: translate("plugins_view.filter_installed"), count: installed.length },
- ...(attention ? [{ id: "attention" as const, label: translate("plugins_view.filter_attention"), count: attention }] : []),
- ];
- const grouped = listFilter === "all" && !query.trim() && category === "all";
- const heading = query.trim()
- ? fill(translate("plugins_view.matches"), { n: plugins.length })
- : category !== "all" ? categoryLabel(category) : tabs.find((tab) => tab.id === listFilter)?.label;
- return (
- <>
- <div className="shrink-0 px-5 pb-4 pt-7 sm:px-7">
- <div className="flex items-center gap-3 pr-9">
- <h2 className="text-lg font-semibold tracking-tight text-foreground-strong">{translate("plugins_view.title")}</h2>
- <div className="ml-auto flex items-center gap-1">
- <IconButton label={translate("plugins_view.refresh")} onClick={onRefresh} busy={refreshing}>
- <RefreshCw className="h-3.5 w-3.5" />
- </IconButton>
- <SoftButton onClick={onBrowse}>{translate("plugins_view.browse")}</SoftButton>
- <SoftButton onClick={onCustomApis}>{translate("custom_apis.title")}</SoftButton>
- <ActionMenu
- label={translate("plugins_view.add")}
- actions={[
- {
- id: "connector",
- label: translate("custom_connector.menu_connector"),
- icon: <Link2 className="h-3.5 w-3.5" />,
- onSelect: () => onAdd("connector"),
- },
- {
- id: "upload",
- label: translate("custom_connector.menu_folder"),
- icon: <FolderUp className="h-3.5 w-3.5" />,
- onSelect: () => onAdd("folder"),
- },
- ]}
- trigger={({ open, toggle }) => (
- <IconButton label={translate("plugins_view.add")} onClick={toggle} active={open}>
- <Plus className="h-4 w-4" />
- </IconButton>
- )}
- />
- </div>
- </div>
- <p className="sr-only">{subtitle}</p>
- <button type="button" onClick={() => onListFilter("installed")}
- className="my-4 flex max-w-full items-center gap-3 rounded-lg py-1 text-sm text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
- {installed.length > 0 && <span className="flex -space-x-2" aria-hidden>
- {installed.slice(0, 4).map((plugin) => <BrandTile key={plugin.id} plugin={plugin} size="sm" />)}
- </span>}
- <span>{fill(translate("plugins_view.installed_count"), { count: installed.length })}</span>
- <ArrowRight className="h-3.5 w-3.5" aria-hidden />
- </button>
- <label className="flex h-10 items-center gap-2 rounded-xl border border-border/70 bg-secondary px-3 text-muted-foreground focus-within:ring-2 focus-within:ring-ring">
- <Search className="h-4 w-4 shrink-0" aria-hidden />
- <input type="search" value={query} onChange={(event) => onQuery(event.target.value)}
- placeholder={translate("plugins_view.search_placeholder")} aria-label={translate("plugins_view.search_placeholder")}
- className="min-w-0 flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground" />
- </label>
- <div className="mt-3 flex flex-wrap items-center gap-2">
- <div role="tablist" aria-label={translate("plugins_view.filter_label")} className="flex flex-wrap gap-1.5">
- {tabs.map((tab) => <button key={tab.id} type="button" role="tab" aria-selected={listFilter === tab.id && category === "all"}
- onClick={() => onListFilter(tab.id)}
- className={cn("rounded-full px-3 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
- listFilter === tab.id && category === "all" ? "bg-primary text-primary-foreground" : "bg-secondary text-muted-foreground hover:text-foreground")}>
- {tab.label}{tab.count !== undefined && <span className="ml-1.5 opacity-65">{tab.count}</span>}
- </button>)}
- </div>
- <BrandedSelect value={category} onValueChange={onCategory}
- ariaLabel={translate("plugins_view.col_category")}
- testId="plugin-window-category"
- className="h-8 w-auto max-w-full rounded-full bg-secondary px-3 text-xs"
- options={[{ value: "all", label: translate("plugins_view.all_categories") },
- ...[...categories].sort((a, b) => WINDOW_CATEGORY_ORDER.indexOf(a) - WINDOW_CATEGORY_ORDER.indexOf(b)).map((name) => ({ value: name, label: categoryLabel(name) }))]} />
- </div>
- </div>
- <ScrollArea className="min-h-0 flex-1">
- <div className="px-4 pb-6 sm:px-6">
- {error && <div role="alert" className="rounded-xl bg-secondary p-4 text-sm text-destructive">{error}</div>}
- {loading && <p role="status" className="p-4 text-sm text-muted-foreground">{translate("plugins_view.loading")}</p>}
- {!error && !loading && <>
- {!grouped && <h3 className="px-2 pb-3 pt-2 text-sm font-semibold text-foreground-strong">{heading}</h3>}
- <ul aria-label={translate("plugins_view.title")}>
- {plugins.map((plugin, index) => <li key={plugin.id}>
- {grouped && (index === 0 || plugins[index - 1].category !== plugin.category) &&
- <h3 className={cn("px-2 pb-2 text-sm font-semibold text-foreground-strong", index ? "pt-5" : "pt-2")}>{categoryLabel(plugin.category)}</h3>}
- <div className="group flex min-h-[76px] items-center gap-3 rounded-xl px-2 py-3 hover:bg-secondary/70">
- <button type="button" onClick={() => onOpen(plugin.id)} aria-label={plugin.name}
- className="flex min-w-0 flex-1 items-center gap-3.5 rounded-lg text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
- <BrandTile plugin={plugin} size="window" />
- <span className="min-w-0 flex-1">
- <span className="block truncate text-[15px] font-medium leading-6 text-foreground-strong">{plugin.name}</span>
- <span className="block truncate text-[13px] leading-5 text-muted-foreground" title={plugin.description}>{plugin.description}</span>
- {plugin.unavailableReason && <span className="block text-xs text-muted-foreground" title={unavailableReasonText(plugin)}>{translate("plugins_view.unsupported_device")}</span>}
- {plugin.status === "needs_reauth" && <span className="block text-xs text-warning"><ReauthExplanation plugin={plugin} inline /></span>}
- <GrantExpiry plugin={plugin} />
- </span>
- </button>
- <WindowConnectButton plugin={plugin} onConnect={onConnect} onDisconnect={onDisconnect} />
- </div>
- </li>)}
- </ul>
- {plugins.length === 0 && <div className="py-12 text-center text-sm text-muted-foreground">
- <p>{translate("plugins_view.no_hits")}</p>
- <button type="button" onClick={onReset} className="mt-3 underline underline-offset-4">{translate("plugins_view.show_all")}</button>
- </div>}
- </>}
- </div>
- </ScrollArea>
- </>
+ }
+ />,
);
}
-function WindowConnectButton({ plugin, onConnect, onDisconnect }: { plugin: Plugin } & ConnectHandlers) {
- const [busy, setBusy] = useState(false);
- const connected = plugin.status === "connected";
- const reconnect = plugin.status === "needs_reauth" || plugin.status === "error";
- const act = async () => {
- if (busy) return;
- setBusy(true);
- try {
- if (connected) await onDisconnect(plugin.id);
- else await onConnect(plugin);
- } finally { setBusy(false); }
- };
- // Connection state in connection words, never install words: "Installed"
- // already names the marketplace tab and the community badge, so a connected
- // card saying "Added" read as done-before-authed. Connected says Connected,
- // untouched says Connect.
- return <button type="button" disabled={busy || Boolean(plugin.unavailableReason)} title={unavailableReasonText(plugin)} onClick={() => void act()}
- aria-label={translate(connected ? "plugins_view.disconnect" : reconnect ? "plugins_view.reconnect" : "plugins_view.connect")}
- className={cn("flex shrink-0 items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",
- connected ? "text-muted-foreground hover:bg-secondary" : "bg-secondary text-foreground hover:bg-accent-soft")}>
- {busy ? <Loader2 className="h-3.5 w-3.5 animate-spin" /> : connected ? <Check className="h-3.5 w-3.5 text-success" /> : reconnect ? <RotateCw className="h-3.5 w-3.5" /> : null}
- {translate(connected ? "plugins_view.status_connected" : reconnect ? "plugins_view.reconnect" : "plugins_view.connect")}
- </button>;
-}
-
// ---------------------------------------------------------------------------
// Status vocabulary shared by the table and the detail page
// ---------------------------------------------------------------------------
@@ -1625,7 +1316,7 @@ function statusTone(status: PluginStatus): "ok" | "off" | "warn" | "error" {
}
}
-function statusLabel(plugin: Plugin): string {
+export function pluginStatusLabel(plugin: Plugin): string {
if (plugin.unavailableReason) return translate("plugins_view.unsupported_device");
switch (plugin.status) {
case "connected":
@@ -1641,133 +1332,6 @@ function statusLabel(plugin: Plugin): string {
}
}
-// ---------------------------------------------------------------------------
-// Table
-// ---------------------------------------------------------------------------
-
-function PluginTable({
- plugins,
- loading,
- filtersActive,
- onOpen,
- onConnect,
- onDisconnect,
- onReset,
-}: {
- plugins: Plugin[];
- loading: boolean;
- filtersActive: boolean;
- onOpen: (id: string) => void;
- onReset: () => void;
-} & ConnectHandlers) {
- const columns: Column[] = [
- { id: "plugin", label: translate("plugins_view.col_plugin") },
- { id: "category", label: translate("plugins_view.col_category"), width: "150px" },
- { id: "status", label: translate("plugins_view.col_status"), width: "180px" },
- { id: "action", label: translate("plugins_view.col_action"), width: "36px", srOnly: true, align: "right" },
- ];
-
- if (loading) {
- return (
- <div className="py-8 text-center text-sm text-muted-foreground">
- {translate("plugins_view.loading")}
- </div>
- );
- }
-
- return (
- <Table label={translate("plugins_view.title")}>
- <TableHead columns={columns} />
- {plugins.map((plugin) => (
- <PluginTableRow
- key={plugin.id}
- plugin={plugin}
- columns={columns}
- onOpen={() => onOpen(plugin.id)}
- onConnect={onConnect}
- onDisconnect={onDisconnect}
- />
- ))}
- {plugins.length === 0 && (
- <EmptyRow>
- <p>
- {filtersActive
- ? translate("plugins_view.no_hits")
- : translate("plugins_view.empty")}
- </p>
- {filtersActive && (
- <button
- type="button"
- onClick={onReset}
- className="mt-3 text-xs text-foreground-strong hover:underline"
- >
- {translate("plugins_view.show_all")}
- </button>
- )}
- </EmptyRow>
- )}
- </Table>
- );
-}
-
-function PluginTableRow({
- plugin,
- columns,
- onOpen,
- onConnect,
- onDisconnect,
-}: { plugin: Plugin; columns: Column[]; onOpen: () => void } & ConnectHandlers) {
- return (
- <TableRow
- id={`plugin-row-${plugin.id}`}
- columns={columns}
- onClick={onOpen}
- ariaLabel={plugin.name}
- >
- <Cell>
- <div className="flex items-center gap-3" title={plugin.description}>
- <BrandTile plugin={plugin} size="sm" />
- <div className="min-w-0">
- <div className="flex items-center gap-2">
- <span className="truncate text-title font-medium">{plugin.name}</span>
- <PreviewBadge plugin={plugin} />
- {plugin.fromMarketplace && <MarketplaceBadge publisher={plugin.publisher} />}
- {plugin.selfUploaded && (
- <span
- className="rounded-full bg-secondary px-1.5 text-micro font-medium text-foreground"
- title={translate("plugin_upload.unreviewed")}
- >
- {translate("plugin_upload.self_badge")}
- </span>
- )}
- </div>
- {plugin.status === "needs_reauth" && (
- <p className="mt-0.5 truncate text-xs">
- <ReauthExplanation plugin={plugin} inline />
- </p>
- )}
- <GrantExpiry plugin={plugin} />
- </div>
- </div>
- </Cell>
- <Cell muted>
- <span className="truncate">{categoryLabel(plugin.category)}</span>
- </Cell>
- <Cell>
- <StatusDot tone={statusTone(plugin.status)} label={statusLabel(plugin)} />
- </Cell>
- <Cell align="right" stop>
- <ConnectIconButton
- status={plugin.status}
- unavailableReason={unavailableReasonText(plugin)}
- onConnect={() => onConnect(plugin)}
- onDisconnect={() => onDisconnect(plugin.id)}
- />
- </Cell>
- </TableRow>
- );
-}
-
// ---------------------------------------------------------------------------
// Detail page
// ---------------------------------------------------------------------------
@@ -1834,13 +1398,51 @@ function PluginDetail({
: []),
];
+ const primaryAction = connected ? (
+ <>
+ <SoftButton onClick={() => void run()} disabled={busy || Boolean(plugin.unavailableReason)}>
+ {busy && <Loader2 className="animate-spin" />}
+ {translate("plugins_view.reconnect")}
+ </SoftButton>
+ <span className="inline-flex h-9 items-center gap-1.5 rounded-md bg-secondary px-3 text-base font-medium text-foreground-strong">
+ <Check className="h-4 w-4 text-success" aria-hidden />
+ {translate("plugins_view.status_connected")}
+ </span>
+ </>
+ ) : (
+ <SoftButton
+ primary={!needsReconnect}
+ onClick={() => void run()}
+ disabled={busy || Boolean(plugin.unavailableReason)}
+ >
+ {busy ? <Loader2 className="animate-spin" /> : needsReconnect ? <RotateCw /> : <Plus />}
+ {needsReconnect ? translate("plugins_view.reconnect") : translate("plugins_view.connect")}
+ </SoftButton>
+ );
+
return (
- <div className="mt-5">
- <DetailHeader
- leading={<BrandTile plugin={plugin} />}
- title={plugin.name}
- titleAccessory={
- <>
+ <article className="mt-6 flex flex-col gap-8">
+ <header className="flex flex-col gap-4">
+ <div className="flex items-start justify-between gap-4">
+ <BrandTile plugin={plugin} size="hero" />
+ <div className="flex flex-wrap items-center justify-end gap-2" title={unavailableReasonText(plugin)}>
+ {menuActions.length > 0 && (
+ <ActionMenu
+ label={translate("plugins_view.more_actions")}
+ actions={menuActions}
+ trigger={({ open, toggle }) => (
+ <IconButton label={translate("plugins_view.more_actions")} onClick={toggle} active={open} className="h-9 w-9">
+ <MoreHorizontal className="h-4 w-4" />
+ </IconButton>
+ )}
+ />
+ )}
+ {primaryAction}
+ </div>
+ </div>
+ <div className="min-w-0">
+ <div className="flex min-w-0 flex-wrap items-center gap-2">
+ <h3 className="min-w-0 break-words text-xl font-semibold text-foreground-strong">{plugin.name}</h3>
<PreviewBadge plugin={plugin} />
{plugin.fromMarketplace && <MarketplaceBadge publisher={plugin.publisher} />}
{plugin.selfUploaded && (
@@ -1851,140 +1453,102 @@ function PluginDetail({
{translate("plugin_upload.self_badge")}
</span>
)}
- </>
- }
- byline={
- <span className="inline-flex items-center gap-2">
- <StatusDot tone={statusTone(plugin.status)} label={statusLabel(plugin)} />
+ </div>
+ <p className="mt-1.5 flex flex-wrap items-center gap-x-2 gap-y-1 text-base text-muted-foreground">
+ <StatusDot tone={statusTone(plugin.status)} label={pluginStatusLabel(plugin)} />
<span>· {categoryLabel(plugin.category)}</span>
{plugin.publisher && (
<span>· {fill(translate("plugins_view.by"), { publisher: plugin.publisher })}</span>
)}
- </span>
- }
- actions={
- <>
- {connected ? (
- <>
- <span className="inline-flex h-8 items-center gap-1.5 rounded-md bg-secondary px-3 text-xs font-medium text-foreground-strong">
- <Check className="h-3.5 w-3.5" />
- {translate("plugins_view.status_connected")}
- </span>
- <SoftButton onClick={() => void run()} disabled={busy || Boolean(plugin.unavailableReason)}>
- {translate("plugins_view.reconnect")}
- </SoftButton>
- </>
- ) : (
- <button
- type="button"
- onClick={() => void run()}
- disabled={busy || Boolean(plugin.unavailableReason)}
- title={unavailableReasonText(plugin)}
- aria-busy={busy}
- className={cn(
- "inline-flex h-8 items-center gap-1.5 rounded-md px-3 text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-60",
- needsReconnect
- ? "bg-secondary text-foreground hover:bg-popover"
- : "bg-primary text-primary-foreground hover:bg-primary/90",
- )}
- >
- {busy ? (
- <Loader2 className="h-3.5 w-3.5 animate-spin" />
- ) : needsReconnect ? (
- <RotateCw className="h-3.5 w-3.5" />
- ) : (
- <Plus className="h-3.5 w-3.5" />
- )}
- {needsReconnect ? translate("plugins_view.reconnect") : translate("plugins_view.connect")}
- </button>
- )}
- {menuActions.length > 0 && (
- <ActionMenu
- label={translate("plugins_view.more_actions")}
- actions={menuActions}
- trigger={({ open, toggle }) => (
- <IconButton label={translate("plugins_view.more_actions")} onClick={toggle} active={open}>
- <MoreHorizontal className="h-4 w-4" />
- </IconButton>
- )}
- />
- )}
- </>
- }
- />
-
- {plugin.unavailableReason && <p className="mt-3 text-sm text-muted-foreground">{unavailableReasonText(plugin)}</p>}
- {plugin.status === "needs_reauth" ? (
- <div className="mt-4 rounded-md bg-secondary px-3 py-2.5 text-xs">
- <ReauthExplanation plugin={plugin} />
+ </p>
</div>
- ) : null}
+ </header>
- <GrantExpiry plugin={plugin} />
-
- {plugin.description && (
- <ClampedText
- className="mt-4"
- text={plugin.description}
- moreLabel={translate("common.see_more")}
- lessLabel={translate("common.see_less")}
- />
+ {(plugin.unavailableReason || plugin.status === "needs_reauth" || plugin.description) && (
+ <div className="flex flex-col gap-3">
+ {plugin.unavailableReason && (
+ <p className="text-base text-muted-foreground">{unavailableReasonText(plugin)}</p>
+ )}
+ {plugin.status === "needs_reauth" ? (
+ <div className="rounded-lg bg-secondary px-3 py-2.5 text-xs">
+ <ReauthExplanation plugin={plugin} />
+ </div>
+ ) : null}
+ <GrantExpiry plugin={plugin} />
+ {plugin.description && (
+ <ClampedText
+ text={plugin.description}
+ moreLabel={translate("common.see_more")}
+ lessLabel={translate("common.see_less")}
+ />
+ )}
+ </div>
)}
- <Panel className="mt-4">
- <div className="px-5 py-4">
- <FactRows
- rows={[
- { label: translate("plugins_view.col_status"), value: statusLabel(plugin) },
- { label: translate("plugins_view.fact_signin"), value: translate(AUTH_LABELS[plugin.authMode]) },
- {
- label: translate("plugins_view.fact_connection"),
- value: (
- <span className={cn(plugin.longevity === "provider_limited" && "text-foreground")}>
- {translate(LONGEVITY_LABEL[plugin.longevity])}
- {plugin.longevityNote ? (
- <span className="block text-xs text-muted-foreground">{longevityNoteText(plugin)}</span>
- ) : null}
- </span>
- ),
- },
- {
- label: translate("plugins_view.fact_oauth_client"),
- value: family
- ? plugin.oauthClientConfigured
- ? fill(translate("plugins_view.oauth_client_own"), { family: family.label })
- : translate("plugins_view.err_misconfigured")
- : null,
- },
- {
- label: translate("custom_connector.fact_server"),
- value:
- plugin.selfUploaded && plugin.mcpUrl ? (
- <code className="break-all font-mono text-meta">{plugin.mcpUrl}</code>
- ) : null,
- },
- { label: translate("plugins_view.fact_publisher"), value: plugin.publisher ?? null },
- {
- label: translate("plugins_view.fact_source"),
- value: plugin.selfUploaded
- ? translate("plugin_upload.unreviewed")
- : plugin.fromMarketplace
- ? translate("marketplace_origin.tooltip")
+ <section aria-labelledby="plugin-information" className="flex flex-col gap-3">
+ <h4 id="plugin-information" className="text-title font-semibold text-foreground-strong">
+ {translate("plugins_view.detail_information")}
+ </h4>
+ <Panel>
+ <div className="px-5 py-4">
+ <FactRows
+ rows={[
+ { label: translate("plugins_view.col_status"), value: pluginStatusLabel(plugin) },
+ { label: translate("plugins_view.col_category"), value: categoryLabel(plugin.category) },
+ { label: translate("plugins_view.fact_signin"), value: translate(AUTH_LABELS[plugin.authMode]) },
+ {
+ label: translate("plugins_view.fact_connection"),
+ value: (
+ <span className={cn(plugin.longevity === "provider_limited" && "text-foreground")}>
+ {translate(LONGEVITY_LABEL[plugin.longevity])}
+ {plugin.longevityNote ? (
+ <span className="block text-xs text-muted-foreground">{longevityNoteText(plugin)}</span>
+ ) : null}
+ </span>
+ ),
+ },
+ {
+ label: translate("plugins_view.fact_oauth_client"),
+ value: family
+ ? plugin.oauthClientConfigured
+ ? fill(translate("plugins_view.oauth_client_own"), { family: family.label })
+ : translate("plugins_view.err_misconfigured")
: null,
- },
- ]}
- />
- </div>
- </Panel>
-
- <FileCard
- className="mt-4"
- rootLabel={plugin.id}
- files={filesQuery.data?.files ?? []}
- loading={filesQuery.isPending}
- error={filesQuery.error ? (filesQuery.error as Error).message : null}
- />
- </div>
+ },
+ {
+ label: translate("custom_connector.fact_server"),
+ value:
+ plugin.selfUploaded && plugin.mcpUrl ? (
+ <code className="break-all font-mono text-meta">{plugin.mcpUrl}</code>
+ ) : null,
+ },
+ { label: translate("plugins_view.fact_publisher"), value: plugin.publisher ?? null },
+ {
+ label: translate("plugins_view.fact_source"),
+ value: plugin.selfUploaded
+ ? translate("plugin_upload.unreviewed")
+ : plugin.fromMarketplace
+ ? translate("marketplace_origin.tooltip")
+ : null,
+ },
+ ]}
+ />
+ </div>
+ </Panel>
+ </section>
+
+ <section aria-labelledby="plugin-files" className="flex flex-col gap-3">
+ <h4 id="plugin-files" className="text-title font-semibold text-foreground-strong">
+ {translate("plugins_view.detail_files")}
+ </h4>
+ <FileCard
+ rootLabel={plugin.id}
+ files={filesQuery.data?.files ?? []}
+ loading={filesQuery.isPending}
+ error={filesQuery.error ? (filesQuery.error as Error).message : null}
+ />
+ </section>
+ </article>
);
}
@@ -2055,18 +1619,18 @@ interface ConnectHandlers {
onDisconnect: (id: string) => void;
}
-export function BrandTile({ plugin, size = "md" }: { plugin: Plugin; size?: "sm" | "md" | "window" }) {
+export function BrandTile({ plugin, size = "md" }: { plugin: Plugin; size?: "xs" | "sm" | "md" | "row" | "hero" }) {
const [failed, setFailed] = useState(false);
const tile = brandTile(plugin);
const fullColour = isFullColourMark(plugin);
const showMonogram = failed || !plugin.logoSlug;
- const small = size === "sm";
+ const small = size === "sm" || size === "xs";
return (
<div
className={cn(
"grid shrink-0 place-items-center overflow-hidden rounded-lg border",
- small ? "h-7 w-7 rounded-md" : size === "window" ? "h-12 w-12 rounded-xl" : "h-10 w-10",
+ size === "xs" ? "h-5 w-5 rounded" : small ? "h-7 w-7 rounded-md" : size === "hero" ? "h-14 w-14 rounded-2xl" : size === "row" ? "h-9 w-9" : "h-10 w-10",
// White app-icon tiles follow the reference in either interface theme.
// Existing white monochrome marks are inverted below, keeping their
// original geometry legible without recolouring multicolour artwork.
@@ -2078,7 +1642,7 @@ export function BrandTile({ plugin, size = "md" }: { plugin: Plugin; size?: "sm"
>
{showMonogram ? (
<span
- className={cn("font-semibold", small ? "text-xs" : "text-sm")}
+ className={cn("font-semibold", small ? "text-xs" : size === "hero" ? "text-xl" : "text-sm")}
style={{ color: `#${glyphColor(tile)}` }}
>
{plugin.name.slice(0, 1).toUpperCase()}
@@ -2088,7 +1652,9 @@ export function BrandTile({ plugin, size = "md" }: { plugin: Plugin; size?: "sm"
src={resolveLogoUrl(plugin)}
alt=""
className={cn(
- fullColour ? (small ? "h-5 w-5" : size === "window" ? "h-9 w-9" : "h-7 w-7") : small ? "h-3.5 w-3.5" : size === "window" ? "h-8 w-8" : "h-5 w-5",
+ fullColour
+ ? (size === "xs" ? "h-3.5 w-3.5" : small ? "h-5 w-5" : size === "hero" ? "h-10 w-10" : size === "row" ? "h-6 w-6" : "h-7 w-7")
+ : size === "xs" ? "h-3 w-3" : small ? "h-3.5 w-3.5" : size === "hero" ? "h-8 w-8" : "h-5 w-5",
["github", "vercel", "notion", "cal_com"].includes(plugin.id) && "invert",
)}
loading="lazy"
@@ -2209,8 +1775,8 @@ export function ReauthExplanation({ plugin, inline }: { plugin: Plugin; inline?:
* — a burst of browser tabs and stray client registrations. `busyRef` is the
* SYNCHRONOUS guard (React state is async and would let a fast double-click
* through before the re-render disables the button); `busy` drives the UI.
- * PluginRow owns one lock and hands it to the icon button, so a click on the
- * card and a click on the "+" can never race into two flows.
+ * A directory row owns one lock for its "+" and its menu's Reconnect, so the
+ * two can never race into two flows.
*/
export function useConnectLock(onConnect: () => void | Promise<void>) {
const [busy, setBusy] = useState(false);
@@ -2231,97 +1797,6 @@ export function useConnectLock(onConnect: () => void | Promise<void>) {
return { busy, run };
}
-export function ConnectIconButton({
- status,
- onConnect,
- onDisconnect,
- busy: busyFromRow,
- unavailableReason,
-}: {
- status: PluginStatus;
- onConnect: () => void | Promise<void>;
- onDisconnect: () => void;
- /** Set when the surrounding card owns the lock, so a flow started by clicking
- * the card still spins this button. */
- busy?: boolean;
- unavailableReason?: string;
-}) {
- const lock = useConnectLock(onConnect);
- const busy = busyFromRow ?? lock.busy;
-
- if (status === "connected") {
- return (
- <button
- type="button"
- onClick={(e) => {
- e.stopPropagation();
- onDisconnect();
- }}
- className="grid h-7 w-7 shrink-0 place-items-center rounded-full bg-secondary text-foreground-strong transition-colors hover:bg-popover hover:text-destructive"
- aria-label={translate("plugins_view.disconnect_plugin")}
- title={translate("plugins_view.disconnect")}
- >
- <Check className="h-3.5 w-3.5" />
- </button>
- );
- }
-
- // The card around this button is clickable too — without stopPropagation the
- // same click would reach both handlers.
- const handleClick = (e: React.MouseEvent) => {
- e.stopPropagation();
- void lock.run();
- };
-
- // A revoked / errored token re-runs the SAME connect flow, but is shown as a
- // distinct amber "Reconnect" affordance so it can never be mistaken for a
- // never-connected "+" (the silent-rot bug this view used to have).
- const needsReconnect = status === "needs_reauth" || status === "error";
- if (needsReconnect) {
- return (
- <button
- type="button"
- onClick={handleClick}
- disabled={busy || Boolean(unavailableReason)}
- aria-busy={busy}
- className={cn(
- "grid h-7 w-7 shrink-0 place-items-center rounded-full bg-secondary text-foreground transition-all hover:bg-popover group-hover:scale-105",
- busy && "cursor-not-allowed opacity-60 group-hover:scale-100",
- )}
- aria-label={translate("plugins_view.reconnect_plugin")}
- title={unavailableReason ?? translate("plugins_view.reconnect")}
- >
- {busy ? (
- <Loader2 className="h-3.5 w-3.5 animate-spin" />
- ) : (
- <RotateCw className="h-3.5 w-3.5" />
- )}
- </button>
- );
- }
-
- return (
- <button
- type="button"
- onClick={handleClick}
- disabled={busy || Boolean(unavailableReason)}
- aria-busy={busy}
- className={cn(
- "grid h-7 w-7 shrink-0 place-items-center rounded-full border border-border bg-background text-muted-foreground transition-all hover:border-border-strong hover:bg-secondary hover:text-foreground-strong group-hover:scale-105",
- busy && "cursor-not-allowed opacity-60 hover:bg-secondary hover:text-muted-foreground group-hover:scale-100",
- )}
- title={unavailableReason}
- aria-label={translate("plugins_view.connect_plugin")}
- >
- {busy ? (
- <Loader2 className="h-3.5 w-3.5 animate-spin" />
- ) : (
- <Plus className="h-3.5 w-3.5" />
- )}
- </button>
- );
-}
-
// ---------------------------------------------------------------------------
// OAuth Redirect Dialog — used by Notion (and any future hosted-MCP plugin
// with DCR + PKCE). The browser tab is already opened by the caller; this
diff --git a/jarvis/ui/web/frontend/src/views/plugins/ExtensionsSidebar.tsx b/jarvis/ui/web/frontend/src/views/plugins/ExtensionsSidebar.tsx
new file mode 100644
index 0000000000..37c2a14258
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/views/plugins/ExtensionsSidebar.tsx
@@ -0,0 +1,156 @@
+/**
+ * The navigation column of the Plugins, MCPs & Skills section: its three areas
+ * and, below them, every plugin the owner connected or added. Clicking one
+ * opens its page, so a connection is one click away from any area.
+ */
+import { useMemo, useState } from "react";
+import { Search, X } from "lucide-react";
+import { translate, useT } from "@/i18n";
+import { cn } from "@/lib/utils";
+import { ConnectorIcon, PluginIcon, SkillIcon } from "@/components/icons/sectionIcons";
+import { ScrollArea } from "@/components/ui/scroll-area";
+import type { PluginArea } from "@/views/PluginsDialog";
+import { BrandTile, matchesQuery, sortPluginsByName, usePluginCatalog } from "@/views/PluginsView";
+import { isInstalled } from "@/views/plugins/sections";
+
+const AREAS = [
+ { id: "plugins", labelKey: "nav.plugins", Icon: PluginIcon },
+ { id: "mcps", labelKey: "nav.mcps", Icon: ConnectorIcon },
+ { id: "skills", labelKey: "nav.skills", Icon: SkillIcon },
+] as const;
+
+const ITEM =
+ "flex min-w-0 items-center gap-2.5 rounded-lg px-2 text-left text-base transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring";
+
+export function ExtensionsSidebar({
+ area,
+ onArea,
+ selectedPluginId,
+ onOpenPlugin,
+}: {
+ area: PluginArea;
+ onArea: (area: PluginArea) => void;
+ selectedPluginId: string | null;
+ onOpenPlugin: (id: string) => void;
+}) {
+ const t = useT();
+ const { plugins, isLoading, error, refetch } = usePluginCatalog();
+ const [searching, setSearching] = useState(false);
+ const [query, setQuery] = useState("");
+ const installed = useMemo(
+ () => plugins.filter(isInstalled).sort(sortPluginsByName),
+ [plugins],
+ );
+ const shown = query.trim() ? installed.filter((plugin) => matchesQuery(plugin, query)) : installed;
+ const closeSearch = () => {
+ setSearching(false);
+ setQuery("");
+ };
+
+ return (
+ <aside className="flex shrink-0 flex-col border-b border-border bg-sidebar md:w-[232px] md:border-b-0 md:border-r">
+ <h2 className="hidden px-4 pb-2 pt-4 text-base font-semibold text-foreground-strong md:block">
+ {t("plugins_view.frame_title")}
+ </h2>
+ <nav aria-label={t("nav.extensions")} className="flex gap-1 p-2 md:flex-col md:gap-0.5 md:py-0">
+ {AREAS.map(({ id, labelKey, Icon }) => (
+ <button
+ key={id}
+ type="button"
+ onClick={() => onArea(id)}
+ aria-current={area === id && !selectedPluginId ? "page" : undefined}
+ className={cn(
+ ITEM,
+ "h-8",
+ area === id && !selectedPluginId
+ ? "bg-secondary font-medium text-foreground-strong"
+ : "text-muted-foreground hover:bg-secondary hover:text-foreground",
+ )}
+ >
+ <Icon className="h-4 w-4 shrink-0" aria-hidden />
+ <span className="truncate">{t(labelKey)}</span>
+ </button>
+ ))}
+ </nav>
+
+ <div className="hidden min-h-0 flex-1 flex-col md:flex">
+ <div className="flex h-8 items-center justify-between pl-4 pr-2 pt-5">
+ <h3 className="text-sm text-muted-foreground">{t("plugins_view.installed_heading")}</h3>
+ <button
+ type="button"
+ onClick={() => (searching ? closeSearch() : setSearching(true))}
+ aria-label={t("plugins_view.installed_search")}
+ aria-pressed={searching}
+ title={t("plugins_view.installed_search")}
+ className="grid h-6 w-6 place-items-center rounded-md text-muted-foreground hover:bg-secondary hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ >
+ {searching ? <X className="h-3.5 w-3.5" aria-hidden /> : <Search className="h-3.5 w-3.5" aria-hidden />}
+ </button>
+ </div>
+ {searching && (
+ <div className="px-2 pt-3">
+ <input
+ type="search"
+ autoFocus
+ data-escape-local=""
+ value={query}
+ onChange={(event) => setQuery(event.target.value)}
+ // Escape leaves the search, not the whole plugin window.
+ onKeyDown={(event) => { if (event.key === "Escape") closeSearch(); }}
+ placeholder={t("plugins_view.installed_search")}
+ aria-label={t("plugins_view.installed_search")}
+ className="h-8 w-full rounded-lg border border-border bg-background px-2.5 text-sm text-foreground outline-none placeholder:text-foreground-faint focus:border-border-strong [&::-webkit-search-cancel-button]:hidden"
+ />
+ </div>
+ )}
+ <ScrollArea className="mt-2 min-h-0 flex-1">
+ <ul aria-label={t("plugins_view.installed_heading")} className="flex flex-col gap-0.5 px-2 pb-3">
+ {shown.map((plugin) => {
+ const broken = plugin.status === "needs_reauth" || plugin.status === "error";
+ const active = area === "plugins" && selectedPluginId === plugin.id;
+ return (
+ <li key={plugin.id}>
+ <button
+ type="button"
+ onClick={() => onOpenPlugin(plugin.id)}
+ aria-current={active ? "page" : undefined}
+ className={cn(
+ ITEM,
+ "h-8 w-full",
+ active
+ ? "bg-secondary font-medium text-foreground-strong"
+ : "text-foreground hover:bg-secondary",
+ )}
+ >
+ <BrandTile plugin={plugin} size="xs" />
+ <span className="min-w-0 flex-1 truncate">{plugin.name}</span>
+ {broken && (
+ <span role="img" aria-label={translate("plugins_view.status_reauth")} title={translate("plugins_view.status_reauth")}
+ className="h-1.5 w-1.5 shrink-0 rounded-full bg-warning" />
+ )}
+ </button>
+ </li>
+ );
+ })}
+ </ul>
+ {shown.length === 0 && (
+ <div className="px-4 pb-3 text-sm text-muted-foreground">
+ {isLoading ? (
+ <p role="status">{t("plugins_view.loading")}</p>
+ ) : error ? (
+ <>
+ <p role="alert">{t("plugins_view.unreachable")}</p>
+ <button type="button" onClick={() => void refetch()} className="mt-2 underline underline-offset-4 hover:text-foreground">
+ {t("common.retry")}
+ </button>
+ </>
+ ) : (
+ <p>{t(query.trim() ? "plugins_view.installed_no_match" : "plugins_view.installed_empty")}</p>
+ )}
+ </div>
+ )}
+ </ScrollArea>
+ </div>
+ </aside>
+ );
+}
diff --git a/jarvis/ui/web/frontend/src/views/plugins/PluginBrowse.tsx b/jarvis/ui/web/frontend/src/views/plugins/PluginBrowse.tsx
new file mode 100644
index 0000000000..85dba5aa58
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/views/plugins/PluginBrowse.tsx
@@ -0,0 +1,584 @@
+/**
+ * The plugin directory: a header with search and the add menu, two scopes
+ * (what ships with the app, what the owner added), and sections of rows whose
+ * headings open the full list.
+ *
+ * Connection state and every connect flow stay with `PluginsView`; this file
+ * only decides what is listed and how a row reads. Colours are theme tokens, so
+ * the page reads the same in light and dark mode.
+ */
+import type { ReactNode } from "react";
+import {
+ Check,
+ ChevronRight,
+ ExternalLink,
+ FolderUp,
+ Link2,
+ Loader2,
+ MoreHorizontal,
+ PanelsTopLeft,
+ Plus,
+ RefreshCw,
+ RotateCw,
+ Search,
+ Settings2,
+ Store,
+ Trash2,
+ Unplug,
+ X,
+} from "lucide-react";
+import { fill, translate } from "@/i18n";
+import { cn } from "@/lib/utils";
+import { MarketplaceBadge } from "@/components/MarketplaceBadge";
+import {
+ ActionMenu,
+ IconButton,
+ MenuPill,
+ type MenuAction,
+} from "@/components/extensions/primitives";
+import type { AddPluginMode } from "@/views/AddConnectorDialog";
+import {
+ BrandTile,
+ categoryLabel,
+ GrantExpiry,
+ type Plugin,
+ pluginStatusLabel,
+ ReauthExplanation,
+ searchPlugins,
+ sortPluginsByName,
+ unavailableReasonText,
+ useConnectLock,
+} from "@/views/PluginsView";
+import {
+ allSections,
+ type BrowseSection,
+ catalogSections,
+ COMMUNITY_SECTION,
+ homeRows,
+ isInstalled,
+ isOwnerAdded,
+ ownSections,
+ type PluginScope,
+ POPULAR_SECTION,
+ sectionCategory,
+ UPLOADED_SECTION,
+} from "@/views/plugins/sections";
+
+const isBroken = (plugin: Plugin): boolean =>
+ plugin.status === "needs_reauth" || plugin.status === "error";
+
+/** The catalog grid: one column on a narrow pane, two once both fit. */
+const GRID = "grid grid-cols-[repeat(auto-fill,minmax(min(100%,280px),1fr))] gap-x-6 gap-y-0.5";
+
+export interface PluginRowHandlers {
+ onOpen: (id: string) => void;
+ onConnect: (plugin: Plugin) => void | Promise<void>;
+ onDisconnect: (id: string) => void;
+ onRemove: (plugin: Plugin) => void;
+}
+
+/** Display title of a section id, in the current UI language. */
+export function sectionTitle(sectionId: string): string {
+ if (sectionId === POPULAR_SECTION) return translate("plugins_view.section_popular");
+ if (sectionId === UPLOADED_SECTION) return translate("plugins_view.section_uploaded");
+ if (sectionId === COMMUNITY_SECTION) return translate("plugins_view.section_community");
+ return categoryLabel(sectionCategory(sectionId) ?? sectionId);
+}
+
+// ---------------------------------------------------------------------------
+// Breadcrumbs — the only way back from a section or a plugin page
+// ---------------------------------------------------------------------------
+
+export interface Crumb {
+ label: string;
+ onClick?: () => void;
+}
+
+export function Breadcrumbs({ crumbs }: { crumbs: Crumb[] }) {
+ return (
+ <nav aria-label={translate("plugins_view.breadcrumb")} className="flex min-w-0 items-center gap-1 text-sm">
+ {crumbs.map((crumb, index) => (
+ <span key={`${index}-${crumb.label}`} className="flex min-w-0 items-center gap-1">
+ {index > 0 && <ChevronRight className="h-3.5 w-3.5 shrink-0 text-foreground-faint" aria-hidden />}
+ {crumb.onClick ? (
+ <button
+ type="button"
+ onClick={crumb.onClick}
+ className="truncate rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ >
+ {crumb.label}
+ </button>
+ ) : (
+ <span aria-current="page" className="truncate text-foreground">{crumb.label}</span>
+ )}
+ </span>
+ ))}
+ </nav>
+ );
+}
+
+// ---------------------------------------------------------------------------
+// Row
+// ---------------------------------------------------------------------------
+
+/** Where an owner-added plugin came from, in the same marks the rest of the
+ * app uses for it. A plugin the app ships carries none. */
+function OriginMark({ plugin }: { plugin: Plugin }) {
+ if (plugin.selfUploaded) {
+ return (
+ <span
+ className="shrink-0 rounded-full bg-surface-raised px-1.5 text-micro font-medium text-foreground"
+ title={translate("plugin_upload.unreviewed")}
+ >
+ {translate("plugin_upload.self_badge")}
+ </span>
+ );
+ }
+ return plugin.fromMarketplace ? <MarketplaceBadge publisher={plugin.publisher} /> : null;
+}
+
+const ACTION_BUTTON =
+ "grid h-7 w-7 shrink-0 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-surface-raised hover:text-foreground-strong focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-60";
+
+/** The trailing control of a row. One state at a time, first match wins:
+ * connecting, connected (menu), broken (reconnect + menu), otherwise the "+"
+ * that starts the connection — disabled where the plugin cannot run on this
+ * device. Connection words throughout: an untouched plugin offers Connect,
+ * never Add. */
+function RowAction({
+ plugin,
+ busy,
+ run,
+ onOpen,
+ onDisconnect,
+ onRemove,
+}: { plugin: Plugin; busy: boolean; run: () => Promise<void> } & Omit<PluginRowHandlers, "onConnect">) {
+ const connected = plugin.status === "connected";
+ const broken = isBroken(plugin);
+
+ if (busy) {
+ return (
+ <button type="button" disabled aria-busy className={ACTION_BUTTON}
+ aria-label={fill(translate("plugins_view.connecting_plugin"), { plugin: plugin.name })}>
+ <Loader2 className="h-4 w-4 animate-spin" aria-hidden />
+ </button>
+ );
+ }
+
+ if (!connected && !broken) {
+ return (
+ <button type="button" onClick={() => void run()} className={ACTION_BUTTON}
+ disabled={Boolean(plugin.unavailableReason)}
+ aria-label={translate("plugins_view.connect_plugin")}
+ title={unavailableReasonText(plugin) ?? translate("plugins_view.connect")}>
+ <Plus className="h-4 w-4" aria-hidden />
+ </button>
+ );
+ }
+
+ const actions: MenuAction[] = [
+ {
+ id: "open",
+ label: translate("plugins_view.open_details"),
+ icon: <PanelsTopLeft className="h-3.5 w-3.5" />,
+ onSelect: () => onOpen(plugin.id),
+ },
+ ...(connected
+ ? [{
+ id: "reconnect",
+ label: translate("plugins_view.reconnect"),
+ icon: <RotateCw className="h-3.5 w-3.5" />,
+ onSelect: () => void run(),
+ }]
+ : []),
+ {
+ id: "disconnect",
+ label: translate("plugins_view.disconnect"),
+ icon: <Unplug className="h-3.5 w-3.5" />,
+ destructive: true,
+ separatorAbove: true,
+ onSelect: () => onDisconnect(plugin.id),
+ },
+ ...(isOwnerAdded(plugin)
+ ? [{
+ id: "remove",
+ label: translate("custom_connector.remove"),
+ icon: <Trash2 className="h-3.5 w-3.5" />,
+ destructive: true,
+ onSelect: () => onRemove(plugin),
+ }]
+ : []),
+ ];
+
+ return (
+ <span className="flex shrink-0 items-center gap-0.5">
+ {connected ? (
+ <span role="img" aria-label={translate("plugins_view.status_connected")} title={pluginStatusLabel(plugin)}
+ className="grid h-7 w-6 place-items-center text-success">
+ <Check className="h-4 w-4" aria-hidden />
+ </span>
+ ) : (
+ <button type="button" onClick={() => void run()} className={cn(ACTION_BUTTON, "text-warning hover:text-warning")}
+ aria-label={translate("plugins_view.reconnect_plugin")} title={translate("plugins_view.reconnect")}>
+ <RotateCw className="h-4 w-4" aria-hidden />
+ </button>
+ )}
+ <ActionMenu
+ label={translate("plugins_view.more_actions")}
+ actions={actions}
+ trigger={({ open, toggle }) => (
+ <button type="button" onClick={toggle} aria-haspopup="menu" aria-expanded={open}
+ aria-label={translate("plugins_view.more_actions")} title={translate("plugins_view.more_actions")}
+ className={cn(ACTION_BUTTON, open && "bg-surface-raised text-foreground-strong")}>
+ <MoreHorizontal className="h-4 w-4" aria-hidden />
+ </button>
+ )}
+ />
+ </span>
+ );
+}
+
+export function PluginRow({
+ plugin,
+ showStatus = false,
+ onOpen,
+ onConnect,
+ onDisconnect,
+ onRemove,
+}: { plugin: Plugin; showStatus?: boolean } & PluginRowHandlers) {
+ // One lock per row: the "+" and a menu "Reconnect" can never race into two
+ // sign-in flows for the same plugin.
+ const { busy, run } = useConnectLock(() => onConnect(plugin));
+ return (
+ <li className="flex min-h-14 items-center gap-1 rounded-xl pr-1.5 transition-colors hover:bg-secondary focus-within:bg-secondary">
+ <button
+ type="button"
+ onClick={() => onOpen(plugin.id)}
+ aria-label={plugin.name}
+ className="flex min-w-0 flex-1 items-center gap-3 rounded-xl px-2 py-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ >
+ <BrandTile plugin={plugin} size="row" />
+ <span className="min-w-0 flex-1">
+ <span className="flex min-w-0 items-center gap-1.5">
+ <span className="truncate text-base font-medium text-foreground-strong">{plugin.name}</span>
+ <OriginMark plugin={plugin} />
+ </span>
+ <span className="block truncate text-sm text-muted-foreground" title={plugin.description}>
+ {plugin.description}
+ </span>
+ {plugin.unavailableReason && (
+ <span className="block truncate text-xs text-muted-foreground" title={unavailableReasonText(plugin)}>
+ {translate("plugins_view.unsupported_device")}
+ </span>
+ )}
+ {plugin.status === "needs_reauth" && (
+ <span className="block truncate text-xs text-warning"><ReauthExplanation plugin={plugin} inline /></span>
+ )}
+ <GrantExpiry plugin={plugin} />
+ </span>
+ {showStatus && (
+ <span className="hidden shrink-0 text-sm text-muted-foreground sm:block">{pluginStatusLabel(plugin)}</span>
+ )}
+ </button>
+ <RowAction plugin={plugin} busy={busy} run={run} onOpen={onOpen} onDisconnect={onDisconnect} onRemove={onRemove} />
+ </li>
+ );
+}
+
+function PluginGrid({ plugins, label, single = false, showStatus = false, handlers }: {
+ plugins: Plugin[];
+ label: string;
+ single?: boolean;
+ showStatus?: boolean;
+ handlers: PluginRowHandlers;
+}) {
+ return (
+ <ul aria-label={label} className={single ? "flex flex-col gap-0.5" : GRID}>
+ {plugins.map((plugin) => (
+ <PluginRow key={plugin.id} plugin={plugin} showStatus={showStatus} {...handlers} />
+ ))}
+ </ul>
+ );
+}
+
+/** Six placeholder rows in the catalog grid while the first load is running. */
+function BrowseSkeleton() {
+ const widths = ["w-20", "w-16", "w-24", "w-16", "w-20", "w-16"];
+ return (
+ <div role="status" className="flex flex-col gap-4">
+ <span className="sr-only">{translate("plugins_view.loading")}</span>
+ <span className="h-3 w-20 rounded bg-secondary motion-safe:animate-pulse" aria-hidden />
+ <div className={GRID} aria-hidden>
+ {widths.map((width, index) => (
+ <div key={index} className="flex min-h-14 items-center gap-3 px-2 py-2 motion-safe:animate-pulse">
+ <span className="h-9 w-9 shrink-0 rounded-lg bg-secondary" />
+ <span className="flex min-w-0 flex-1 flex-col gap-2">
+ <span className={cn("h-3 rounded bg-secondary", width)} />
+ <span className="h-3 w-3/5 rounded bg-secondary" />
+ </span>
+ </div>
+ ))}
+ </div>
+ </div>
+ );
+}
+
+/** One home-page section: the rows it was given, under a heading that opens
+ * the section's full list. */
+function SectionBlock({ section, onOpenSection, handlers }: {
+ section: BrowseSection;
+ onOpenSection: (id: string) => void;
+ handlers: PluginRowHandlers;
+}) {
+ const title = sectionTitle(section.id);
+ return (
+ <section aria-label={title} className="flex flex-col gap-3">
+ <h3 className="px-2">
+ <button
+ type="button"
+ onClick={() => onOpenSection(section.id)}
+ aria-label={fill(translate("plugins_view.open_section"), { section: title })}
+ className="group/heading inline-flex items-center gap-1 rounded-sm text-title font-semibold text-foreground-strong focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ >
+ {title}
+ <ChevronRight className="h-4 w-4 text-foreground-faint transition-transform group-hover/heading:text-muted-foreground motion-safe:group-hover/heading:translate-x-0.5" aria-hidden />
+ </button>
+ </h3>
+ <PluginGrid plugins={section.plugins} label={title} handlers={handlers} />
+ </section>
+ );
+}
+
+// ---------------------------------------------------------------------------
+// Page
+// ---------------------------------------------------------------------------
+
+export interface PluginBrowseProps extends PluginRowHandlers {
+ plugins: Plugin[];
+ categoryOrder: string[];
+ loading: boolean;
+ error: string | null;
+ refreshing: boolean;
+ onRefresh: () => void;
+ scope: PluginScope;
+ onScope: (scope: PluginScope) => void;
+ /** The section whose full list is open, or null on the home page. */
+ sectionId: string | null;
+ onSection: (sectionId: string | null) => void;
+ query: string;
+ onQuery: (query: string) => void;
+ /** The installed list with its connection states, instead of the directory. */
+ managing: boolean;
+ onManage: (managing: boolean) => void;
+ onAdd: (mode: AddPluginMode) => void;
+ onCommunity: () => void;
+ onMarketplace: () => void;
+ onCustomApis: () => void;
+ /** Shown above the sections of the home page (the reconnect notice). */
+ banner?: ReactNode;
+}
+
+export function PluginBrowse({
+ plugins, categoryOrder, loading, error, refreshing, onRefresh,
+ scope, onScope, sectionId, onSection, query, onQuery, managing, onManage,
+ onAdd, onCommunity, onMarketplace, onCustomApis, banner,
+ onOpen, onConnect, onDisconnect, onRemove,
+}: PluginBrowseProps) {
+ const handlers: PluginRowHandlers = { onOpen, onConnect, onDisconnect, onRemove };
+ const sections = scope === "catalog" ? catalogSections(plugins, categoryOrder) : ownSections(plugins);
+ const openSection = sectionId
+ ? allSections(plugins, categoryOrder).find((section) => section.id === sectionId) ?? null
+ : null;
+ // What needs a reconnect leads the installed list; the rest follows A-Z.
+ const installed = plugins.filter(isInstalled).sort((a, b) =>
+ Number(isBroken(b)) - Number(isBroken(a)) || sortPluginsByName(a, b));
+ const searching = query.trim() !== "";
+ // A search stays inside whatever is open: one section, the installed list,
+ // or — on the home page — every plugin of both scopes.
+ const pool = managing ? installed : openSection ? openSection.plugins : plugins;
+ const results = searching ? searchPlugins(pool, query) : pool;
+ const home = !managing && !openSection && !searching;
+
+ const title = managing
+ ? translate("plugins_view.manage_title")
+ : openSection ? sectionTitle(openSection.id) : translate("plugins_view.title");
+ const subtitle = managing
+ ? translate("plugins_view.manage_subtitle")
+ : openSection ? null : translate("plugins_view.subtitle");
+
+ const leave = () => {
+ onManage(false);
+ onSection(null);
+ onQuery("");
+ };
+
+ const addActions: MenuAction[] = [
+ {
+ id: "connector",
+ label: translate("custom_connector.menu_connector"),
+ icon: <Link2 className="h-3.5 w-3.5" />,
+ onSelect: () => onAdd("connector"),
+ },
+ {
+ id: "upload",
+ label: translate("custom_connector.menu_folder"),
+ icon: <FolderUp className="h-3.5 w-3.5" />,
+ onSelect: () => onAdd("folder"),
+ },
+ {
+ id: "custom-apis",
+ label: translate("custom_apis.title"),
+ icon: <PanelsTopLeft className="h-3.5 w-3.5" />,
+ onSelect: onCustomApis,
+ },
+ {
+ id: "community",
+ label: translate("plugins_view.add_community"),
+ icon: <Store className="h-3.5 w-3.5" />,
+ separatorAbove: true,
+ onSelect: onCommunity,
+ },
+ {
+ id: "marketplace",
+ label: translate("plugins_view.add_marketplace"),
+ icon: <ExternalLink className="h-3.5 w-3.5" />,
+ onSelect: onMarketplace,
+ },
+ ];
+
+ return (
+ <div className="flex flex-col gap-6">
+ {(managing || openSection) && (
+ <Breadcrumbs crumbs={[{ label: translate("plugins_view.title"), onClick: leave }, { label: title }]} />
+ )}
+
+ <header className="flex flex-wrap items-start justify-between gap-x-4 gap-y-3">
+ <div className="min-w-0">
+ <h2 className="text-xl font-semibold text-foreground-strong">{title}</h2>
+ {subtitle && <p className="mt-1 text-base text-muted-foreground">{subtitle}</p>}
+ </div>
+ {/* A basis instead of a bare flex-1: on a narrow pane the controls
+ wrap under the title rather than squeezing the search shut. */}
+ <div className="flex min-w-0 flex-[1_1_18rem] items-center justify-end gap-1">
+ <label className="flex h-8 min-w-0 max-w-56 flex-1 items-center gap-2 rounded-full border border-border bg-background px-3 text-muted-foreground focus-within:border-border-strong">
+ <Search className="h-3.5 w-3.5 shrink-0" aria-hidden />
+ <input
+ type="search"
+ value={query}
+ onChange={(event) => onQuery(event.target.value)}
+ // Escape clears a search before it may close the window.
+ data-escape-local={searching ? "" : undefined}
+ onKeyDown={(event) => { if (event.key === "Escape" && searching) onQuery(""); }}
+ placeholder={translate("plugins_view.search_placeholder")}
+ aria-label={translate("plugins_view.search_placeholder")}
+ className="min-w-0 flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-foreground-faint [&::-webkit-search-cancel-button]:hidden"
+ />
+ {searching && (
+ <button type="button" onClick={() => onQuery("")} aria-label={translate("plugins_view.clear_filters")}
+ className="grid h-5 w-5 shrink-0 place-items-center rounded-full hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
+ <X className="h-3.5 w-3.5" aria-hidden />
+ </button>
+ )}
+ </label>
+ <IconButton label={translate("plugins_view.refresh")} onClick={onRefresh} busy={refreshing}>
+ <RefreshCw className="h-4 w-4" />
+ </IconButton>
+ {!managing && (
+ <IconButton label={translate("plugins_view.manage")} onClick={() => { onSection(null); onQuery(""); onManage(true); }}>
+ <Settings2 className="h-4 w-4" />
+ </IconButton>
+ )}
+ <ActionMenu
+ label={translate("plugins_view.add")}
+ actions={addActions}
+ trigger={({ open, toggle }) => (
+ <MenuPill open={open} toggle={toggle} primary>
+ {translate("plugins_view.add")}
+ </MenuPill>
+ )}
+ />
+ </div>
+ </header>
+
+ {home && (
+ <div role="tablist" aria-label={translate("plugins_view.scope_label")} className="flex gap-1">
+ {(["catalog", "yours"] as const).map((id) => (
+ <button
+ key={id}
+ type="button"
+ role="tab"
+ aria-selected={scope === id}
+ onClick={() => onScope(id)}
+ className={cn(
+ "rounded-full px-3 py-1.5 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
+ scope === id
+ ? "bg-secondary text-foreground-strong"
+ : "text-muted-foreground hover:bg-secondary hover:text-foreground",
+ )}
+ >
+ {translate(id === "catalog" ? "plugins_view.scope_catalog" : "plugins_view.scope_yours")}
+ </button>
+ ))}
+ </div>
+ )}
+
+ {error && (
+ <div role="alert" className="flex flex-wrap items-center gap-3 rounded-xl bg-secondary px-4 py-3 text-sm text-destructive">
+ <span className="min-w-0 flex-1">{error}</span>
+ <button type="button" onClick={onRefresh}
+ className="rounded-md border border-border px-2.5 py-1 text-xs font-medium text-foreground hover:bg-surface-raised">
+ {translate("common.retry")}
+ </button>
+ </div>
+ )}
+
+ {loading && <BrowseSkeleton />}
+
+ {!loading && !error && home && (
+ <>
+ {banner}
+ {homeRows(sections).map((section) => (
+ <SectionBlock key={section.id} section={section} onOpenSection={onSection} handlers={handlers} />
+ ))}
+ {sections.length === 0 && (
+ <div className="rounded-xl border border-border bg-card px-5 py-8 text-center">
+ <p className="text-base font-medium text-foreground-strong">{translate("plugins_view.yours_empty_title")}</p>
+ <p className="mx-auto mt-1 max-w-sm text-sm text-muted-foreground">{translate("plugins_view.yours_empty_body")}</p>
+ <div className="mt-4 flex flex-wrap justify-center gap-2">
+ <button type="button" onClick={() => onAdd("connector")}
+ className="inline-flex h-8 items-center gap-1.5 rounded-md bg-secondary px-3 text-sm font-medium text-foreground hover:bg-surface-raised">
+ <Link2 className="h-3.5 w-3.5" aria-hidden />{translate("custom_connector.menu_connector")}
+ </button>
+ <button type="button" onClick={onCommunity}
+ className="inline-flex h-8 items-center gap-1.5 rounded-md bg-secondary px-3 text-sm font-medium text-foreground hover:bg-surface-raised">
+ <Store className="h-3.5 w-3.5" aria-hidden />{translate("plugins_view.add_community")}
+ </button>
+ </div>
+ </div>
+ )}
+ </>
+ )}
+
+ {!loading && !error && !home && (
+ <>
+ {searching && (
+ <p className="px-2 text-sm text-muted-foreground" aria-live="polite">
+ {fill(translate("plugins_view.matches"), { n: results.length })}
+ </p>
+ )}
+ <PluginGrid plugins={results} label={title} single={managing} showStatus={managing} handlers={handlers} />
+ {results.length === 0 && (
+ <div className="py-10 text-center text-sm text-muted-foreground">
+ <p>{translate(managing && !searching ? "plugins_view.installed_empty" : "plugins_view.no_hits")}</p>
+ {searching && (
+ <button type="button" onClick={leave} className="mt-3 underline underline-offset-4 hover:text-foreground">
+ {translate("plugins_view.show_all")}
+ </button>
+ )}
+ </div>
+ )}
+ </>
+ )}
+ </div>
+ );
+}
diff --git a/jarvis/ui/web/frontend/src/views/plugins/sections.test.ts b/jarvis/ui/web/frontend/src/views/plugins/sections.test.ts
new file mode 100644
index 0000000000..72b27d1a35
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/views/plugins/sections.test.ts
@@ -0,0 +1,136 @@
+import { describe, expect, it } from "vitest";
+
+import type { Plugin } from "@/views/PluginsView";
+import {
+ catalogSections,
+ categorySectionId,
+ COMMUNITY_SECTION,
+ homeRows,
+ homeSectionId,
+ isInstalled,
+ ownSections,
+ POPULAR_SECTION,
+ sectionCategory,
+ UPLOADED_SECTION,
+} from "@/views/plugins/sections";
+
+const plugin = (id: string, extra: Partial<Plugin> = {}): Plugin => ({
+ id,
+ name: id,
+ description: "d",
+ category: "Developer",
+ logoSlug: id,
+ authMode: "pat_paste",
+ authConfig: { mode: "pat_paste" },
+ status: "not_connected",
+ longevity: "permanent",
+ oauthClientConfigured: false,
+ fromMarketplace: false,
+ selfUploaded: false,
+ ...extra,
+});
+
+const ids = (plugins: Plugin[]) => plugins.map((p) => p.id);
+
+describe("catalogSections", () => {
+ it("leads with the featured plugins, then one section per category in the given order", () => {
+ const sections = catalogSections(
+ [
+ plugin("zeta", { category: "Messaging" }),
+ plugin("beta", { featured: true }),
+ plugin("alpha"),
+ ],
+ ["Messaging", "Developer"],
+ );
+ expect(sections.map((s) => s.id)).toEqual([
+ POPULAR_SECTION,
+ categorySectionId("Messaging"),
+ categorySectionId("Developer"),
+ ]);
+ expect(ids(sections[0].plugins)).toEqual(["beta"]);
+ // A featured plugin still belongs to its category; rows there run A-Z.
+ expect(ids(sections[2].plugins)).toEqual(["alpha", "beta"]);
+ });
+
+ it("has no Popular section when nothing is featured, and drops empty categories", () => {
+ const sections = catalogSections([plugin("alpha")], ["Messaging", "Developer"]);
+ expect(sections.map((s) => s.id)).toEqual([categorySectionId("Developer")]);
+ });
+
+ it("leaves what the owner added to the owner's scope", () => {
+ const sections = catalogSections(
+ [plugin("shipped"), plugin("mine", { selfUploaded: true }), plugin("theirs", { fromMarketplace: true })],
+ ["Developer"],
+ );
+ expect(ids(sections[0].plugins)).toEqual(["shipped"]);
+ });
+});
+
+describe("homeRows", () => {
+ it("shows a plugin once: what Popular lists is left out of its category below", () => {
+ const rows = homeRows(
+ catalogSections(
+ [plugin("alpha"), plugin("beta", { featured: true })],
+ ["Developer"],
+ ),
+ );
+ expect(rows.map((s) => [s.id, ids(s.plugins)])).toEqual([
+ [POPULAR_SECTION, ["beta"]],
+ [categorySectionId("Developer"), ["alpha"]],
+ ]);
+ });
+
+ it("caps a section at six rows and lets the overflow show in the section below", () => {
+ const featured = Array.from({ length: 8 }, (_, i) => plugin(`f${i}`, { featured: true }));
+ const rows = homeRows(catalogSections(featured, ["Developer"]));
+ expect(ids(rows[0].plugins)).toEqual(["f0", "f1", "f2", "f3", "f4", "f5"]);
+ // The two featured plugins Popular had no room for are not lost.
+ expect(ids(rows[1].plugins)).toEqual(["f6", "f7"]);
+ });
+
+ it("drops a section whose plugins are all shown above", () => {
+ const rows = homeRows(
+ catalogSections([plugin("only", { featured: true })], ["Developer"]),
+ );
+ expect(rows.map((s) => s.id)).toEqual([POPULAR_SECTION]);
+ });
+});
+
+describe("ownSections", () => {
+ it("splits own connectors from community installs and omits the empty half", () => {
+ const mine = plugin("mine", { selfUploaded: true });
+ const theirs = plugin("theirs", { fromMarketplace: true });
+ expect(ownSections([plugin("shipped"), theirs, mine]).map((s) => s.id)).toEqual([
+ UPLOADED_SECTION,
+ COMMUNITY_SECTION,
+ ]);
+ expect(ownSections([plugin("shipped"), theirs]).map((s) => s.id)).toEqual([COMMUNITY_SECTION]);
+ expect(ownSections([plugin("shipped")])).toEqual([]);
+ });
+});
+
+describe("section ids", () => {
+ it("round-trips a category and never mistakes a curated section for one", () => {
+ expect(sectionCategory(categorySectionId("Files & Photos"))).toBe("Files & Photos");
+ expect(sectionCategory(POPULAR_SECTION)).toBeNull();
+ // A category that happens to be called "popular" keeps its own section.
+ expect(categorySectionId("popular")).not.toBe(POPULAR_SECTION);
+ });
+
+ it("names the section a plugin is listed under", () => {
+ expect(homeSectionId(plugin("a", { category: "Messaging" }))).toBe(categorySectionId("Messaging"));
+ expect(homeSectionId(plugin("b", { selfUploaded: true }))).toBe(UPLOADED_SECTION);
+ expect(homeSectionId(plugin("c", { fromMarketplace: true }))).toBe(COMMUNITY_SECTION);
+ });
+});
+
+describe("isInstalled", () => {
+ it("keeps a broken connection and an unconnected owner-added plugin in the installed list", () => {
+ expect(isInstalled(plugin("a"))).toBe(false);
+ expect(isInstalled(plugin("b", { status: "connected" }))).toBe(true);
+ expect(isInstalled(plugin("c", { status: "needs_reauth" }))).toBe(true);
+ expect(isInstalled(plugin("d", { status: "error" }))).toBe(true);
+ expect(isInstalled(plugin("e", { fromMarketplace: true }))).toBe(true);
+ expect(isInstalled(plugin("f", { selfUploaded: true }))).toBe(true);
+ });
+});
diff --git a/jarvis/ui/web/frontend/src/views/plugins/sections.ts b/jarvis/ui/web/frontend/src/views/plugins/sections.ts
new file mode 100644
index 0000000000..cde3c14ac9
--- /dev/null
+++ b/jarvis/ui/web/frontend/src/views/plugins/sections.ts
@@ -0,0 +1,101 @@
+/**
+ * How the plugin directory is cut into sections.
+ *
+ * The home page never lists the whole catalog: it shows a handful of sections,
+ * each capped at `SECTION_LIMIT` rows and none repeating a plugin, and a
+ * section's heading opens its full list. Kept free of React so the grouping rules can be tested on their own.
+ */
+import type { Plugin } from "@/views/PluginsView";
+
+/** Rows a home section shows before its heading leads to the full list. */
+export const SECTION_LIMIT = 6;
+
+export const POPULAR_SECTION = "popular";
+export const UPLOADED_SECTION = "uploaded";
+export const COMMUNITY_SECTION = "community";
+const CATEGORY_PREFIX = "category:";
+
+/** "catalog" is what the app ships with; "yours" is everything the owner added. */
+export type PluginScope = "catalog" | "yours";
+
+export interface BrowseSection {
+ id: string;
+ plugins: Plugin[];
+}
+
+/** A plugin the owner brought in: by URL, as a folder, or from the community. */
+export const isOwnerAdded = (plugin: Plugin): boolean =>
+ plugin.fromMarketplace || plugin.selfUploaded;
+
+/** A plugin that belongs in the "Installed" list: connected once, or added by
+ * the owner. A revoked or errored one stays listed so it can be reconnected. */
+export const isInstalled = (plugin: Plugin): boolean =>
+ plugin.status === "connected" ||
+ plugin.status === "needs_reauth" ||
+ plugin.status === "error" ||
+ isOwnerAdded(plugin);
+
+export const categorySectionId = (category: string): string => `${CATEGORY_PREFIX}${category}`;
+
+/** The catalog category behind a section id, or null for a curated section. */
+export const sectionCategory = (sectionId: string): string | null =>
+ sectionId.startsWith(CATEGORY_PREFIX) ? sectionId.slice(CATEGORY_PREFIX.length) : null;
+
+/** The section a plugin is listed under, whatever page it was opened from. */
+export function homeSectionId(plugin: Plugin): string {
+ if (plugin.selfUploaded) return UPLOADED_SECTION;
+ if (plugin.fromMarketplace) return COMMUNITY_SECTION;
+ return categorySectionId(plugin.category);
+}
+
+const byName = (a: Plugin, b: Plugin): number =>
+ a.name.localeCompare(b.name, undefined, { sensitivity: "base" });
+
+/** Sections of the shipped catalog: the featured picks first, then one section
+ * per category in `categoryOrder`. Empty sections are dropped. */
+export function catalogSections(plugins: Plugin[], categoryOrder: string[]): BrowseSection[] {
+ const shipped = plugins.filter((plugin) => !isOwnerAdded(plugin));
+ const sections: BrowseSection[] = [];
+ const popular = shipped.filter((plugin) => plugin.featured);
+ if (popular.length > 0) sections.push({ id: POPULAR_SECTION, plugins: popular });
+ for (const category of categoryOrder) {
+ const members = shipped.filter((plugin) => plugin.category === category).sort(byName);
+ if (members.length > 0) sections.push({ id: categorySectionId(category), plugins: members });
+ }
+ return sections;
+}
+
+/** Sections of what the owner added: own connectors and folders, then
+ * community installs. */
+export function ownSections(plugins: Plugin[]): BrowseSection[] {
+ const sections: BrowseSection[] = [];
+ const uploaded = plugins.filter((plugin) => plugin.selfUploaded).sort(byName);
+ if (uploaded.length > 0) sections.push({ id: UPLOADED_SECTION, plugins: uploaded });
+ const community = plugins
+ .filter((plugin) => plugin.fromMarketplace && !plugin.selfUploaded)
+ .sort(byName);
+ if (community.length > 0) sections.push({ id: COMMUNITY_SECTION, plugins: community });
+ return sections;
+}
+
+/** What each section shows on the home page: at most `SECTION_LIMIT` rows, and
+ * a plugin a section above already shows is not repeated below — every plugin
+ * is on the page once. A section left with nothing to show is dropped; its
+ * own page still lists all of it. */
+export function homeRows(sections: BrowseSection[]): BrowseSection[] {
+ const shown = new Set<string>();
+ const rows: BrowseSection[] = [];
+ for (const section of sections) {
+ const plugins = section.plugins
+ .filter((plugin) => !shown.has(plugin.id))
+ .slice(0, SECTION_LIMIT);
+ for (const plugin of plugins) shown.add(plugin.id);
+ if (plugins.length > 0) rows.push({ id: section.id, plugins });
+ }
+ return rows;
+}
+
+/** Every section of both scopes, for resolving an open section by its id. */
+export function allSections(plugins: Plugin[], categoryOrder: string[]): BrowseSection[] {
+ return [...catalogSections(plugins, categoryOrder), ...ownSections(plugins)];
+}