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。

fix(plugin): 右列空白点击也进入插件详情

Dash97865a9122d2
diff --git a/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx b/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx
index cf216c91c9..89aa0208e0 100644
--- a/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx
+++ b/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx
@@ -2177,17 +2177,13 @@ export function GhostPluginCard({
{unreadSummary || item.description || item.id}
</span>
</span>
- {/* 右列控制区:自行消费点击,不冒泡到整卡主动作(纯冒泡拦截层,无独立语义)。 */}
- <span
- className="flex shrink-0 flex-col items-end justify-between gap-2 self-stretch"
- onClick={(event) => event.stopPropagation()}
- onKeyDown={(event) => event.stopPropagation()}
- >
+ {/* 右列只在真实控件上拦截冒泡;空白与「由 Agent 调用」提示仍走整卡进详情。 */}
+ <span className="flex shrink-0 flex-col items-end justify-between gap-2 self-stretch">
<span className="flex items-center gap-1.5">
{updateVersion && onUpdate ? (
<button
type="button"
- onClick={onUpdate}
+ onClick={stopAnd(onUpdate)}
disabled={updateBusy}
aria-label={t('settings.ghosts.page.updateAria', {
name: item.name,
@@ -2206,7 +2202,7 @@ export function GhostPluginCard({
) : null}
<button
type="button"
- onClick={onManage}
+ onClick={stopAnd(onManage)}
aria-label={t('settings.ghosts.page.manageAria', { name: item.name })}
title={t('settings.ghosts.page.manageAction')}
className="grid size-7 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)]"
@@ -2220,6 +2216,13 @@ export function GhostPluginCard({
);
}
+function stopAnd(handler: () => void) {
+ return (event: { stopPropagation: () => void }) => {
+ event.stopPropagation();
+ handler();
+ };
+}
+
function CardPillButton({
onClick,
label,
@@ -2234,7 +2237,7 @@ function CardPillButton({
return (
<button
type="button"
- onClick={onClick}
+ onClick={stopAnd(onClick)}
aria-label={ariaLabel ?? label}
className={cn(
'inline-flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-full bg-[var(--surface-chip)] px-3.5 text-12 font-medium text-[var(--text-primary)]',
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 ad8ebb68a2..50b5ceb5c7 100644
--- a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsx
+++ b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsx
@@ -317,6 +317,27 @@ describe('GhostPluginCard', () => {
expect(onPrimary).not.toHaveBeenCalled();
});
+ it('opens details from the non-interactive agent-invoked hint', () => {
+ const onPrimary = vi.fn();
+ const onManage = vi.fn();
+ render(<GhostPluginCard item={toolPlugin} onPrimary={onPrimary} onManage={onManage} />);
+
+ fireEvent.click(screen.getByText('settings.ghosts.page.agentInvoked'));
+ expect(onManage).toHaveBeenCalledTimes(1);
+ expect(onPrimary).not.toHaveBeenCalled();
+ });
+
+ it('opens details from empty space in the right action rail', () => {
+ const onPrimary = vi.fn();
+ const onManage = vi.fn();
+ render(<GhostPluginCard item={commandPlugin} onPrimary={onPrimary} onManage={onManage} />);
+
+ const manage = screen.getByRole('button', { name: 'settings.ghosts.page.manageAria' });
+ fireEvent.click(manage.parentElement as HTMLElement);
+ expect(onManage).toHaveBeenCalledTimes(1);
+ expect(onPrimary).not.toHaveBeenCalled();
+ });
+
it('sends a disabled plugin to manage and shows no enable switch on the card', () => {
const onPrimary = vi.fn();
const onManage = vi.fn();