fix(agents): keep plugin details clear of row controls

Цей коміт міститься в:
l0ng-ai committed 2026-12-02 18:05:58 +08:00
1 джерело 9abe3d7e3c
коміт c0e82f7e2c
3 files changed
+361 -78

No files matched your search

+127
Переглянути файл
@@ -0,0 +1,127 @@
import type { AgentPluginCatalog, AgentPluginState } from "../src/bindings";
import { expect, stubDesktop, test } from "./fixtures";
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();
});
+129 -17
Переглянути файл
@@ -1,17 +1,49 @@
/* Keep technical metadata from competing with the row's name and action. */
.row {
min-height: var(--h-row);
padding-block: 2px;
padding: var(--space-1-5) var(--space-2);
}
.expand {
align-items: flex-start;
min-width: 0;
}
.expand > svg {
margin-top: var(--space-0-5);
}
.titleRow {
display: flex;
align-items: baseline;
gap: var(--space-1-5);
min-width: 0;
}
.entryTitle {
flex-shrink: 0;
min-width: 0;
color: var(--fg-strong);
font-weight: 500;
overflow-wrap: anywhere;
}
.titleRow .entryTitle {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.version {
flex: none;
max-width: 40%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
color: var(--fg-muted);
font-size: var(--fs-small);
}
.subtitle {
flex: 1;
min-width: 0;
color: var(--fg-muted);
font-size: var(--fs-small);
@@ -20,8 +52,81 @@
white-space: nowrap;
}
.scopeSelect {
min-width: 120px;
.statusRow {
display: flex;
flex-wrap: wrap;
gap: var(--space-0-5) var(--space-2);
color: var(--warning);
font-size: var(--fs-small);
overflow-wrap: anywhere;
}
.nativeHint {
display: flex;
align-items: center;
gap: var(--space-1);
}
.nativeHint > svg,
.nativeHint > img {
flex-shrink: 0;
}
.description {
color: var(--fg);
line-height: 1.45;
white-space: pre-wrap;
overflow-wrap: anywhere;
}
.groupTitle {
flex-shrink: 0;
max-width: calc(100% - 48px);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.groupPath {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.rowControls {
justify-content: flex-end;
}
@container settings-content (max-width: 360px) {
.reviewRow {
flex-wrap: wrap;
}
.reviewRow .expand {
flex-basis: 100%;
}
.version {
display: none;
}
.groupToggle {
flex-wrap: wrap;
}
.groupPath {
flex-basis: 100%;
padding-left: var(--space-4);
}
.searchRow {
flex-wrap: wrap;
}
.searchRow > :first-child {
flex-basis: 100%;
}
}
.controls {
@@ -36,7 +141,7 @@
display: flex;
flex-direction: column;
gap: var(--space-2);
padding: 10px 12px;
padding: var(--space-2) var(--space-3);
border-radius: var(--radius-control);
background: var(--bg-elev);
box-shadow: inset 0 0 0 1px var(--border);
@@ -54,7 +159,8 @@
display: flex;
align-items: center;
flex-wrap: wrap;
gap: var(--space-1-5);
gap: var(--space-1) var(--space-3);
min-width: 0;
}
.summaryTitle {
@@ -66,12 +172,15 @@
display: inline-flex;
align-items: center;
gap: var(--space-1);
padding: 2px 8px;
border-radius: var(--radius-small);
border: 1px solid var(--border);
background: var(--bg-app);
padding: 0;
border: 0;
background: none;
color: var(--link);
font-size: var(--fs-tiny);
font-size: var(--fs-small);
text-align: left;
min-width: 0;
max-width: 100%;
overflow-wrap: anywhere;
cursor: pointer;
}
@@ -98,14 +207,17 @@
display: inline-flex;
align-items: center;
gap: var(--space-1);
padding: 2px 7px;
border-radius: var(--radius-small);
background: var(--bg-app);
box-shadow: inset 0 0 0 1px var(--border);
font-size: var(--fs-tiny);
min-width: 0;
max-width: 100%;
font-size: var(--fs-small);
color: var(--fg-secondary);
}
.marketplaceChip > span:not(:first-child) {
overflow-wrap: anywhere;
min-width: 0;
}
.dialogBody {
display: flex;
flex-direction: column;
+105 -61
Переглянути файл
@@ -213,38 +213,38 @@ export function AgentPluginsPage({ backend = defaultPluginsBackend }: { backend?
<div className={styles.summaryBox}>
<div className={styles.summaryHeader}>
<div className={styles.summaryPills}>
<span className={styles.summaryTitle}>
<T>Active Bundle Projection</T>
</span>
<button
type="button"
className={styles.projectionLink}
onClick={() => void executeAction("file.settings", SKILLS_PAGE)}
>
{formatMessage(tx("{count} skills → Skills"), { count: catalog.projectedSkills })}
</button>
<button
type="button"
className={styles.projectionLink}
onClick={() => void executeAction("file.settings", MCP_PAGE)}
>
{formatMessage(tx("{count} MCP servers → MCP Connections"), { count: catalog.projectedMcpServers })}
</button>
<button
type="button"
className={styles.projectionLink}
onClick={() => void executeAction("file.settings", MEMORY_PAGE)}
>
{formatMessage(tx("{count} rules → Memory"), { count: catalog.projectedRules })}
</button>
</div>
<span className={styles.summaryTitle}>
<T>Active Bundle Projection</T>
</span>
{backend.addMarketplace && (
<Button size="small" onClick={() => setMarketplacesOpen(true)}>
{formatMessage(tx("Marketplaces ({count})…"), { count: catalog.marketplaces.length })}
</Button>
)}
</div>
<div className={styles.summaryPills}>
<button
type="button"
className={styles.projectionLink}
onClick={() => void executeAction("file.settings", SKILLS_PAGE)}
>
{formatMessage(tx("{count} skills → Skills"), { count: catalog.projectedSkills })}
</button>
<button
type="button"
className={styles.projectionLink}
onClick={() => void executeAction("file.settings", MCP_PAGE)}
>
{formatMessage(tx("{count} MCP servers → MCP Connections"), { count: catalog.projectedMcpServers })}
</button>
<button
type="button"
className={styles.projectionLink}
onClick={() => void executeAction("file.settings", MEMORY_PAGE)}
>
{formatMessage(tx("{count} rules → Memory"), { count: catalog.projectedRules })}
</button>
</div>
{catalog.marketplaces.length > 0 && (
<div className={styles.marketplaceRow}>
@@ -289,7 +289,7 @@ export function AgentPluginsPage({ backend = defaultPluginsBackend }: { backend?
/>
</div>
<div className={page.searchRow}>
<div className={clsx(page.searchRow, styles.searchRow)}>
<SearchField
className={page.search}
value={query}
@@ -322,14 +322,16 @@ export function AgentPluginsPage({ backend = defaultPluginsBackend }: { backend?
<div className={page.sectionBar}>
<button
type="button"
className={page.sectionToggle}
className={clsx(page.sectionToggle, styles.groupToggle)}
aria-expanded={!isCollapsed}
onClick={() => setCollapsed((prev) => ({ ...prev, [key]: !prev[key] }))}
>
<Icon name={isCollapsed ? "chevron-right" : "chevron-down"} size={14} className={page.chevron} />
<span className={page.sectionTitle}>{title}</span>
<span className={clsx(page.sectionTitle, styles.groupTitle)}>{title}</span>
<span className={page.badge}>{items.length}</span>
<span className={page.sectionHint}>{pluginGroupPath(source, scope)}</span>
<span className={clsx(page.sectionHint, styles.groupPath)} title={pluginGroupPath(source, scope)}>
{pluginGroupPath(source, scope)}
</span>
</button>
</div>
@@ -438,41 +440,55 @@ function PluginCard({
const { plugin } = state;
const summary = componentSummary(state, tx);
const group = PLUGIN_SOURCE_GROUPS[plugin.source];
const details = [summary, plugin.approxTokens > 0 ? `~${plugin.approxTokens}t` : ""].filter(Boolean).join(" · ");
const subtitle = [details, plugin.description].filter(Boolean).join(" · ");
const needsReview = state.consentRequired && !state.enabled;
return (
<div role="listitem" className={page.card}>
<div className={clsx(page.cardHeader, styles.row)}>
<button type="button" className={page.cardExpandBtn} aria-expanded={isExpanded} onClick={onToggleExpand}>
<div className={clsx(page.cardHeader, styles.row, needsReview && styles.reviewRow)}>
<button
type="button"
className={clsx(page.cardExpandBtn, styles.expand)}
aria-expanded={isExpanded}
onClick={onToggleExpand}
>
<Icon name={isExpanded ? "chevron-down" : "chevron-right"} size={13} className={page.chevron} />
<span className={styles.entryTitle}>{plugin.displayName}</span>
{plugin.version && <span className={page.tag}>v{plugin.version}</span>}
{plugin.marketplace && <span className={page.tag}>{plugin.marketplace}</span>}
{plugin.formats.map((f) => (
<span key={f} className={page.tag}>
{pluginFormatLabel(f)}
<span className={page.cardMain}>
<span className={styles.titleRow}>
<span className={styles.entryTitle} title={plugin.displayName}>
{plugin.displayName}
</span>
{plugin.version && (
<span className={styles.version} title={plugin.version}>
v{plugin.version}
</span>
)}
</span>
))}
{summary && <span className={page.tag}>{summary}</span>}
{plugin.approxTokens > 0 && <span className={page.tag}>~{plugin.approxTokens}t</span>}
{plugin.description && (
<span className={styles.subtitle} title={plugin.description}>
{plugin.description}
</span>
)}
{state.origin === "trust" && (
<span className={clsx(page.tag, page.tagWarning)}>
<T>Untrusted workspace</T>
</span>
)}
{state.consentRequired && (
<span className={clsx(page.tag, page.tagWarning)}>
<T>Approval required</T>
</span>
)}
{subtitle && (
<span className={styles.subtitle} title={subtitle}>
{subtitle}
</span>
)}
{(state.origin === "trust" || state.consentRequired) && (
<span className={styles.statusRow}>
{state.origin === "trust" && (
<span>
<T>Untrusted workspace</T>
</span>
)}
{state.consentRequired && (
<span>
<T>Approval required</T>
</span>
)}
</span>
)}
</span>
</button>
<div className={styles.controls}>
{state.consentRequired && !state.enabled ? (
<div className={clsx(styles.controls, styles.rowControls)}>
{needsReview ? (
<Button
size="small"
disabled={busy || (state.origin === "trust" && !hasTrustedProject)}
@@ -493,7 +509,34 @@ function PluginCard({
{isExpanded && (
<div className={page.cardDrawer}>
{plugin.description && <span className={styles.description}>{plugin.description}</span>}
{details && <span className={styles.hint}>{details}</span>}
<div className={page.metaGrid}>
{plugin.version && (
<>
<span className={page.metaLabel}>
<T>Version</T>
</span>
<span className={page.metaValue}>{plugin.version}</span>
</>
)}
{plugin.marketplace && (
<>
<span className={page.metaLabel}>
<T>Marketplace</T>
</span>
<span className={page.metaValue}>{plugin.marketplace}</span>
</>
)}
{plugin.formats.length > 0 && (
<>
<span className={page.metaLabel}>
<T>Format</T>
</span>
<span className={page.metaValue}>{plugin.formats.map(pluginFormatLabel).join(" · ")}</span>
</>
)}
<span className={page.metaLabel}>
<T>Scope</T>
</span>
@@ -558,7 +601,7 @@ function PluginCard({
</button>
)}
{(plugin.capabilities.hookFiles?.length ?? 0) > 0 && (
<span className={page.tag}>{(plugin.capabilities.hookFiles ?? []).join(", ")}</span>
<span className={page.metaValue}>{(plugin.capabilities.hookFiles ?? []).join(", ")}</span>
)}
</span>
@@ -573,8 +616,9 @@ function PluginCard({
</div>
{group.agent && (
<span className={styles.hint}>
<Icon name={providerIcon(group.agent)} size={12} /> {tx(group.label)} reads this bundle natively.
<span className={clsx(styles.hint, styles.nativeHint)}>
<Icon name={providerIcon(group.agent)} size={12} />
<span>{tx(group.label)} reads this bundle natively.</span>
</span>
)}