Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 修复插件与 Skill 页面窄宽布局 (#417)
nanacobf2eba1d5803
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/forge.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/forge.test.tsindex 2c4992fe86..dd62574259 100644--- a/apps/desktop/src/main/cindy-brain/__tests__/forge.test.ts+++ b/apps/desktop/src/main/cindy-brain/__tests__/forge.test.ts@@ -437,6 +437,9 @@ describe('FORGE_GUIDE', () => {'/preview/','settingsHtml','settingsHeight',+ 'box-sizing:border-box',+ 'min-width:0',+ 'max-width:100%',"fetch('/kv')",// setup 就绪声明(2026-07-21):使用前置检查——作者声明需求,主机统一检查。'setup 就绪声明',diff --git a/apps/desktop/src/main/cindy-brain/forge.ts b/apps/desktop/src/main/cindy-brain/forge.tsindex 145d0975f9..955e535012 100644--- a/apps/desktop/src/main/cindy-brain/forge.ts+++ b/apps/desktop/src/main/cindy-brain/forge.ts@@ -1785,11 +1785,14 @@ tool-call 内轮询时记得定期发 tool-progress 心跳续命(见 §4"长任自动重灌;设置区基线背景 = 宿主设置卡片色(与相邻卡片无缝),别再自己铺整页底色。高度缺省自适应:主机在页面就绪后量内容高度,内容动态增减(展开区、追加列表)时会自动跟随重量(内部 ResizeObserver 通知宿主再量,你无需做-任何事)。自适应模式下主机会把 html/body 高度钉为 auto 并裁掉横向溢出——-布局按"内容自然撑高"来写,别用 height:100%/100vh 撑满视口(高度会追不准),-也别做横向滚动;纵向滚动条只在内容超 800px 上限时出现,上限内高度始终贴合-内容。只有想把区域高度完全钉死时才声明 settingsHeight(此时主机不干预布局,-超出部分内部滚动)。意识沉睡时设置区不渲染(显示沉睡提示),唤醒后可用。+任何事)。自适应模式下主机会把 html/body 高度钉为 auto、宽度收在设置卡片内+并裁掉横向溢出;同时统一给页面元素应用 box-sizing:border-box、min-width:0+和 max-width:100%,让固定宽控件也能在窄卡片中收缩。布局按"内容自然撑高 ++容器宽度自适应"来写,别用 height:100%/100vh 撑满视口(高度会追不准),也别+依赖固定宽度、横向滚动或自定义 content-box 尺寸;纵向滚动条只在内容超 800px+上限时出现,上限内高度始终贴合内容。只有想把区域高度完全钉死时才声明+settingsHeight(此时主机不注入上述响应式规则,超出部分由你的页面内部滚动)。+意识沉睡时设置区不渲染(显示沉睡提示),唤醒后可用。**外链(前往控制台)**:设置区/面板里可以放 \`<a href="https://…">\` 链接,但只有 **href 与身份卡 \`network.secrets[].url\` 声明逐字一致**的地址会被主机放行diff --git a/apps/desktop/src/renderer/cindy-brain/CindyCapabilityPrefs.tsx b/apps/desktop/src/renderer/cindy-brain/CindyCapabilityPrefs.tsxindex 6f05f57ba1..b25ef51619 100644--- a/apps/desktop/src/renderer/cindy-brain/CindyCapabilityPrefs.tsx+++ b/apps/desktop/src/renderer/cindy-brain/CindyCapabilityPrefs.tsx@@ -56,7 +56,7 @@ export function CindyCapabilityPrefs({return (<divclassName={cn(- 'flex flex-col gap-3 rounded-xl border px-5 py-4',+ 'cindy-capability-prefs min-w-0 max-w-full flex flex-col gap-3 rounded-xl border px-5 py-4',appearance === 'plugin'? 'border-[color-mix(in_srgb,var(--border-default)_72%,transparent)] bg-[color-mix(in_srgb,var(--surface-elevated)_82%,var(--surface))]': 'border-[var(--settings-theme-card-border)] bg-[var(--settings-theme-card-bg)]',@@ -84,10 +84,13 @@ export function CindyCapabilityPrefs({{capabilities.map((capability) => {const kind = capability.startsWith('video.') ? prefs.video : prefs.image;return (- <div key={capability} className="flex items-center justify-between gap-4">+ <div+ key={capability}+ className="cindy-capability-row flex min-w-0 items-center justify-between gap-4"+ ><spanclassName={cn(- 'text-[var(--text-secondary)]',+ 'min-w-0 text-[var(--text-secondary)]',appearance === 'plugin' ? 'text-13 leading-5' : 'text-12',)}>@@ -102,7 +105,7 @@ export function CindyCapabilityPrefs({onChange={(event) => void handleChange(capability, event.target.value)}aria-label={t(`settings.ghosts.detail.cindyPrefs.cap.${capability}`)}className={cn(- 'h-8 w-[300px] shrink-0 appearance-none rounded-full border border-[var(--settings-input-border)] bg-[var(--settings-input-bg)] py-0 pl-3 pr-8 text-[var(--settings-input-text)] outline-none focus:ring-2 focus:ring-[var(--focus-ring-soft)]',+ 'cindy-capability-select h-8 w-[300px] max-w-[60%] min-w-0 shrink appearance-none rounded-full border border-[var(--settings-input-border)] bg-[var(--settings-input-bg)] py-0 pl-3 pr-8 text-[var(--settings-input-text)] outline-none focus:ring-2 focus:ring-[var(--focus-ring-soft)]',appearance === 'plugin' ? 'text-13 leading-5' : 'text-12',)}>diff --git a/apps/desktop/src/renderer/cindy-brain/GhostSettingsWebview.tsx b/apps/desktop/src/renderer/cindy-brain/GhostSettingsWebview.tsxindex ecbeef30fd..0a3c26b942 100644--- a/apps/desktop/src/renderer/cindy-brain/GhostSettingsWebview.tsx+++ b/apps/desktop/src/renderer/cindy-brain/GhostSettingsWebview.tsx@@ -12,6 +12,7 @@ import {observeHostTheme,} from './ghostPanelTheme';import {+ GHOST_SETTINGS_LAYOUT_REVISION,loadGhostSettingsSnapshot,saveGhostSettingsSnapshot,snapshotMatchesContext,@@ -29,8 +30,8 @@ import {** 高度:缺省**随内容自适应**——dom-ready 后宿主 executeJavaScript 量 guest* 的 body 内容高(不受信数值,clamp 48–800 收口;量到前占位 160),延迟补量- * 两次兜后到的布局/字体;声明了 settingsHeight 则固定该值(作者对动态内容- * 的显式选择)。+ * 两次兜后到的布局/字体;声明了 settingsHeight 则固定该值,并保持作者布局+ * 完全不受宿主响应式规则干预。** 视觉连续性(规则 7):guest 首帧不可能与宿主同帧(独立渲染进程,* attach→装载→绘制天然晚数帧)——追不平就贴快照:渲染稳定后把 guest 画面@@ -49,17 +50,21 @@ const AUTO_HEIGHT_MIN = 48;const AUTO_HEIGHT_MAX = 800;/**- * 自适应模式的结构 CSS(dom-ready 注入,id 守卫幂等):+ * 自适应高度设置 guest 的结构 CSS(dom-ready 注入,id 守卫幂等):+ * - 把文档和子元素宽度收在宿主卡片内,让插件作者的固定宽控件在极窄内容区+ * 也能收缩,而不是顶出卡片;* - html/body 高度钉 auto:意识页写 height:100%/100vh 会让 body 高恒等于* 当前视口高,量出来的值永远追着容器现值走(只涨不缩的棘轮,内容变矮后* 底部空白收不回去),钉 auto 后 body 高回归内容本身;* - overflow-x 裁掉:设置卡片里横滚动条永远不是想要的,且它会吃掉十几像素* 视口高、连带勾出纵滚动条(量高不知道横滚动条的存在)。* 纵向滚动开关不在这里——由量高脚本按"内容是否超 clamp 上限"逐次决定。- * 仅自适应模式注入;settingsHeight 固定高度是作者显式选择,布局不干预。+ * 固定高度模式不注入这些规则,遵守 settingsHeight 的作者布局契约。*/-const AUTO_HEIGHT_GUEST_CSS =- 'html,body{height:auto !important;min-height:0 !important;}html{overflow-x:hidden;}';+const RESPONSIVE_GUEST_CSS =+ 'html,body{width:100%!important;max-width:100%!important;overflow-x:hidden!important;}*,*::before,*::after{box-sizing:border-box!important;min-width:0!important;max-width:100%!important;}';+const RESPONSIVE_STYLE_SCRIPT = `(function(){if(document.getElementById('__xdt_settings_w'))return;var s=document.createElement('style');s.id='__xdt_settings_w';s.textContent=${JSON.stringify(RESPONSIVE_GUEST_CSS)};(document.head||document.documentElement).appendChild(s)})()`;+const AUTO_HEIGHT_GUEST_CSS = 'html,body{height:auto !important;min-height:0 !important;}';const AUTO_HEIGHT_STYLE_SCRIPT = `(function(){if(document.getElementById('__xdt_auto_h'))return;var s=document.createElement('style');s.id='__xdt_auto_h';s.textContent=${JSON.stringify(AUTO_HEIGHT_GUEST_CSS)};(document.head||document.documentElement).appendChild(s)})()`;/**@@ -264,6 +269,7 @@ function SettingsWebviewBody({dpr: window.devicePixelRatio,themeCss: buildSettingsThemeCss(),version: manifest.version,+ layoutRevision: GHOST_SETTINGS_LAYOUT_REVISION,capturedAt: Date.now(),});} catch {@@ -335,14 +341,18 @@ function SettingsWebviewBody({const onDomReady = () => {injector.onDomReady();if (fixedHeight !== undefined) {- // 固定高度不量高,补一次空执行,只为把淡入排到主题 CSS 之后。- void webview.executeJavaScript('0').then(reveal, reveal);+ // settingsHeight 契约要求宿主不干预 guest 布局。只用空脚本往返作为+ // 主题 insertCSS 后的有序揭示屏障,不注入宽度/overflow 规则。+ void webview.executeJavaScript('void 0').then(reveal, reveal);return;}+ const prepareResponsiveLayout = webview+ .executeJavaScript(RESPONSIVE_STYLE_SCRIPT)+ .catch(() => {});// 结构 CSS 先落地再量(html/body 钉 auto 会改变 body 高,顺序反了首量// 就是错值);脚本自带 id 守卫,dom-ready 因 guest 内跳转重入时幂等。- void webview- .executeJavaScript(AUTO_HEIGHT_STYLE_SCRIPT)+ void prepareResponsiveLayout+ .then(() => webview.executeJavaScript(AUTO_HEIGHT_STYLE_SCRIPT)).catch(() => {}).then(measure);measureTimers.push(setTimeout(measure, 250), setTimeout(measure, 1000));@@ -411,7 +421,10 @@ function SettingsWebviewBody({<divref={hostRef}data-ghost-webview- className="relative flex"+ className={cn(+ 'relative flex w-full min-w-0 max-w-full',+ fixedHeight === undefined && 'overflow-hidden',+ )}style={{ height: fixedHeight ?? autoHeight }}>{/* 首帧快照(上层盖住透明装载期的 webview;pointer-events 穿透,撤图前@@ -447,7 +460,7 @@ export function GhostSettingsWebview({return (<divclassName={cn(- 'flex flex-col gap-3 rounded-xl border px-5 py-4',+ 'flex min-w-0 max-w-full flex-col gap-3 rounded-xl border px-5 py-4',appearance === 'plugin'? 'border-[color-mix(in_srgb,var(--border-default)_72%,transparent)] bg-[color-mix(in_srgb,var(--surface-elevated)_82%,var(--surface))]': 'border-[var(--settings-theme-card-border)] bg-[var(--settings-theme-card-bg)]',diff --git a/apps/desktop/src/renderer/cindy-brain/__tests__/GhostSettingsWebview.test.tsx b/apps/desktop/src/renderer/cindy-brain/__tests__/GhostSettingsWebview.test.tsxnew file mode 100644index 0000000000..511ce5b900--- /dev/null+++ b/apps/desktop/src/renderer/cindy-brain/__tests__/GhostSettingsWebview.test.tsx@@ -0,0 +1,93 @@+/**+ * Regression coverage for Plugin settings guest layout ownership.+ * [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md+ * @vitest-environment jsdom+ */++import { render, waitFor } from '@testing-library/react';+import { afterEach, describe, expect, it, vi } from 'vitest';++import type { InstalledGhost } from '../../../shared/ghost';+import { GhostSettingsWebview } from '../GhostSettingsWebview';++vi.mock('react-i18next', () => ({+ useTranslation: () => ({ t: (key: string) => key }),+}));++afterEach(() => {+ vi.restoreAllMocks();+});++function renderSettings(settingsHeight?: number) {+ const executeJavaScript = vi.fn().mockResolvedValue(undefined);+ const originalCreateElement = document.createElement.bind(document);++ vi.spyOn(document, 'createElement').mockImplementation(((+ tagName: string,+ options?: ElementCreationOptions,+ ) => {+ const element = originalCreateElement(tagName, options);+ if (tagName.toLowerCase() === 'webview') {+ Object.assign(element, {+ executeJavaScript,+ insertCSS: vi.fn().mockResolvedValue('theme-css'),+ removeInsertedCSS: vi.fn().mockResolvedValue(undefined),+ capturePage: vi.fn(),+ });+ }+ return element;+ }) as typeof document.createElement);++ const ghost = {+ enabled: true,+ dir: '/tmp/example',+ manifest: {+ id: 'example.settings-layout',+ name: 'Example',+ version: '1.0.0',+ settingsHtml: 'settings.html',+ settingsHeight,+ },+ } as InstalledGhost;++ const view = render(<GhostSettingsWebview ghost={ghost} />);+ const webview = view.container.querySelector('webview');+ if (!webview) throw new Error('Expected settings webview');+ webview.dispatchEvent(new Event('dom-ready'));++ const host = view.container.querySelector<HTMLElement>('[data-ghost-webview]');+ if (!host) throw new Error('Expected settings webview host');++ return { executeJavaScript, host };+}++describe('GhostSettingsWebview layout ownership', () => {+ it('does not inject responsive width rules into fixed-height guests', async () => {+ const { executeJavaScript, host } = renderSettings(360);++ await waitFor(() => expect(executeJavaScript).toHaveBeenCalledWith('void 0'));+ expect(+ executeJavaScript.mock.calls.some(([script]) => String(script).includes('__xdt_settings_w')),+ ).toBe(false);+ expect(host.classList.contains('overflow-hidden')).toBe(false);+ });++ it('keeps responsive containment for auto-height guests', async () => {+ const { executeJavaScript, host } = renderSettings();++ await waitFor(() =>+ expect(+ executeJavaScript.mock.calls.some(([script]) =>+ String(script).includes('__xdt_settings_w'),+ ),+ ).toBe(true),+ );+ const responsiveScript = executeJavaScript.mock.calls+ .map(([script]) => String(script))+ .find((script) => script.includes('__xdt_settings_w'));+ expect(responsiveScript).toContain('box-sizing:border-box!important');+ expect(responsiveScript).toContain('min-width:0!important');+ expect(responsiveScript).toContain('max-width:100%!important');+ expect(host.classList.contains('overflow-hidden')).toBe(true);+ });+});diff --git a/apps/desktop/src/renderer/cindy-brain/__tests__/ghostSettingsSnapshot.test.ts b/apps/desktop/src/renderer/cindy-brain/__tests__/ghostSettingsSnapshot.test.tsindex c24e6dadb8..8fc79af06b 100644--- a/apps/desktop/src/renderer/cindy-brain/__tests__/ghostSettingsSnapshot.test.ts+++ b/apps/desktop/src/renderer/cindy-brain/__tests__/ghostSettingsSnapshot.test.ts@@ -7,6 +7,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';import {__resetGhostSettingsSnapshotCacheForTest,+ GHOST_SETTINGS_LAYOUT_REVISION,loadGhostSettingsSnapshot,pruneGhostSettingsSnapshots,saveGhostSettingsSnapshot,@@ -24,6 +25,7 @@ function makeSnapshot(overrides: Partial<GhostSettingsSnapshot> = {}): GhostSettdpr: 2,themeCss: ':root { --surface: #111; }',version: '1.1.1',+ layoutRevision: GHOST_SETTINGS_LAYOUT_REVISION,capturedAt: Date.now(),...overrides,};@@ -87,6 +89,12 @@ describe('容错', () => {delete legacy.capturedAt;localStorage.setItem('ghostSettings.snapshot.g1', JSON.stringify(legacy));expect(loadGhostSettingsSnapshot('g1')).toBeNull();++ __resetGhostSettingsSnapshotCacheForTest();+ const preLayoutRevision: Partial<GhostSettingsSnapshot> = { ...makeSnapshot() };+ delete preLayoutRevision.layoutRevision;+ localStorage.setItem('ghostSettings.snapshot.g1', JSON.stringify(preLayoutRevision));+ expect(loadGhostSettingsSnapshot('g1')).toBeNull();});it('localStorage 写失败(配额满)时静默降级为仅内存缓存', () => {@@ -153,10 +161,13 @@ describe('存储预算', () => {describe('匹配判定', () => {const ctx = { version: '1.1.1', themeCss: ':root { --surface: #111; }', dpr: 2 };- it('版本 / 主题 / DPR 全等才命中', () => {+ it('插件版本 / 宿主布局版本 / 主题 / DPR 全等才命中', () => {expect(snapshotMatchesContext(makeSnapshot(), ctx)).toBe(true);expect(snapshotMatchesContext(makeSnapshot({ version: '1.1.2' }), ctx)).toBe(false);- expect(snapshotMatchesContext(makeSnapshot({ themeCss: ':root { --surface: #eee; }' }), ctx)).toBe(false);+ expect(snapshotMatchesContext(makeSnapshot({ layoutRevision: 2 }), ctx)).toBe(false);+ expect(+ snapshotMatchesContext(makeSnapshot({ themeCss: ':root { --surface: #eee; }' }), ctx),+ ).toBe(false);expect(snapshotMatchesContext(makeSnapshot({ dpr: 1 }), ctx)).toBe(false);});diff --git a/apps/desktop/src/renderer/cindy-brain/ghostSettingsSnapshot.ts b/apps/desktop/src/renderer/cindy-brain/ghostSettingsSnapshot.tsindex f90389e779..25133e454c 100644--- a/apps/desktop/src/renderer/cindy-brain/ghostSettingsSnapshot.ts+++ b/apps/desktop/src/renderer/cindy-brain/ghostSettingsSnapshot.ts@@ -5,8 +5,8 @@* 跨 app 重启可用);下次进入详情页首帧直接贴这张图(像素与真内容一致),* webview 在图底下装载,就绪后无缝撤图换真身。用户看不到空白帧与高度跳变。*- * 快照只是"上一次的画面",不承载任何真实状态:失配(版本 / 主题 / 宽度 /- * DPR 任一变化)或过期(TTL)就整张作废走老的淡入路径,绝不拿旧像素硬凑新布局。+ * 快照只是"上一次的画面",不承载任何真实状态:失配(插件版本 / 宿主布局版本 /+ * 主题 / 宽度 / DPR 任一变化)或过期(TTL)就整张作废走老的淡入路径。* 位图来自宿主对 guest 的 capturePage(嵌入方主动读,零桥模型不破),* 内容不受信也无所谓——它只被当成 <img> 的像素,不进任何执行上下文。*@@ -29,6 +29,8 @@ export interface GhostSettingsSnapshot {themeCss: string;/** 拍摄时的意识版本(原位更新后界面可能全变,作废)。 */version: string;+ /** 拍摄时的宿主设置布局版本(注入规则变化后旧位图作废)。 */+ layoutRevision: number;/** 拍摄时刻(epoch ms):TTL 过期判定 + 总量超预算时的 LRU 淘汰序。 */capturedAt: number;}@@ -42,6 +44,9 @@ export interface GhostSettingsSnapshotContext {const STORAGE_PREFIX = 'ghostSettings.snapshot.';+/** 宿主设置 guest 的布局契约版本;布局注入改变时递增以主动淘汰旧快照。 */+export const GHOST_SETTINGS_LAYOUT_REVISION = 3;+/*** 单条持久化体积上限(字符数,localStorage 按 UTF-16 计):设置区是纯色底 +* 文字控件,PNG data URL 正常远小于此;超限说明画面异常复杂,只留内存缓存。@@ -75,6 +80,7 @@ function isValidSnapshot(value: unknown): value is GhostSettingsSnapshot {Number.isFinite(v.dpr) &&typeof v.themeCss === 'string' &&typeof v.version === 'string' &&+ v.layoutRevision === GHOST_SETTINGS_LAYOUT_REVISION &&typeof v.capturedAt === 'number' &&Number.isFinite(v.capturedAt));@@ -192,13 +198,14 @@ export function pruneGhostSettingsSnapshots(installedGhostIds: Iterable<string>)}}-/** 上下文匹配:版本 / 主题 CSS / DPR 全等才允许贴图。 */+/** 上下文匹配:插件版本 / 宿主布局版本 / 主题 CSS / DPR 全等才允许贴图。 */export function snapshotMatchesContext(snapshot: GhostSettingsSnapshot,ctx: GhostSettingsSnapshotContext,): boolean {return (snapshot.version === ctx.version &&+ snapshot.layoutRevision === GHOST_SETTINGS_LAYOUT_REVISION &&snapshot.themeCss === ctx.themeCss &&snapshot.dpr === ctx.dpr);diff --git a/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx b/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsxindex a0da6c50a2..03a3f9ebb9 100644--- a/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx+++ b/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx@@ -2,7 +2,7 @@* Plugin detail presentation for configuration, Tools, permissions, and factual metadata.** Inputs: the renderer-safe Plugin detail model plus the installed Ghost when available.- * Outputs: accessible detail interactions without mutating Ghost runtime data directly.+ * Outputs: accessible detail interactions and a single-row responsive action hero.* [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md*/@@ -199,7 +199,7 @@ export function GhostPluginDetailView({</button><header>- <div className="plugin-detail-hero grid grid-cols-[64px_minmax(0,1fr)_auto] items-center gap-5">+ <div className="plugin-detail-hero grid grid-cols-[64px_minmax(0,1fr)_auto] items-center gap-3"><GhostPluginIconiconDataUrl={detail.iconDataUrl}iconId={detail.id}@@ -214,7 +214,7 @@ export function GhostPluginDetailView({</div><div- className="plugin-detail-actions flex shrink-0 items-center gap-3"+ className="plugin-detail-actions flex shrink-0 flex-nowrap items-center gap-1.5"style={WINDOW_NO_DRAG_STYLE}>{updateVersion ? (@@ -238,7 +238,7 @@ export function GhostPluginDetailView({disabled={!canUse}title={!enabled ? t('settings.ghosts.detail.useDisabled') : undefined}className={cn(- 'inline-flex h-10 min-w-[88px] items-center justify-center rounded-full px-5 text-13 font-medium',+ 'plugin-detail-primary-action inline-flex h-10 min-w-[88px] items-center justify-center whitespace-nowrap rounded-full px-3 text-13 font-medium','bg-[var(--accent-cta-bg)] text-[var(--accent-pure-cta-fg)]','transition-[background-color,transform,opacity] duration-150 hover:bg-[var(--accent-hover)] active:scale-[0.98]','focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',@@ -383,20 +383,26 @@ export function GhostPluginMetadata({}) {const { t } = useTranslation();return (- <div className="mt-2 flex flex-wrap items-center gap-2 text-13 leading-5 text-[var(--text-tertiary)]">+ <div className="plugin-detail-metadata mt-2 flex min-w-0 flex-nowrap items-center gap-2 overflow-hidden whitespace-nowrap text-13 leading-5 text-[var(--text-tertiary)]">{author ? (<>- <span>{t('settings.ghosts.detail.byAuthor', { author })}</span>+ <span className="min-w-0 truncate">+ {t('settings.ghosts.detail.byAuthor', { author })}+ </span><MetadataDivider /></>) : null}- <span>v{version}</span>+ <span className="shrink-0">v{version}</span></div>);}function MetadataDivider() {- return <span aria-hidden="true">·</span>;+ return (+ <span className="shrink-0" aria-hidden="true">+ ·+ </span>+ );}function DetailSectionHeader({diff --git a/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx b/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsxindex e532d3423d..1c988a86ba 100644--- a/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx+++ b/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx@@ -2,13 +2,13 @@* Plugin catalog and detail coordinator backed by the latest Ghost host APIs.** Inputs: installed Ghost snapshots and user actions.- * Outputs: the Plugin list/detail UI plus install, toggle, and command-launch flows.+ * Outputs: the Plugin list/detail UI, focus-stable installed queue, and Plugin action flows.* [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md*/import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';import { useNavigate, useSearchParams } from 'react-router-dom';-import { ChevronDown, ChevronRight, Plus, Sparkles, Upload } from 'lucide-react';+import { ChevronDown, ChevronRight, ChevronUp, Plus, Sparkles, Upload } from 'lucide-react';import { useTranslation } from 'react-i18next';import { WINDOW_NO_DRAG_STYLE } from '@/components/layout/windowDrag';@@ -57,7 +57,11 @@ import {type GhostPluginListItem,} from './lib/ghostPluginViewModel';import { formatSetupGateDescription } from './lib/ghostSetupGateModel';-import { PluginManagementLayout, PluginManagementPage } from './PluginManagementLayout';+import {+ PLUGIN_MANAGEMENT_CARD_GRID_CLASS,+ PluginManagementLayout,+ PluginManagementPage,+} from './PluginManagementLayout';import { GhostPluginDetailView } from './GhostPluginDetailView';import { GhostPluginIcon } from './GhostPluginIcon';import { MarketPluginDetailView } from './MarketPluginDetailView';@@ -71,6 +75,8 @@ import { usePluginIconRefresh } from './lib/usePluginIconRefresh';import './plugin-motion.css';const MAX_VISIBLE_INSTALLED_GHOSTS = 5;+const PLUGIN_CATALOG_TOOLBAR_CLASS =+ 'plugin-catalog-toolbar mb-5 flex items-center justify-between gap-4';type PluginPresentationFilter = 'all' | PluginPresentationOrigin;type PresentedGhostPluginItem = GhostPluginListItem & {origin: PluginPresentationOrigin;@@ -332,9 +338,7 @@ export function GhostPluginPage() {? (marketByGhostId.get(selectedDetail.id) ?? null): null;const selectedMarketUpdate =- selectedMarketInstall?.installState === 'update-available'- ? selectedMarketInstall- : null;+ selectedMarketInstall?.installState === 'update-available' ? selectedMarketInstall : null;const panelStatus = useMemo(() => {if (!selectedDetail || selectedDetail.panelMinWidth === null) return null;@@ -770,64 +774,18 @@ export function GhostPluginPage() {{installedShortcutItems.length}</span></div>- <div className="flex min-w-0 flex-wrap items-center gap-1">- {installedShortcutItems- .slice(0, MAX_VISIBLE_INSTALLED_GHOSTS)- .map((item) => renderInstalledGhost(item, setSelectedId))}- {installedShortcutItems.length > MAX_VISIBLE_INSTALLED_GHOSTS ? (- <button- type="button"- onClick={() => setInstalledExpanded((expanded) => !expanded)}- className={cn(- 'group flex w-16 shrink-0 justify-center rounded-[12px] px-2 py-2',- 'transition-transform duration-150 ease-out hover:-translate-y-px active:translate-y-0 active:scale-[0.98]',- 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',- 'motion-reduce:transform-none motion-reduce:transition-none',- )}- aria-expanded={installedExpanded}- aria-label={t(- installedExpanded- ? 'settings.ghosts.page.installedCollapse'- : 'settings.ghosts.page.installedExpand',- { count: installedShortcutItems.length - MAX_VISIBLE_INSTALLED_GHOSTS },- )}- >- <span className="grid size-12 grid-cols-2 grid-rows-2 place-content-center gap-1 rounded-[22%] border-[0.5px] border-[color-mix(in_srgb,var(--border-default)_62%,transparent)] bg-[color-mix(in_srgb,var(--surface-chip)_58%,transparent)] p-2 shadow-[var(--plugin-icon-shadow)] transition-colors duration-150 group-hover:bg-[color-mix(in_srgb,var(--surface-chip)_78%,transparent)]">- {installedShortcutItems- .slice(MAX_VISIBLE_INSTALLED_GHOSTS, MAX_VISIBLE_INSTALLED_GHOSTS + 3)- .map((item) => (- <span- key={item.id}- className="flex size-3.5 items-center justify-center overflow-hidden rounded-[5px] bg-[var(--surface-elevated)]"- >- <GhostPluginIcon- iconDataUrl={item.iconDataUrl}- iconId={item.id}- iconName={item.name}- size="mini"- />- </span>- ))}- <span className="col-start-2 row-start-2 flex size-3.5 items-center justify-center rounded-[5px] bg-[var(--surface-elevated)] text-[9px] font-medium tabular-nums text-[var(--text-secondary)]">- +{installedShortcutItems.length - MAX_VISIBLE_INSTALLED_GHOSTS}- </span>- </span>- </button>- ) : null}- </div>- {installedExpanded && installedShortcutItems.length > MAX_VISIBLE_INSTALLED_GHOSTS ? (- <div className="plugin-motion-stagger mt-2 flex flex-wrap items-center gap-1">- {installedShortcutItems- .slice(MAX_VISIBLE_INSTALLED_GHOSTS)- .map((item) => renderInstalledGhost(item, setSelectedId))}- </div>- ) : null}+ <InstalledGhostQueue+ items={installedShortcutItems}+ expanded={installedExpanded}+ onExpandedChange={setInstalledExpanded}+ onSelect={setSelectedId}+ /></section>) : null}<section className="plugin-motion-page-section mt-6 min-w-0">- <div className="mb-5 flex flex-col gap-4 md:flex-row md:items-center md:justify-between">- <div className="flex items-baseline gap-2">+ <div className={PLUGIN_CATALOG_TOOLBAR_CLASS}>+ <div className="flex shrink-0 items-baseline gap-2 whitespace-nowrap"><h2 className="text-20 font-medium text-[var(--text-primary)]">{t('settings.ghosts.page.allTitle')}</h2>@@ -836,7 +794,7 @@ export function GhostPluginPage() {</span></div><div- className="flex max-w-full items-center gap-1 overflow-x-auto"+ className="plugin-catalog-filters flex min-w-0 max-w-full items-center gap-1 overflow-x-auto"role="group"aria-label={t('settings.ghosts.page.filtersAria')}style={WINDOW_NO_DRAG_STYLE}@@ -883,7 +841,7 @@ export function GhostPluginPage() {) : null}{items.length > 0 || availableMarketItems.length > 0 ? (- <div className="plugin-motion-stagger grid grid-cols-1 gap-3 sm:grid-cols-2">+ <div className={cn('plugin-motion-stagger', PLUGIN_MANAGEMENT_CARD_GRID_CLASS)}>{items.map((item) => (<GhostPluginCardkey={item.id}@@ -1035,7 +993,7 @@ function GhostPluginActions({<buttontype="button"className={cn(- 'group inline-flex h-9 shrink-0 items-center gap-2 rounded-full border border-[var(--border-default)]',+ 'plugin-management-action-trigger group inline-flex h-9 shrink-0 items-center gap-2 rounded-full border border-[var(--border-default)]','bg-[var(--surface-elevated)] px-3.5 text-12 font-medium text-[var(--text-primary)] shadow-[var(--plugin-card-shadow)]','transition-[background-color,border-color,transform] duration-150 ease-out','hover:border-[var(--text-tertiary)] hover:bg-[var(--surface-hover-soft)] active:scale-[0.98]',@@ -1045,11 +1003,13 @@ function GhostPluginActions({aria-label={t('settings.ghosts.page.addPluginAria')}><Plus size={14} strokeWidth={1.8} aria-hidden="true" />- {t('settings.ghosts.page.addPlugin')}+ <span className="plugin-management-action-label">+ {t('settings.ghosts.page.addPlugin')}+ </span><ChevronDownsize={13}strokeWidth={1.75}- className="transition-transform duration-150 group-data-[state=open]:rotate-180 motion-reduce:transition-none"+ className="plugin-management-action-chevron transition-transform duration-150 group-data-[state=open]:rotate-180 motion-reduce:transition-none"aria-hidden="true"/></button>@@ -1233,6 +1193,80 @@ export function InstalledGhostShortcut({);}-function renderInstalledGhost(item: GhostPluginListItem, onSelect: (id: string) => void) {- return <InstalledGhostShortcut key={item.id} item={item} onSelect={onSelect} />;+/** Installed shortcuts share one wrapping queue in both collapsed and expanded states. */+export function InstalledGhostQueue({+ items,+ expanded,+ onExpandedChange,+ onSelect,+}: {+ items: readonly GhostPluginListItem[];+ expanded: boolean;+ onExpandedChange: (expanded: boolean) => void;+ onSelect: (id: string) => void;+}) {+ const { t } = useTranslation();+ const hasOverflow = items.length > MAX_VISIBLE_INSTALLED_GHOSTS;+ const visibleItems = expanded ? items : items.slice(0, MAX_VISIBLE_INSTALLED_GHOSTS);++ return (+ <div+ data-testid="installed-plugin-queue"+ className={cn(+ 'flex min-w-0 flex-wrap items-center gap-1',+ expanded && 'plugin-motion-stagger',+ )}+ >+ {visibleItems.map((item) => (+ <InstalledGhostShortcut key={item.id} item={item} onSelect={onSelect} />+ ))}+ {hasOverflow ? (+ <button+ key="installed-overflow-toggle"+ type="button"+ onClick={() => onExpandedChange(!expanded)}+ className={cn(+ 'group flex w-16 shrink-0 justify-center rounded-[12px] px-2 py-2',+ 'transition-transform duration-150 ease-out hover:-translate-y-px active:translate-y-0 active:scale-[0.98]',+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',+ 'motion-reduce:transform-none motion-reduce:transition-none',+ )}+ aria-expanded={expanded}+ aria-label={t(+ expanded+ ? 'settings.ghosts.page.installedCollapse'+ : 'settings.ghosts.page.installedExpand',+ { count: items.length - MAX_VISIBLE_INSTALLED_GHOSTS },+ )}+ >+ {expanded ? (+ <span className="flex size-12 items-center justify-center rounded-[22%] border-[0.5px] border-[color-mix(in_srgb,var(--border-default)_62%,transparent)] bg-[color-mix(in_srgb,var(--surface-chip)_58%,transparent)] text-[var(--text-secondary)] shadow-[var(--plugin-icon-shadow)] transition-colors duration-150 group-hover:bg-[color-mix(in_srgb,var(--surface-chip)_78%,transparent)]">+ <ChevronUp size={18} strokeWidth={1.8} aria-hidden="true" />+ </span>+ ) : (+ <span className="grid size-12 grid-cols-2 grid-rows-2 place-content-center gap-1 rounded-[22%] border-[0.5px] border-[color-mix(in_srgb,var(--border-default)_62%,transparent)] bg-[color-mix(in_srgb,var(--surface-chip)_58%,transparent)] p-2 shadow-[var(--plugin-icon-shadow)] transition-colors duration-150 group-hover:bg-[color-mix(in_srgb,var(--surface-chip)_78%,transparent)]">+ {items+ .slice(MAX_VISIBLE_INSTALLED_GHOSTS, MAX_VISIBLE_INSTALLED_GHOSTS + 3)+ .map((item) => (+ <span+ key={item.id}+ className="flex size-3.5 items-center justify-center overflow-hidden rounded-[5px] bg-[var(--surface-elevated)]"+ >+ <GhostPluginIcon+ iconDataUrl={item.iconDataUrl}+ iconId={item.id}+ iconName={item.name}+ size="mini"+ />+ </span>+ ))}+ <span className="col-start-2 row-start-2 flex size-3.5 items-center justify-center rounded-[5px] bg-[var(--surface-elevated)] text-[9px] font-medium tabular-nums text-[var(--text-secondary)]">+ +{items.length - MAX_VISIBLE_INSTALLED_GHOSTS}+ </span>+ </span>+ )}+ </button>+ ) : null}+ </div>+ );}diff --git a/apps/desktop/src/renderer/features/plugin/MarketPluginDetailView.tsx b/apps/desktop/src/renderer/features/plugin/MarketPluginDetailView.tsxindex 69676a580b..187f81374c 100644--- a/apps/desktop/src/renderer/features/plugin/MarketPluginDetailView.tsx+++ b/apps/desktop/src/renderer/features/plugin/MarketPluginDetailView.tsx@@ -51,7 +51,7 @@ export function MarketPluginDetailView({</button><header>- <div className="grid grid-cols-[64px_minmax(0,1fr)_auto] items-center gap-5">+ <div className="plugin-detail-hero grid grid-cols-[64px_minmax(0,1fr)_auto] items-center gap-3"><GhostPluginIconiconDataUrl={detail.icon?.url}iconId={detail.ghostId}@@ -80,7 +80,7 @@ export function MarketPluginDetailView({onClick={onInstall}disabled={actionDisabled}className={cn(- 'inline-flex h-10 min-w-[104px] items-center justify-center gap-2 rounded-full px-5 text-13 font-medium',+ 'plugin-detail-primary-action inline-flex h-10 min-w-[104px] items-center justify-center gap-2 whitespace-nowrap rounded-full px-4 text-13 font-medium','bg-[var(--accent-cta-bg)] text-[var(--accent-pure-cta-fg)]','transition-[background-color,transform,opacity] duration-150 hover:bg-[var(--accent-hover)] active:scale-[0.98]','focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',diff --git a/apps/desktop/src/renderer/features/plugin/PluginManagementLayout.tsx b/apps/desktop/src/renderer/features/plugin/PluginManagementLayout.tsxindex e53a07e8cf..264a3c84e9 100644--- a/apps/desktop/src/renderer/features/plugin/PluginManagementLayout.tsx+++ b/apps/desktop/src/renderer/features/plugin/PluginManagementLayout.tsx@@ -1,12 +1,12 @@/*** Shared list-page shell for the Plugin and Skill product surfaces.*- * Inputs: active tab, shared search state, and page-specific header actions.- * Outputs: one width, toolbar, scrolling frame, and transition contract for both catalogs.+ * Inputs: active tab, shared search state, optional labels with tab-derived defaults, and actions.+ * Outputs: one width, focus-order-aligned adaptive toolbar, scrolling frame, and transitions.* [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md*/-import type { ReactNode } from 'react';+import { useLayoutEffect, useRef, useState, type ReactNode } from 'react';import { useNavigate } from 'react-router-dom';import { useTranslation } from 'react-i18next';import { Search, X } from 'lucide-react';@@ -45,6 +45,16 @@ interface PluginManagementPageProps {*/export const PLUGIN_MANAGEMENT_FRAME_CLASS = 'mx-auto w-full max-w-[920px] px-8 lg:px-12';+/**+ * Catalog cards respond to the width of their own content area rather than the+ * outer window. This matters when app sidebars leave a narrow main pane even+ * though viewport breakpoints such as `sm` / `md` still match.+ */+export const PLUGIN_MANAGEMENT_CARD_GRID_CLASS =+ 'grid grid-cols-[repeat(auto-fit,minmax(min(100%,22.5rem),1fr))] gap-3';++const PLUGIN_MANAGEMENT_STACKED_MAX_WIDTH = 720;+export function PluginManagementLayout({activeTab,children,@@ -55,7 +65,7 @@ export function PluginManagementLayout({headerActions,}: PluginManagementLayoutProps) {return (- <div className="plugin-motion-root flex h-full min-h-0 w-full flex-col bg-[var(--surface)]">+ <div className="plugin-management-layout-root plugin-motion-root flex h-full min-h-0 w-full flex-col bg-[var(--surface)]"><PluginManagementHeaderactiveTab={activeTab}query={query}@@ -81,84 +91,134 @@ export function PluginManagementHeader({}: PluginManagementHeaderProps) {const { t } = useTranslation();const navigate = useNavigate();+ const frameRef = useRef<HTMLDivElement | null>(null);+ const [stacked, setStacked] = useState(false);const searchable = query !== undefined && onQueryChange !== undefined;+ const searchInputId = `plugin-management-${activeTab}-search`;+ const resolvedSearchPlaceholder =+ searchPlaceholder ??+ t(activeTab === 'plugins' ? 'settings.ghosts.page.search' : 'skillhub.home.search');+ const resolvedClearSearchLabel =+ clearSearchLabel ??+ t(activeTab === 'plugins' ? 'settings.ghosts.page.clearSearch' : 'skillhub.home.clearSearch');- // Catalog scroll surfaces reserve a 12px gutter on both edges; mirror it here.- return (- <div className="h-16 shrink-0 px-3" style={WINDOW_DRAG_STYLE}>- <div className={cn(PLUGIN_MANAGEMENT_FRAME_CLASS, 'flex h-full items-center gap-4')}>- <div- className="plugin-motion-tabs inline-flex shrink-0 rounded-full border p-0.5 backdrop-blur-md"- role="tablist"- aria-label={t('sidebar.horizontalTabbarAria')}- style={{- ...WINDOW_NO_DRAG_STYLE,- background: 'color-mix(in srgb, var(--surface-chip) 62%, transparent)',- borderColor: 'color-mix(in srgb, var(--border-default) 52%, transparent)',- boxShadow: 'inset 0 1px 0 color-mix(in srgb, var(--surface-elevated) 24%, transparent)',- }}- >- <TabButton- active={activeTab === 'plugins'}- label={t('settings.ghosts.title')}- onClick={() => navigate('/plugins')}- />- <TabButton- active={activeTab === 'skills'}- label={t('skillhub.home.title')}- onClick={() => navigate('/skillhub/local')}- />- </div>- {searchable || children ? (- // 该容器 flex-1 撑满 tab 与右缘之间的整段空间;no-drag 只能标在其中的- // 交互元素(搜索框 / 动作按钮)上,标在容器上会把中段空白也挖出拖拽区- // (windowDrag.tsx:drag 区域是纯几何计算,与内容实际占位无关)。- <div className="flex min-w-0 flex-1 items-center justify-end gap-1.5">- {searchable ? (- <div- className="flex h-9 min-w-[148px] max-w-[260px] flex-1 items-center gap-2 rounded-full border px-3 backdrop-blur-md transition-[background-color,border-color,box-shadow] focus-within:border-[var(--focus-ring)] focus-within:ring-2 focus-within:ring-[var(--focus-ring-soft)]"- style={{- ...WINDOW_NO_DRAG_STYLE,- background: 'color-mix(in srgb, var(--surface-elevated-soft) 70%, transparent)',- borderColor: 'color-mix(in srgb, var(--border-default) 52%, transparent)',- boxShadow:- 'inset 0 1px 0 color-mix(in srgb, var(--surface-elevated) 24%, transparent)',- }}+ useLayoutEffect(() => {+ const frame = frameRef.current;+ const root = frame?.closest('.plugin-management-layout-root');+ if (!root || typeof ResizeObserver === 'undefined') return;+ const update = (width: number) => setStacked(width <= PLUGIN_MANAGEMENT_STACKED_MAX_WIDTH);+ update(root.getBoundingClientRect().width);+ const observer = new ResizeObserver((entries) => {+ const entry = entries[0];+ update(entry?.contentRect.width ?? root.getBoundingClientRect().width);+ });+ observer.observe(root);+ return () => observer.disconnect();+ }, []);++ const tabs = (+ <div+ key="plugin-management-tabs"+ className="plugin-motion-tabs inline-flex shrink-0 rounded-full border p-0.5 backdrop-blur-md"+ role="tablist"+ aria-label={t('sidebar.horizontalTabbarAria')}+ style={{+ ...WINDOW_NO_DRAG_STYLE,+ background: 'color-mix(in srgb, var(--surface-chip) 62%, transparent)',+ borderColor: 'color-mix(in srgb, var(--border-default) 52%, transparent)',+ boxShadow: 'inset 0 1px 0 color-mix(in srgb, var(--surface-elevated) 24%, transparent)',+ }}+ >+ <TabButton+ active={activeTab === 'plugins'}+ label={t('settings.ghosts.title')}+ onClick={() => navigate('/plugins')}+ />+ <TabButton+ active={activeTab === 'skills'}+ label={t('skillhub.home.title')}+ onClick={() => navigate('/skillhub/local')}+ />+ </div>+ );++ const tools =+ searchable || children ? (+ // 该容器 flex-1 撑满 tab 与右缘之间的整段空间;no-drag 只能标在其中的+ // 交互元素(搜索框 / 动作按钮)上,标在容器上会把中段空白也挖出拖拽区+ // (windowDrag.tsx:drag 区域是纯几何计算,与内容实际占位无关)。+ <div+ key="plugin-management-tools"+ className="plugin-management-tools flex min-w-0 flex-1 items-center justify-end gap-1.5"+ >+ {searchable ? (+ <div+ className="plugin-management-search-control flex h-9 min-w-[148px] max-w-[260px] flex-1 items-center gap-2 rounded-full border px-3 backdrop-blur-md transition-[width,background-color,border-color,box-shadow] focus-within:border-[var(--focus-ring)] focus-within:ring-2 focus-within:ring-[var(--focus-ring-soft)] motion-reduce:transition-none"+ style={{+ ...WINDOW_NO_DRAG_STYLE,+ background: 'color-mix(in srgb, var(--surface-elevated-soft) 70%, transparent)',+ borderColor: 'color-mix(in srgb, var(--border-default) 52%, transparent)',+ boxShadow:+ 'inset 0 1px 0 color-mix(in srgb, var(--surface-elevated) 24%, transparent)',+ }}+ >+ <label+ htmlFor={searchInputId}+ className="plugin-management-search-trigger grid size-6 shrink-0 cursor-text place-items-center text-[var(--text-tertiary)]"+ >+ <Search size={15} strokeWidth={1.75} aria-hidden="true" />+ </label>+ <input+ id={searchInputId}+ type="text"+ inputMode="search"+ value={query}+ onChange={(event) => onQueryChange(event.target.value)}+ onKeyDown={(event) => {+ if (event.nativeEvent.isComposing) return;+ if (event.key !== 'Escape') return;+ if (query) {+ onQueryChange('');+ } else {+ event.currentTarget.blur();+ }+ }}+ placeholder={resolvedSearchPlaceholder}+ aria-label={resolvedSearchPlaceholder}+ className="plugin-management-search-input min-w-0 flex-1 appearance-none border-0 bg-transparent text-13 text-[var(--text-primary)] outline-none placeholder:text-[var(--text-placeholder)]"+ />+ {query ? (+ <button+ type="button"+ onClick={() => onQueryChange('')}+ aria-label={resolvedClearSearchLabel}+ className="plugin-management-search-clear grid size-6 shrink-0 place-items-center rounded-full text-[var(--text-tertiary)] transition-colors duration-150 hover:bg-[var(--surface-hover-soft)] hover:text-[var(--text-primary)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]">- <Search- size={15}- strokeWidth={1.75}- className="shrink-0 text-[var(--text-tertiary)]"- aria-hidden="true"- />- <input- type="text"- inputMode="search"- value={query}- onChange={(event) => onQueryChange(event.target.value)}- placeholder={searchPlaceholder}- aria-label={searchPlaceholder}- className="min-w-0 flex-1 appearance-none border-0 bg-transparent text-13 text-[var(--text-primary)] outline-none placeholder:text-[var(--text-placeholder)]"- />- {query ? (- <button- type="button"- onClick={() => onQueryChange('')}- aria-label={clearSearchLabel}- className="grid size-6 shrink-0 place-items-center rounded-full text-[var(--text-tertiary)] transition-colors duration-150 hover:bg-[var(--surface-hover-soft)] hover:text-[var(--text-primary)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]"- >- <X size={13} strokeWidth={1.75} aria-hidden="true" />- </button>- ) : null}- </div>- ) : null}- {children ? (- <div className="flex shrink-0 items-center gap-1.5" style={WINDOW_NO_DRAG_STYLE}>- {children}- </div>+ <X size={13} strokeWidth={1.75} aria-hidden="true" />+ </button>) : null}</div>) : null}+ {children ? (+ <div className="flex shrink-0 items-center gap-1.5" style={WINDOW_NO_DRAG_STYLE}>+ {children}+ </div>+ ) : null}+ </div>+ ) : null;++ // Catalog scroll surfaces reserve a 12px gutter on both edges; mirror it here.+ return (+ <div className="plugin-management-header h-16 shrink-0 px-3" style={WINDOW_DRAG_STYLE}>+ <div+ ref={frameRef}+ className={cn(+ PLUGIN_MANAGEMENT_FRAME_CLASS,+ 'plugin-management-header-frame flex h-full items-center gap-4',+ )}+ >+ {stacked ? tools : tabs}+ {stacked ? tabs : tools}</div></div>);@@ -189,7 +249,7 @@ function TabButton({aria-selected={active}onClick={onClick}className={cn(- 'h-8 min-w-[88px] select-none rounded-full border border-transparent px-4 text-13 font-medium transition-colors',+ 'plugin-management-tab h-8 min-w-[88px] select-none rounded-full border border-transparent px-4 text-13 font-medium transition-colors','focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',active? 'plugin-motion-selected text-[var(--text-primary)] shadow-[var(--plugin-card-shadow)]'diff --git a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsx b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsxindex 0e5bf0627e..a87bef8bcd 100644--- a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsx+++ b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsx@@ -1,12 +1,12 @@/**- * Regression coverage for Plugin card actions and compact marketplace metadata.+ * Regression coverage for Plugin card actions, compact metadata, and queue focus continuity.* [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md* @vitest-environment jsdom*/-import { fireEvent, render, screen } from '@testing-library/react';+import { fireEvent, render, screen, within } from '@testing-library/react';import { describe, expect, it, vi } from 'vitest';-import type { ReactNode } from 'react';+import { useState, type ReactNode } from 'react';vi.mock('react-i18next', () => ({useTranslation: () => ({ t: (key: string) => key }),@@ -20,7 +20,12 @@ vi.mock('@/components/ui/tooltip', () => ({),}));-import { GhostPluginCard, InstalledGhostShortcut, MarketPluginCard } from '../GhostPluginPage';+import {+ GhostPluginCard,+ InstalledGhostQueue,+ InstalledGhostShortcut,+ MarketPluginCard,+} from '../GhostPluginPage';import type { GhostPluginListItem } from '../lib/ghostPluginViewModel';import type { PluginMarketItem } from '../../../../shared/pluginMarket';@@ -50,6 +55,18 @@ const marketPlugin: PluginMarketItem = {enabled: null,};+function InstalledQueueHarness({ items }: { items: readonly GhostPluginListItem[] }) {+ const [expanded, setExpanded] = useState(false);+ return (+ <InstalledGhostQueue+ items={items}+ expanded={expanded}+ onExpandedChange={setExpanded}+ onSelect={vi.fn()}+ />+ );+}+describe('GhostPluginCard', () => {it('shows the installed shortcut name through the shared Tooltip', () => {const onSelect = vi.fn();@@ -64,6 +81,39 @@ describe('GhostPluginCard', () => {expect(onSelect).toHaveBeenCalledWith('filo-google');});+ it('puts the collapse control after every installed plugin in the expanded queue', () => {+ const plugins = Array.from({ length: 7 }, (_, index) => ({+ ...installedPlugin,+ id: `plugin-${index + 1}`,+ name: `Plugin ${index + 1}`,+ }));+ const { container } = render(<InstalledQueueHarness items={plugins} />);++ expect(screen.getByRole('button', { name: 'Plugin 5' })).toBeTruthy();+ expect(screen.queryByRole('button', { name: 'Plugin 6' })).toBeNull();++ const expand = screen.getByRole('button', {+ name: 'settings.ghosts.page.installedExpand',+ });+ expand.focus();+ fireEvent.click(expand);++ const queue = container.querySelector('[data-testid="installed-plugin-queue"]');+ const collapse = screen.getByRole('button', {+ name: 'settings.ghosts.page.installedCollapse',+ });+ expect(screen.getByRole('button', { name: 'Plugin 7' })).toBeTruthy();+ expect(queue?.lastElementChild).toBe(collapse);+ expect(within(collapse).queryByText('+2')).toBeNull();+ expect(collapse.querySelector('.lucide-chevron-up')).toBeTruthy();+ expect(document.activeElement).toBe(collapse);++ fireEvent.click(collapse);+ expect(document.activeElement).toBe(+ screen.getByRole('button', { name: 'settings.ghosts.page.installedExpand' }),+ );+ });+it('opens the plugin detail from the card body without firing the action', () => {const onSelect = vi.fn();const onAction = vi.fn();diff --git a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginDetailSections.test.tsx b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginDetailSections.test.tsxindex 4afcfa7cfa..5bf049b9eb 100644--- a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginDetailSections.test.tsx+++ b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginDetailSections.test.tsx@@ -52,6 +52,7 @@ vi.mock('react-i18next', () => ({}));import type { GhostPermissionItem } from '../../../../shared/ghost';+import { CindyCapabilityPrefs } from '@/cindy-brain/CindyCapabilityPrefs';import {DetailsSection,GhostPluginDetailView,@@ -150,11 +151,15 @@ describe('Ghost plugin detail sections', () => {const scrollSurface = container.querySelector('main');const detailFrame = container.querySelector('article');const backButton = detailFrame?.querySelector(':scope > button');+ const detailHero = detailFrame?.querySelector('.plugin-detail-hero');+ const detailActions = detailFrame?.querySelector('.plugin-detail-actions');expect(scrollSurface?.className).toContain('[scrollbar-gutter:stable_both-edges]');expect(detailFrame?.className).toContain('plugin-detail-frame');expect(detailFrame?.className).toContain('mx-auto');expect(detailFrame?.className).toContain('max-w-[824px]');expect(backButton?.className).toContain('-ml-3');+ expect(detailHero?.className).toContain('grid-cols-[64px_minmax(0,1fr)_auto]');+ expect(detailActions?.className).toContain('flex-nowrap');});it('disables every market update entry while an update is busy', async () => {@@ -207,6 +212,44 @@ describe('Ghost plugin detail sections', () => {expect(metadata.textContent).toBe('By Cindy·v1.1.4');expect(metadata.className).toContain('text-[var(--text-tertiary)]');expect(metadata.innerHTML).not.toContain('text-[var(--text-secondary)]');+ expect(screen.getByText('By Cindy').className).toContain('min-w-0');+ expect(screen.getByText('By Cindy').className).toContain('truncate');+ });++ it('marks Cindy model preferences as a card-width responsive control group', () => {+ Object.defineProperty(window, 'electronAPI', {+ configurable: true,+ value: {+ ghosts: {+ cindyPrefsSync: () => ({+ overrides: {},+ image: {+ options: [{ id: 'image-default', label: 'Image Default' }],+ defaultModel: { id: 'image-default', label: 'Image Default' },+ },+ video: {+ options: [{ id: 'video-default', label: 'Video Default' }],+ defaultModel: { id: 'video-default', label: 'Video Default' },+ },+ }),+ setCindyPref: vi.fn(),+ },+ },+ });++ const { container } = render(+ <CindyCapabilityPrefs+ ghostId="builtin.example"+ capabilities={['image.generate']}+ appearance="plugin"+ />,+ );++ expect(container.querySelector('.cindy-capability-prefs')).toBeTruthy();+ expect(container.querySelector('.cindy-capability-row')).toBeTruthy();+ const select = screen.getByRole('combobox');+ expect(select.className).toContain('cindy-capability-select');+ expect(select.className).toContain('max-w-[60%]');});it('shows only the Tool description after an explicit click', async () => {diff --git a/apps/desktop/src/renderer/features/plugin/__tests__/PluginManagementLayout.test.tsx b/apps/desktop/src/renderer/features/plugin/__tests__/PluginManagementLayout.test.tsxindex 83c8ac5a29..7b12f96a61 100644--- a/apps/desktop/src/renderer/features/plugin/__tests__/PluginManagementLayout.test.tsx+++ b/apps/desktop/src/renderer/features/plugin/__tests__/PluginManagementLayout.test.tsx@@ -1,18 +1,20 @@/**- * Regression coverage for the shared Plugin and Skill management shell.+ * Regression coverage for the shared Plugin and Skill shell, search accessibility, and focus order.* [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md* @vitest-environment jsdom*/-import { fireEvent, render, screen, waitFor } from '@testing-library/react';+import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';import { MemoryRouter, useLocation } from 'react-router-dom';-import { describe, expect, it, vi } from 'vitest';+import { afterEach, describe, expect, it, vi } from 'vitest';vi.mock('react-i18next', () => ({useTranslation: () => ({t: (key: string) =>({'settings.ghosts.title': 'Plugins',+ 'settings.ghosts.page.search': 'Search plugins',+ 'settings.ghosts.page.clearSearch': 'Clear Plugin Search','skillhub.home.title': 'Skills','sidebar.horizontalTabbarAria': 'Plugin and skill navigation','skillhub.home.search': 'Search skills',@@ -21,9 +23,17 @@ vi.mock('react-i18next', () => ({}),}));-import { PluginManagementLayout, PluginManagementPage } from '../PluginManagementLayout';+import {+ PLUGIN_MANAGEMENT_CARD_GRID_CLASS,+ PluginManagementLayout,+ PluginManagementPage,+} from '../PluginManagementLayout';import { useActiveMainView } from '@/hooks/useActiveMainView';+afterEach(() => {+ vi.unstubAllGlobals();+});+function CurrentPath() {return <output data-testid="current-path">{useLocation().pathname}</output>;}@@ -80,6 +90,12 @@ describe('PluginManagementLayout', () => {expect(pageFrame?.className).toContain('max-w-[920px]');});+ it('uses a content-width responsive card grid for both catalogs', () => {+ expect(PLUGIN_MANAGEMENT_CARD_GRID_CLASS).toContain('auto-fit');+ expect(PLUGIN_MANAGEMENT_CARD_GRID_CLASS).toContain('min(100%,22.5rem)');+ expect(PLUGIN_MANAGEMENT_CARD_GRID_CLASS).not.toMatch(/\b(?:sm|md|lg):grid-cols-/);+ });+it('keeps catalog children in a height-constrained flex column so their main area can scroll', () => {render(<MemoryRouter>@@ -121,4 +137,175 @@ describe('PluginManagementLayout', () => {fireEvent.click(screen.getByRole('button', { name: 'Clear skill search' }));expect(onQueryChange).toHaveBeenCalledWith('');});++ it.each([+ ['plugins', 'Search plugins', 'Clear Plugin Search'],+ ['skills', 'Search skills', 'Clear skill search'],+ ] as const)(+ 'provides accessible search defaults for the %s tab',+ (activeTab, searchLabel, clearLabel) => {+ render(+ <MemoryRouter>+ <PluginManagementLayout activeTab={activeTab} query="calendar" onQueryChange={vi.fn()}>+ <span>Content</span>+ </PluginManagementLayout>+ </MemoryRouter>,+ );++ expect(screen.getByRole('textbox', { name: searchLabel })).toBeTruthy();+ expect(screen.getByRole('button', { name: clearLabel })).toBeTruthy();+ },+ );++ it('keeps search directly editable and blurs an empty search with Escape', async () => {+ render(+ <MemoryRouter>+ <PluginManagementLayout+ activeTab="skills"+ query=""+ onQueryChange={vi.fn()}+ searchPlaceholder="Search skills"+ clearSearchLabel="Clear skill search"+ >+ <span>Content</span>+ </PluginManagementLayout>+ </MemoryRouter>,+ );++ const searchInput = screen.getByRole('textbox', { name: 'Search skills' });+ const searchControl = searchInput.parentElement;+ const searchLabel = searchControl?.querySelector(+ 'label[for="plugin-management-skills-search"]',+ );++ expect(searchControl?.getAttribute('data-expanded')).toBeNull();+ expect(searchLabel).toBeTruthy();+ expect(screen.queryByRole('button', { name: 'Search skills' })).toBeNull();+ searchInput.focus();+ await waitFor(() => expect(document.activeElement).toBe(searchInput));++ fireEvent.keyDown(searchInput, { key: 'Escape' });+ expect(document.activeElement).not.toBe(searchInput);+ });++ it('leaves the search query and focus intact when IME handles Escape', () => {+ const onQueryChange = vi.fn();+ render(+ <MemoryRouter>+ <PluginManagementLayout activeTab="skills" query="calendar" onQueryChange={onQueryChange}>+ <span>Content</span>+ </PluginManagementLayout>+ </MemoryRouter>,+ );++ const searchInput = screen.getByRole('textbox', { name: 'Search skills' });+ searchInput.focus();+ fireEvent.keyDown(searchInput, { key: 'Escape', isComposing: true });++ expect(onQueryChange).not.toHaveBeenCalled();+ expect(document.activeElement).toBe(searchInput);+ });++ it('matches DOM focus order to the stacked visual rows', async () => {+ vi.stubGlobal(+ 'ResizeObserver',+ class {+ readonly callback: ResizeObserverCallback;++ constructor(callback: ResizeObserverCallback) {+ this.callback = callback;+ }++ observe() {+ this.callback(+ [{ contentRect: { width: 700 } } as ResizeObserverEntry],+ this as unknown as ResizeObserver,+ );+ }++ unobserve() {}+ disconnect() {}+ },+ );++ const { container } = render(+ <MemoryRouter>+ <PluginManagementLayout+ activeTab="plugins"+ query=""+ onQueryChange={vi.fn()}+ headerActions={<button type="button">Add plugin</button>}+ >+ <span>Content</span>+ </PluginManagementLayout>+ </MemoryRouter>,+ );++ await waitFor(() => {+ const focusable = [...container.querySelectorAll('input, button')];+ expect(+ focusable.indexOf(screen.getByRole('textbox', { name: 'Search plugins' })),+ ).toBeLessThan(focusable.indexOf(screen.getByRole('tab', { name: 'Plugins' })));+ expect(focusable.indexOf(screen.getByRole('button', { name: 'Add plugin' }))).toBeLessThan(+ focusable.indexOf(screen.getByRole('tab', { name: 'Plugins' })),+ );+ });+ });++ it('preserves focused controls while reordering rows across the stacked breakpoint', async () => {+ let resizeCallback: ResizeObserverCallback | null = null;+ vi.stubGlobal(+ 'ResizeObserver',+ class {+ constructor(callback: ResizeObserverCallback) {+ resizeCallback = callback;+ }++ observe() {+ resizeCallback?.(+ [{ contentRect: { width: 800 } } as ResizeObserverEntry],+ this as unknown as ResizeObserver,+ );+ }++ unobserve() {}+ disconnect() {}+ },+ );++ render(+ <MemoryRouter>+ <PluginManagementLayout+ activeTab="plugins"+ query=""+ onQueryChange={vi.fn()}+ headerActions={<button type="button">Add plugin</button>}+ >+ <span>Content</span>+ </PluginManagementLayout>+ </MemoryRouter>,+ );++ const search = screen.getByRole('textbox', { name: 'Search plugins' });+ search.focus();+ act(() => {+ resizeCallback?.(+ [{ contentRect: { width: 700 } } as ResizeObserverEntry],+ {} as ResizeObserver,+ );+ });+ await waitFor(() => expect(document.activeElement).toBe(search));+ expect(screen.getByRole('textbox', { name: 'Search plugins' })).toBe(search);++ const pluginsTab = screen.getByRole('tab', { name: 'Plugins' });+ pluginsTab.focus();+ act(() => {+ resizeCallback?.(+ [{ contentRect: { width: 800 } } as ResizeObserverEntry],+ {} as ResizeObserver,+ );+ });+ await waitFor(() => expect(document.activeElement).toBe(pluginsTab));+ expect(screen.getByRole('tab', { name: 'Plugins' })).toBe(pluginsTab);+ });});diff --git a/apps/desktop/src/renderer/features/plugin/plugin-motion.css b/apps/desktop/src/renderer/features/plugin/plugin-motion.cssindex efbb619c2e..634cc5f711 100644--- a/apps/desktop/src/renderer/features/plugin/plugin-motion.css+++ b/apps/desktop/src/renderer/features/plugin/plugin-motion.css@@ -95,22 +95,116 @@animation: plugin-selection-settle var(--plugin-motion-state) var(--plugin-motion-ease-enter);}-/* The detail hero collapses from the actual page column width, not the window width. */+/* Catalog chrome responds to the actual main pane, including when the sidebar stays open. */+.plugin-management-layout-root {+ container: plugin-management / inline-size;+}+.plugin-detail-frame {- container-type: inline-size;+ container: plugin-detail / inline-size;+}++.cindy-capability-prefs {+ container: cindy-capability / inline-size;+}++@container cindy-capability (max-width: 520px) {+ .cindy-capability-prefs .cindy-capability-row {+ align-items: stretch;+ flex-direction: column;+ gap: 0.5rem;+ }++ .cindy-capability-prefs .cindy-capability-select {+ width: 100%;+ max-width: none;+ }+}++@container plugin-detail (max-width: 420px) {+ .plugin-detail-frame .plugin-detail-metadata {+ display: none;+ }+}++@container plugin-detail (min-width: 600px) {+ .plugin-detail-frame .plugin-detail-hero {+ gap: 1.25rem;+ }++ .plugin-detail-frame .plugin-detail-actions {+ gap: 0.75rem;+ }++ .plugin-detail-frame .plugin-detail-primary-action {+ padding-inline: 1.25rem;+ }}-@container (max-width: 759px) {- .plugin-detail-hero {- grid-template-columns: 64px minmax(0, 1fr);+@container plugin-management (max-width: 720px) {+ .plugin-management-layout-root .plugin-catalog-toolbar {+ align-items: stretch;+ flex-direction: column;+ gap: 0.75rem;}- .plugin-detail-actions {- grid-column: 1 / -1;+ .plugin-management-layout-root .plugin-catalog-filters {+ width: 100%;justify-content: space-between;- margin-top: 1rem;+ gap: 0.125rem;+ }++ .plugin-management-layout-root .plugin-catalog-filters > button {+ padding-inline: 0.5rem;+ }++ .plugin-management-layout-root .plugin-management-header {+ height: 7rem;+ }++ .plugin-management-layout-root .plugin-management-header-frame {+ display: grid;+ grid-template-areas:+ 'tools'+ 'tabs';+ grid-template-columns: minmax(0, 1fr);+ grid-template-rows: 2.25rem 2.25rem;+ align-content: center;+ column-gap: 0;+ row-gap: 0.5rem;+ }++ .plugin-management-layout-root .plugin-motion-tabs {+ grid-area: tabs;+ width: 100%;+ }++ .plugin-management-layout-root .plugin-management-tab {+ min-width: 0;+ flex: 1 1 0%;+ }++ .plugin-management-layout-root .plugin-management-tools {+ grid-area: tools;width: 100%;}++ .plugin-management-layout-root .plugin-management-search-control {+ min-width: 0;+ max-width: none;+ flex: 1 1 auto;+ }++ .plugin-management-layout-root .plugin-management-action-trigger {+ width: 2.25rem;+ padding-inline: 0;+ justify-content: center;+ }++ .plugin-management-layout-root+ :is(.plugin-management-action-label, .plugin-management-action-chevron) {+ display: none;+ }}@media (max-width: 767px) {diff --git a/apps/desktop/src/renderer/features/skillhub/SkillhubHomeView.tsx b/apps/desktop/src/renderer/features/skillhub/SkillhubHomeView.tsxindex 3e17c2aaff..a213cf6eb8 100644--- a/apps/desktop/src/renderer/features/skillhub/SkillhubHomeView.tsx+++ b/apps/desktop/src/renderer/features/skillhub/SkillhubHomeView.tsx@@ -25,6 +25,7 @@ import {import { cn } from '@/lib/utils';import { useAuth } from '@/contexts/AuthContext';import {+ PLUGIN_MANAGEMENT_CARD_GRID_CLASS,PluginManagementLayout,PluginManagementPage,} from '@/features/plugin/PluginManagementLayout';@@ -173,7 +174,9 @@ export function SkillhubHomeView() {</h1><p className="mt-2 max-w-2xl text-14 leading-6 text-[var(--text-secondary)]">{t(- marketAllowed ? 'skillhub.home.description' : 'skillhub.home.descriptionLocalOnly',+ marketAllowed+ ? 'skillhub.home.description'+ : 'skillhub.home.descriptionLocalOnly',)}</p></div>@@ -220,10 +223,7 @@ export function SkillhubHomeView() {/>{marketLoading && recommended.length === 0 ? (// 占位骨架:与真实卡片同栅格、同行数、同高度,内容到位后原地替换不跳动。- <div- className="grid grid-cols-[repeat(auto-fill,minmax(360px,1fr))] gap-3"- aria-hidden- >+ <div className={PLUGIN_MANAGEMENT_CARD_GRID_CLASS} aria-hidden>{Array.from({ length: RECOMMENDED_LIMIT }).map((_, i) => (<divkey={i}@@ -241,7 +241,7 @@ export function SkillhubHomeView() {{t('skillhub.home.recommendedEmpty')}</div>) : (- <div className="plugin-motion-stagger grid grid-cols-[repeat(auto-fill,minmax(360px,1fr))] gap-3">+ <div className={cn('plugin-motion-stagger', PLUGIN_MANAGEMENT_CARD_GRID_CLASS)}>{recommended.map((s) => (<buttonkey={s.name}@@ -385,7 +385,7 @@ function LocalGroup({return (<div className="flex flex-col gap-3"><span className="px-1 text-13 font-medium text-[var(--text-secondary)]">{label}</span>- <div className="plugin-motion-stagger grid grid-cols-1 gap-3 md:grid-cols-2">+ <div className={cn('plugin-motion-stagger', PLUGIN_MANAGEMENT_CARD_GRID_CLASS)}>{skills.map((s) => {const Icon = KIND_ICON[s.kind] ?? Package;// 来源:'skillhub' = 从市场安装的副本(填充徽标);'local' = 自己开发/发布、