Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

feat(plugin): 已安装插件卡片点击默认进入详情

Dashde548b006e5a
diff --git a/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx b/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx
index 9058a7cbb2..cf216c91c9 100644
--- a/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx
+++ b/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx
@@ -1081,7 +1081,7 @@ export function GhostPluginPage() {
[confirm, ghosts, navigate, openGhostConfiguration, t],
);
- /** 卡片/详情主动作分发:面板型开页面内面板,指令/Host 能力型起对话,工具型进管理。 */
+ /** 卡片胶囊/详情主动作分发:面板型开页面内面板,指令/Host 能力型起对话,工具型进管理。整卡点击不走这里。 */
const handlePrimaryAction = useCallback(
(item: Pick<GhostPluginListItem, 'id' | 'name' | 'tabPanel' | 'canUse' | 'hostCapability'>) => {
const action = ghostPrimaryAction(item);
@@ -2048,7 +2048,8 @@ function GhostPluginActions({
/**
* 已安装插件卡片(设计定稿):
- * - 整卡可点 = 主动作(面板「使用」/ 指令「对话」/ 工具型与停用态进管理);
+ * - 整卡可点 = 进详情(与滑杆管理入口同目标);
+ * - 主动作留在右下角胶囊(面板「使用」/ 指令或能力「对话」/ 工具型无按钮);
* - 无启用开关(收进详情页);滑杆图标 = 管理入口;
* - 更新 = 文字胶囊「更新到 vX」,无任何小圆点(绿点专职未读语义,PR-B 接入)。
*/
@@ -2081,12 +2082,11 @@ export function GhostPluginCard({
const unread = useGhostUnread(item.id);
const unreadSummary = useGhostUnreadSummary(item.id);
const primary = ghostPrimaryAction(item);
- const cardAction = enabled && primary !== 'manage' ? onPrimary : onManage;
const handleCardKeyDown = (event: KeyboardEvent<HTMLElement>) => {
if (event.target !== event.currentTarget) return;
if (event.key !== 'Enter' && event.key !== ' ') return;
event.preventDefault();
- cardAction();
+ onManage();
};
let primaryControl: ReactNode;
if (!enabled) {
@@ -2122,7 +2122,7 @@ export function GhostPluginCard({
<article
role="button"
tabIndex={0}
- onClick={cardAction}
+ onClick={onManage}
onKeyDown={handleCardKeyDown}
aria-label={item.name}
className={cn(
diff --git a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsx b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsx
index 49cce776d7..d1135834af 100644
--- a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsx
+++ b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsx
@@ -1,6 +1,6 @@
/**
* Regression coverage for installed Plugin card actions (redesigned card:
- * whole-card primary action, kind-specific primary button, manage entry),
+ * whole-card opens detail, kind-specific primary button, manage entry),
* market card actions, and the legacy recovery notice.
* [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md
* @vitest-environment jsdom
@@ -160,32 +160,56 @@ describe('GhostPluginCard', () => {
// 未读是模块级 store,用例间必须互不串味。
afterEach(() => __resetGhostUnreadForTest());
- it('fires the primary action from the whole card for a command plugin', () => {
+ it('opens plugin details from the whole card for a command plugin', () => {
const onPrimary = vi.fn();
const onManage = vi.fn();
render(<GhostPluginCard item={commandPlugin} onPrimary={onPrimary} onManage={onManage} />);
fireEvent.click(screen.getByRole('button', { name: 'Filo Google' }));
+ expect(onManage).toHaveBeenCalledTimes(1);
+ expect(onPrimary).not.toHaveBeenCalled();
+ // 指令型主按钮仍是「对话」,不随整卡改成详情。
+ expect(screen.getByRole('button', { name: 'settings.ghosts.page.chatAria' })).toBeTruthy();
+ });
+
+ it('keeps the conversation pill as the command plugin primary action', () => {
+ const onPrimary = vi.fn();
+ const onManage = vi.fn();
+ render(<GhostPluginCard item={commandPlugin} onPrimary={onPrimary} onManage={onManage} />);
+
+ fireEvent.click(screen.getByRole('button', { name: 'settings.ghosts.page.chatAria' }));
expect(onPrimary).toHaveBeenCalledTimes(1);
expect(onManage).not.toHaveBeenCalled();
- // 指令型主按钮 = 「对话」。
- expect(screen.getByRole('button', { name: 'settings.ghosts.page.chatAria' })).toBeTruthy();
});
it('labels the primary button 使用 for a tab-panel plugin', () => {
const onPrimary = vi.fn();
- render(<GhostPluginCard item={panelPlugin} onPrimary={onPrimary} onManage={vi.fn()} />);
+ const onManage = vi.fn();
+ render(<GhostPluginCard item={panelPlugin} onPrimary={onPrimary} onManage={onManage} />);
fireEvent.click(screen.getByRole('button', { name: 'settings.ghosts.page.useAria' }));
expect(onPrimary).toHaveBeenCalledTimes(1);
+ expect(onManage).not.toHaveBeenCalled();
+ });
+
+ it('opens plugin details from the whole card for a tab-panel plugin', () => {
+ const onPrimary = vi.fn();
+ const onManage = vi.fn();
+ render(<GhostPluginCard item={panelPlugin} onPrimary={onPrimary} onManage={onManage} />);
+
+ fireEvent.click(screen.getByRole('button', { name: 'Signoff Board' }));
+ expect(onManage).toHaveBeenCalledTimes(1);
+ expect(onPrimary).not.toHaveBeenCalled();
});
it('offers a conversation entry for a Host capability plugin', () => {
const onPrimary = vi.fn();
- render(<GhostPluginCard item={simulatorPlugin} onPrimary={onPrimary} onManage={vi.fn()} />);
+ const onManage = vi.fn();
+ render(<GhostPluginCard item={simulatorPlugin} onPrimary={onPrimary} onManage={onManage} />);
fireEvent.click(screen.getByRole('button', { name: 'settings.ghosts.page.chatAria' }));
expect(onPrimary).toHaveBeenCalledTimes(1);
+ expect(onManage).not.toHaveBeenCalled();
expect(screen.queryByText('settings.ghosts.page.agentInvoked')).toBeNull();
});
@@ -201,13 +225,14 @@ describe('GhostPluginCard', () => {
it('shows the update pill and keeps it from triggering the card action', () => {
const onPrimary = vi.fn();
+ const onManage = vi.fn();
const onUpdate = vi.fn();
render(
<GhostPluginCard
item={commandPlugin}
updateVersion="1.1.0"
onPrimary={onPrimary}
- onManage={vi.fn()}
+ onManage={onManage}
onUpdate={onUpdate}
/>,
);
@@ -215,6 +240,7 @@ describe('GhostPluginCard', () => {
fireEvent.click(screen.getByRole('button', { name: 'settings.ghosts.page.updateAria' }));
expect(onUpdate).toHaveBeenCalledTimes(1);
expect(onPrimary).not.toHaveBeenCalled();
+ expect(onManage).not.toHaveBeenCalled();
// 有更新时不显示「已是最新」。
expect(screen.queryByText(/upToDate/)).toBeNull();
});
diff --git a/apps/desktop/src/renderer/features/plugin/lib/ghostPluginViewModel.ts b/apps/desktop/src/renderer/features/plugin/lib/ghostPluginViewModel.ts
index 6b518c830f..13ee3340e4 100644
--- a/apps/desktop/src/renderer/features/plugin/lib/ghostPluginViewModel.ts
+++ b/apps/desktop/src/renderer/features/plugin/lib/ghostPluginViewModel.ts
@@ -52,11 +52,11 @@ export interface GhostPluginListItem {
}
/**
- * 卡片主动作的四分法:
+ * 卡片主动作的四分法(只驱动右下角胶囊;整卡点击一律进详情):
* - `panel`:有页签面板 → 「使用」直接打开面板;
* - `command`:只有 $指令 → 「对话」把指令插进输入框起话题;
* - `capability`:Host 承载的能力 → 「对话」进入该能力的工作流;
- * - `manage`:纯工具型(Agent 对话中自动调用)→ 无主按钮,点卡片进管理页。
+ * - `manage`:纯工具型(Agent 对话中自动调用)→ 无主按钮。
* 停靠形态(left/right)的面板由布局树承载,不算 panel 主动作。
*/
export type GhostPrimaryAction = 'panel' | 'command' | 'capability' | 'manage';