дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-03 16:51:16 +02:00
Agent plugin marketplace entries and the plugin preview header showed text only, while MCP Connections › Browse shows server icons. Plugin icons are now resolved without extra network requests: explicit manifest or marketplace icon fields (https URLs validated, repo-relative images as raw.githubusercontent.com URLs or small data: URIs for local plugins), then conventional icon files in the fetched tree or local folder, then the GitHub owner's avatar. A shared AgentRemoteIcon tile renders them in both lists, theme-aware, with a fallback for monochrome icons. Co-authored-by: dengliu <[email protected]>
243 рядки
9.4 KiB
TypeScript
243 рядки
9.4 KiB
TypeScript
import type { AgentMarketplaceBrowseResult, AgentPluginCatalog, AgentPluginState } from "../src/bindings";
|
|
import { expect, stubDesktop, test } from "./fixtures";
|
|
|
|
const svgDataIcon = (bg: string, label: string) =>
|
|
`data:image/svg+xml,${encodeURIComponent(
|
|
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect width="32" height="32" rx="6" fill="${bg}"/><text x="16" y="21" text-anchor="middle" fill="#fff" font-family="system-ui,sans-serif" font-size="13" font-weight="700">${label}</text></svg>`,
|
|
)}`;
|
|
|
|
const makePlugin = (name: string, consentRequired: boolean): AgentPluginState => ({
|
|
plugin: {
|
|
id: name,
|
|
name,
|
|
displayName: name,
|
|
version: "26.1021.31345",
|
|
description: "A plugin with a long description explaining what it can do for the agent in this workspace.",
|
|
marketplace: "context-engineering-marketplace-with-a-long-name",
|
|
source: "claudeUser",
|
|
scope: "user",
|
|
formats: ["claude", "codex", "copilot"],
|
|
rootPath: "/Users/dev/.claude/plugins/cache/context-engineering-marketplace/agent-plugin",
|
|
defaultEnabled: false,
|
|
approxTokens: 2550,
|
|
capabilities: {
|
|
skillCount: 17,
|
|
mcpCount: 1,
|
|
ruleCount: 2,
|
|
subagentCount: 3,
|
|
commandCount: 0,
|
|
hookFiles: consentRequired ? ["hooks/a-very-long-lifecycle-hook-file-name.json"] : [],
|
|
requiresConsent: consentRequired,
|
|
},
|
|
valid: true,
|
|
},
|
|
enabled: !consentRequired,
|
|
origin: consentRequired ? "consent" : "none",
|
|
consentRequired,
|
|
});
|
|
|
|
test("agent plugin metadata stays clear of enable and review controls at narrow widths", async ({
|
|
workbench: page,
|
|
}) => {
|
|
const longName = "Context Engineering with an exceptionally long plugin display name";
|
|
const catalog: AgentPluginCatalog = {
|
|
plugins: [makePlugin(longName, true), makePlugin("Frontend Design", false)],
|
|
marketplaces: [
|
|
{
|
|
id: "official",
|
|
name: "claude-plugins-official",
|
|
source: "example/official",
|
|
scope: "user",
|
|
discovered: true,
|
|
},
|
|
{
|
|
id: "community",
|
|
name: "context-engineering-marketplace-with-a-long-name",
|
|
source: "example/community",
|
|
scope: "user",
|
|
discovered: true,
|
|
},
|
|
],
|
|
projectedSkills: 17,
|
|
projectedMcpServers: 1,
|
|
projectedRules: 2,
|
|
};
|
|
await stubDesktop(page);
|
|
await page.evaluate(async (catalog) => {
|
|
window.__ipc.handlers.agent_plugins_list = () => structuredClone(catalog);
|
|
window.__ipc.handlers.window_open_settings = () => {
|
|
throw { kind: "unavailable", message: "separate settings window disabled in browser test", detail: null };
|
|
};
|
|
const actionsModule = "/src/platform/actions.ts";
|
|
const { executeAction } = await import(/* @vite-ignore */ actionsModule);
|
|
await executeAction("file.settings", "agents.plugins");
|
|
}, catalog);
|
|
const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
|
|
await expect(dialog).toBeVisible();
|
|
const group = dialog.getByRole("region", { name: "Claude Code · User" });
|
|
const rows = group.getByRole("listitem");
|
|
await expect(rows).toHaveCount(2);
|
|
const review = rows.first().getByRole("button", { name: "Review & Enable…" });
|
|
await expect(review).toBeVisible();
|
|
for (const width of [1120, 780, 580, 520]) {
|
|
await page.setViewportSize({ width, height: 760 });
|
|
await expect(async () => {
|
|
const fit = await rows.evaluateAll((items) =>
|
|
items.every((row) => {
|
|
const expand = row.querySelector("button[aria-expanded]")!;
|
|
const action = expand.nextElementSibling!;
|
|
const bounds = row.getBoundingClientRect();
|
|
const a = expand.getBoundingClientRect();
|
|
const b = action.getBoundingClientRect();
|
|
const title = expand.querySelector("[title]")!.getBoundingClientRect();
|
|
return (
|
|
title.width > 0 &&
|
|
a.right <= bounds.right + 1 &&
|
|
b.right <= bounds.right + 1 &&
|
|
(a.right <= b.left + 1 || a.bottom <= b.top + 1) &&
|
|
expand.scrollWidth <= expand.clientWidth + 1
|
|
);
|
|
}),
|
|
);
|
|
expect(fit).toBe(true);
|
|
}).toPass();
|
|
if (process.env.SETTINGS_EVIDENCE)
|
|
await dialog.screenshot({
|
|
path: `${process.env.SETTINGS_EVIDENCE}/plugins-${width}.png`,
|
|
animations: "disabled",
|
|
});
|
|
}
|
|
|
|
await rows
|
|
.first()
|
|
.getByRole("button", { name: new RegExp(longName) })
|
|
.click();
|
|
await expect(rows.first().getByText(catalog.plugins[0]!.plugin.marketplace!)).toBeVisible();
|
|
await expect(rows.first().getByText(".claude-plugin · .codex-plugin · .plugin")).toBeVisible();
|
|
await expect(rows.first().getByText(catalog.plugins[0]!.plugin.description, { exact: true })).toBeVisible();
|
|
if (process.env.SETTINGS_EVIDENCE) {
|
|
await page.setViewportSize({ width: 1120, height: 760 });
|
|
await page.evaluate(async () => {
|
|
const themePath = "/src/workbench/theme.ts";
|
|
const { setTheme } = await import(/* @vite-ignore */ themePath);
|
|
await setTheme("dark");
|
|
});
|
|
await dialog.screenshot({
|
|
path: `${process.env.SETTINGS_EVIDENCE}/plugins-expanded-dark.png`,
|
|
animations: "disabled",
|
|
});
|
|
}
|
|
await review.click();
|
|
await expect(page.getByRole("dialog", { name: /Approve Plugin Capabilities/ })).toBeVisible();
|
|
});
|
|
|
|
test("displays plugin icons when browsing a marketplace in Install Agent Plugin", async ({ workbench: page }) => {
|
|
const catalog: AgentPluginCatalog = {
|
|
plugins: [],
|
|
marketplaces: [
|
|
{
|
|
id: "anthropics/claude-plugins-official",
|
|
name: "claude-plugins-official",
|
|
source: "anthropics/claude-plugins-official",
|
|
scope: "user",
|
|
discovered: false,
|
|
},
|
|
],
|
|
projectedSkills: 0,
|
|
projectedMcpServers: 0,
|
|
projectedRules: 0,
|
|
};
|
|
const browseResult: AgentMarketplaceBrowseResult = {
|
|
source: "anthropics/claude-plugins-official",
|
|
marketplaceName: "claude-plugins-official",
|
|
owner: "anthropics",
|
|
repo: "claude-plugins-official",
|
|
gitRef: "main",
|
|
treeSha: "1111111111111111111111111111111111111111",
|
|
candidates: [
|
|
{
|
|
name: "42crunch-api-security-testing",
|
|
displayName: "42crunch-api-security-testing",
|
|
version: "1.5.5",
|
|
description: "Automate API security directly in Claude Code with 42Crunch.",
|
|
marketplace: "claude-plugins-official",
|
|
iconUrl: svgDataIcon("#1B73E8", "42"),
|
|
iconDarkUrl: null,
|
|
sourceSpec: "42Crunch-AI/claude-plugins#v1.5.5",
|
|
subpath: "plugins/api-security-testing",
|
|
alreadyInstalledUser: false,
|
|
alreadyInstalledWorkspace: false,
|
|
},
|
|
{
|
|
name: "adobe-for-creativity",
|
|
displayName: "adobe-for-creativity",
|
|
version: "3.4.0",
|
|
description: "Harness Adobe's creative AI-powered tools to edit images and automate design workflows.",
|
|
marketplace: "claude-plugins-official",
|
|
iconUrl: svgDataIcon("#FA0F00", "Ad"),
|
|
iconDarkUrl: null,
|
|
sourceSpec: "adobe/skills#main",
|
|
subpath: "plugins/creative-cloud/adobe-for-creativity",
|
|
alreadyInstalledUser: false,
|
|
alreadyInstalledWorkspace: false,
|
|
},
|
|
{
|
|
name: "local-fallback",
|
|
displayName: "local-fallback",
|
|
version: "1.0.0",
|
|
description: "Local plugin without a custom icon shows the monochrome fallback glyph.",
|
|
marketplace: "claude-plugins-official",
|
|
iconUrl: null,
|
|
iconDarkUrl: null,
|
|
sourceSpec: "/tmp/local-fallback",
|
|
subpath: "",
|
|
alreadyInstalledUser: false,
|
|
alreadyInstalledWorkspace: false,
|
|
},
|
|
],
|
|
};
|
|
|
|
await page.setViewportSize({ width: 1120, height: 760 });
|
|
await stubDesktop(page);
|
|
await page.evaluate(
|
|
async ({ catalog, browseResult }) => {
|
|
window.__ipc.handlers.agent_plugins_list = () => structuredClone(catalog);
|
|
window.__ipc.handlers.agent_plugins_browse_marketplace = () => structuredClone(browseResult);
|
|
window.__ipc.handlers.window_open_settings = () => {
|
|
throw { kind: "unavailable", message: "separate settings window disabled in browser test", detail: null };
|
|
};
|
|
const actionsModule = "/src/platform/actions.ts";
|
|
const { executeAction } = await import(/* @vite-ignore */ actionsModule);
|
|
await executeAction("file.settings", "agents.plugins");
|
|
},
|
|
{ catalog, browseResult },
|
|
);
|
|
|
|
const settingsDialog = page.getByRole("dialog", { name: "Settings", exact: true });
|
|
await expect(settingsDialog).toBeVisible();
|
|
await settingsDialog.getByRole("button", { name: "Browse", exact: true }).first().click();
|
|
|
|
const installDlg = page.getByRole("dialog", { name: "Install Agent Plugin" });
|
|
await expect(installDlg).toBeVisible();
|
|
await expect(installDlg.getByText("42crunch-api-security-testing")).toBeVisible();
|
|
await expect(installDlg.getByText("adobe-for-creativity")).toBeVisible();
|
|
await expect(installDlg.getByText("local-fallback")).toBeVisible();
|
|
await expect(installDlg.locator("img")).toHaveCount(2);
|
|
|
|
if (process.env.SETTINGS_EVIDENCE) {
|
|
await installDlg.screenshot({
|
|
path: `${process.env.SETTINGS_EVIDENCE}/plugin-browse-icons-light.png`,
|
|
animations: "disabled",
|
|
});
|
|
await page.evaluate(async () => {
|
|
const themePath = "/src/workbench/theme.ts";
|
|
const { setTheme } = await import(/* @vite-ignore */ themePath);
|
|
await setTheme("dark");
|
|
});
|
|
await installDlg.screenshot({
|
|
path: `${process.env.SETTINGS_EVIDENCE}/plugin-browse-icons-dark.png`,
|
|
animations: "disabled",
|
|
});
|
|
}
|
|
});
|