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(desktop): 更新确认框工具 diff 折叠、滚动条提示与限高收口

Lizidc9236964f75
diff --git a/apps/desktop/src/renderer/cindy-brain/GhostPermissionList.tsx b/apps/desktop/src/renderer/cindy-brain/GhostPermissionList.tsx
index 41a01a7c17..beffb26641 100644
--- a/apps/desktop/src/renderer/cindy-brain/GhostPermissionList.tsx
+++ b/apps/desktop/src/renderer/cindy-brain/GhostPermissionList.tsx
@@ -31,10 +31,9 @@ import {
Wrench,
type LucideIcon,
} from 'lucide-react';
-import { useEffect, useRef, useState } from 'react';
+import { useState, type ReactNode } from 'react';
import { useTranslation } from 'react-i18next';
-import { flashScrollbar } from '@/lib/scrollbarAutoHide';
import { cn } from '@/lib/utils';
import type {
GhostPermissionDiff,
@@ -143,10 +142,21 @@ export function GhostPermissionRows({ items }: { items: GhostPermissionItem[] })
}
/**
- * 工具说明由意识作者自由填写,往往是整段接口文档。安装确认只先报工具数量,
+ * 工具说明由意识作者自由填写,往往是整段接口文档。确认框只先报工具数量,
* 用户主动展开后再显示原文,避免常规工具把真正需要留意的权限挤出屏幕。
+ *
+ * 装入(全量清单)与更新(权限 diff)共用这一个折叠壳:标题 key 与计数由调用方给,
+ * 行本身作为 children 传入 —— 更新分支的行带 added/removed 徽章,装入分支不带。
*/
-function GhostToolPermissionGroup({ items }: { items: GhostPermissionItem[] }) {
+function GhostToolPermissionGroup({
+ titleKey,
+ count,
+ children,
+}: {
+ titleKey: 'toolsGroup' | 'toolsDiffGroup';
+ count: number;
+ children: ReactNode;
+}) {
const { t } = useTranslation();
const [expanded, setExpanded] = useState(false);
@@ -159,9 +169,9 @@ function GhostToolPermissionGroup({ items }: { items: GhostPermissionItem[] }) {
className="flex w-full items-center gap-2 px-3 py-2.5 text-left text-13 text-[var(--confirm-desc)]"
>
<Wrench size={14} className="shrink-0 text-[var(--text-tertiary)]" />
- <span className="flex-1">{t('settings.ghosts.perm.toolsGroup')}</span>
+ <span className="flex-1">{t(`settings.ghosts.perm.${titleKey}`)}</span>
<span className="rounded-full bg-[var(--surface-chip)] px-2 py-0.5 text-11 text-[var(--text-secondary)]">
- {t('settings.ghosts.perm.itemCount', { count: items.length })}
+ {t('settings.ghosts.perm.itemCount', { count })}
</span>
<ChevronDown
size={14}
@@ -172,9 +182,7 @@ function GhostToolPermissionGroup({ items }: { items: GhostPermissionItem[] }) {
/>
</button>
{expanded && (
- <div className="border-t border-[var(--border-default)] px-3 py-2">
- <GhostPermissionRows items={items} />
- </div>
+ <div className="border-t border-[var(--border-default)] px-3 py-2">{children}</div>
)}
</div>
);
@@ -200,7 +208,11 @@ export function GhostPermissionList({ items }: { items: GhostPermissionItem[] })
<span>{t('settings.ghosts.perm.itemCount', { count: items.length })}</span>
</div>
<GhostPermissionRows items={beforeTools} />
- {toolItems.length > 0 && <GhostToolPermissionGroup items={toolItems} />}
+ {toolItems.length > 0 && (
+ <GhostToolPermissionGroup titleKey="toolsGroup" count={toolItems.length}>
+ <GhostPermissionRows items={toolItems} />
+ </GhostToolPermissionGroup>
+ )}
<GhostPermissionRows items={afterTools} />
</div>
);
@@ -243,8 +255,13 @@ export function GhostTrustSummary({ trust }: { trust: GhostTrustInfo }) {
}
/**
- * 安装确认的紧凑内容区:简介可折叠,作者/版本单列,详情只在弹窗内部滚动。
+ * 安装确认的紧凑内容区:简介可折叠,作者/版本单列。
* 安全相关权限不做总折叠,避免为了短而牺牲知情确认。
+ *
+ * 限高与滚动不在这里:共享 ConfirmDialog 已经持有 max-h-[85vh] + 内部滚动区,
+ * 并在弹窗出现/内容变高时闪一下滚动条。本组件曾自带 min(56vh, 520px) 滚动容器,
+ * 那会与共享层套成两层限高(2026-07-27 收口删除)——只留一个滚动主体,
+ * "还能往下看"这件事才有唯一口径。
*/
export function GhostInstallReview({
description,
@@ -259,27 +276,12 @@ export function GhostInstallReview({
}) {
const { t } = useTranslation();
const [descriptionExpanded, setDescriptionExpanded] = useState(false);
- const scrollRef = useRef<HTMLDivElement>(null);
const canCollapseDescription = Boolean(
description && (description.length > 160 || description.includes('\n')),
);
- const revealScrollbar = () => {
- requestAnimationFrame(() => {
- if (scrollRef.current) flashScrollbar(scrollRef.current);
- });
- };
-
- // 初次出现以及展开介绍/工具后都短暂亮出滚动条,明确告诉用户内容还能往下看。
- useEffect(revealScrollbar, []);
-
return (
- <div
- ref={scrollRef}
- className="overflow-y-auto overscroll-contain pr-1"
- style={{ maxHeight: 'min(56vh, 520px)', scrollbarGutter: 'stable' }}
- onClickCapture={revealScrollbar}
- >
+ <div>
{description && (
<div>
<p
@@ -317,7 +319,15 @@ export function GhostInstallReview({
);
}
-/** 更新确认:只展示权限变化(新增/移除),不变项折叠成一行计数。 */
+/**
+ * 更新确认:只展示权限变化(新增/移除),不变项折叠成一行计数。
+ *
+ * 工具行再折一层。原因是 diffGhostPermissionItems 会比对同一 key 的 detail:
+ * 作者只重写了工具说明,也算「移除旧行 + 新增新行」,N 个工具就产出 2N 行、
+ * 每行一整段接口文档。真正该被看见的权限变化(新增网络域名、新增凭证等)会被
+ * 顶到滚动区最上面、需要滚过一屏文档。所以 kind === 'tool' 的变化收进折叠组
+ * 只报数量,非 tool 的敏感变化仍旧直接亮出来。
+ */
export function GhostPermissionDiffView({ diff }: { diff: GhostPermissionDiff }) {
const { t } = useTranslation();
const changed = diff.added.length > 0 || diff.removed.length > 0;
@@ -328,14 +338,30 @@ export function GhostPermissionDiffView({ diff }: { diff: GhostPermissionDiff })
</div>
);
}
+ const isTool = (item: GhostPermissionItem) => item.kind === 'tool';
+ const addedSensitive = diff.added.filter((item) => !isTool(item));
+ const removedSensitive = diff.removed.filter((item) => !isTool(item));
+ const addedTools = diff.added.filter(isTool);
+ const removedTools = diff.removed.filter(isTool);
+ const toolChangeCount = addedTools.length + removedTools.length;
return (
<div>
- {diff.added.map((item) => (
+ {addedSensitive.map((item) => (
<PermRow key={`added:${item.key}`} item={item} badge="added" />
))}
- {diff.removed.map((item) => (
+ {removedSensitive.map((item) => (
<PermRow key={`removed:${item.key}`} item={item} badge="removed" />
))}
+ {toolChangeCount > 0 && (
+ <GhostToolPermissionGroup titleKey="toolsDiffGroup" count={toolChangeCount}>
+ {addedTools.map((item) => (
+ <PermRow key={`added:${item.key}`} item={item} badge="added" />
+ ))}
+ {removedTools.map((item) => (
+ <PermRow key={`removed:${item.key}`} item={item} badge="removed" />
+ ))}
+ </GhostToolPermissionGroup>
+ )}
{diff.unchanged.length > 0 && (
<div className="mt-1 text-12 text-[var(--text-tertiary)]">
{t('settings.ghosts.perm.unchanged', { count: diff.unchanged.length })}
@@ -344,3 +370,31 @@ export function GhostPermissionDiffView({ diff }: { diff: GhostPermissionDiff })
</div>
);
}
+
+/**
+ * 更新确认的内容区:来源/签名摘要(可选)+ 权限 diff。
+ *
+ * 更新确认有两个入口 —— 本地 .cindy 换版走 installFlow.confirmAndRunUpdate,
+ * 市场更新走 GhostPluginPage.handleMarketUpdate。此前两边各写一遍 content,
+ * 市场那条还漏了 trust 卡。收成一个组件后,内容层的调整(如上面的工具折叠)
+ * 只改一处,不会再出现"第三个入口又漏一次"。
+ *
+ * trust 可选:市场路径当前拿不到与本地包同口径的 GhostTrustInfo,不传即不渲染
+ * 来源卡 —— 不许诺自己没验过的来源,也不拿假数据占位。
+ */
+export function GhostUpdateReview({
+ trust,
+ diff,
+}: {
+ trust?: GhostTrustInfo;
+ diff: GhostPermissionDiff;
+}) {
+ return (
+ <div>
+ {trust && <GhostTrustSummary trust={trust} />}
+ <div className={cn(trust && 'mt-3')}>
+ <GhostPermissionDiffView diff={diff} />
+ </div>
+ </div>
+ );
+}
diff --git a/apps/desktop/src/renderer/cindy-brain/__tests__/GhostPermissionList.test.tsx b/apps/desktop/src/renderer/cindy-brain/__tests__/GhostPermissionList.test.tsx
index f5a38ede40..7ca1165802 100644
--- a/apps/desktop/src/renderer/cindy-brain/__tests__/GhostPermissionList.test.tsx
+++ b/apps/desktop/src/renderer/cindy-brain/__tests__/GhostPermissionList.test.tsx
@@ -14,6 +14,7 @@ import {
GhostInstallReview,
GhostPermissionDiffView,
GhostPermissionList,
+ GhostUpdateReview,
} from '../GhostPermissionList';
// 仓库同款 i18n mock:t 返回 key 本身(带参时拼上参数便于断言)。
@@ -75,9 +76,11 @@ describe('GhostPermissionList(装入全量清单)', () => {
items={[]}
/>,
);
- const scrollArea = container.firstElementChild as HTMLElement;
- expect(scrollArea.classList.contains('overflow-y-auto')).toBe(true);
- expect(scrollArea.style.maxHeight).toBe('min(56vh, 520px)');
+ // 限高与滚动由共享 ConfirmDialog 持有,本组件不许再自套一层滚动容器
+ // (两层限高 → "到底了没有"取决于谁先触底)。
+ const root = container.firstElementChild as HTMLElement;
+ expect(root.classList.contains('overflow-y-auto')).toBe(false);
+ expect(root.style.maxHeight).toBe('');
const trigger = screen.getByRole('button', { expanded: false });
expect(trigger.textContent).toBe('settings.ghosts.installConfirm.expandDescription');
fireEvent.click(trigger);
@@ -143,7 +146,7 @@ describe('GhostPermissionList(装入全量清单)', () => {
});
describe('GhostPermissionDiffView(更新权限 diff)', () => {
- it('只亮变化项:新增/移除带徽章,不变项折叠成计数行', () => {
+ it('只亮变化项:非工具变化直接带徽章,工具变化折叠计数,不变项折叠成计数行', () => {
const next: GhostManifest = {
...chip(),
version: '2.0.0',
@@ -151,15 +154,54 @@ describe('GhostPermissionDiffView(更新权限 diff)', () => {
tools: [...(chip().tools ?? []), { name: 'style_image', description: '风格化' }], // 新增
};
render(<GhostPermissionDiffView diff={diffGhostPermissionItems(chip(), next)} />);
- expect(screen.getByText(/perm\.tool:.*style_image/)).toBeTruthy();
- expect(screen.getByText('settings.ghosts.perm.added')).toBeTruthy();
+ // 非工具的敏感变化直接亮出来。
expect(screen.getByText('settings.ghosts.perm.cindyImageEdit')).toBeTruthy();
expect(screen.getByText('settings.ghosts.perm.removed')).toBeTruthy();
+ // 工具变化只报数量,原文要展开才看;新增徽章跟着行进折叠区。
+ expect(screen.getByText('settings.ghosts.perm.toolsDiffGroup')).toBeTruthy();
+ expect(screen.getByText(/perm\.itemCount:.*"count":1/)).toBeTruthy();
+ expect(screen.queryByText(/perm\.tool:.*style_image/)).toBeNull();
+ expect(screen.queryByText('settings.ghosts.perm.added')).toBeNull();
+ fireEvent.click(screen.getByRole('button', { expanded: false }));
+ expect(screen.getByText(/perm\.tool:.*style_image/)).toBeTruthy();
+ expect(screen.getByText('settings.ghosts.perm.added')).toBeTruthy();
expect(screen.getByText(/perm\.unchanged:.*"count":5/)).toBeTruthy();
// 不变项本体不渲染(折叠):cindyImageGenerate 不该出现在行里。
expect(screen.queryByText('settings.ghosts.perm.cindyImageGenerate')).toBeNull();
});
+ it('只改了工具说明时,2N 条工具行全部收进折叠区,不挤走真正的权限变化', () => {
+ const prev: GhostManifest = {
+ ...chip(),
+ tools: [
+ { name: 'gen_image', description: '旧说明 A' },
+ { name: 'style_image', description: '旧说明 B' },
+ ],
+ };
+ const next: GhostManifest = {
+ ...prev,
+ version: '2.0.0',
+ // 工具说明重写 → diff 记成「移除旧行 + 新增新行」,2 个工具产出 4 行。
+ tools: [
+ { name: 'gen_image', description: '新说明 A(整段接口文档)' },
+ { name: 'style_image', description: '新说明 B(整段接口文档)' },
+ ],
+ slots: [...prev.slots, 'network'],
+ network: { hosts: ['api.example.com'] },
+ };
+ render(<GhostPermissionDiffView diff={diffGhostPermissionItems(prev, next)} />);
+ // 真正的权限变化(新增网络域名)仍在折叠区之外,第一屏就能看到。
+ expect(screen.getByText(/perm\.networkHost:.*api\.example\.com/)).toBeTruthy();
+ expect(screen.getByText('settings.ghosts.perm.added')).toBeTruthy();
+ // 4 条工具行收进一个折叠组,原文默认不渲染。
+ expect(screen.getByText(/perm\.itemCount:.*"count":4/)).toBeTruthy();
+ expect(screen.queryByText('新说明 A(整段接口文档)')).toBeNull();
+ expect(screen.queryByText('旧说明 B')).toBeNull();
+ fireEvent.click(screen.getByRole('button', { expanded: false }));
+ expect(screen.getByText('新说明 A(整段接口文档)')).toBeTruthy();
+ expect(screen.getByText('旧说明 B')).toBeTruthy();
+ });
+
it('权限无变化 → 单行收敛文案,无任何条目', () => {
render(
<GhostPermissionDiffView
@@ -171,3 +213,42 @@ describe('GhostPermissionDiffView(更新权限 diff)', () => {
expect(screen.queryByText('settings.ghosts.perm.unchanged', { exact: false })).toBeNull();
});
});
+
+describe('GhostUpdateReview(更新确认内容区,两个入口共用)', () => {
+ const next = (): GhostManifest => ({
+ ...chip(),
+ version: '2.0.0',
+ slots: [...chip().slots, 'network'],
+ network: { hosts: ['api.example.com'] },
+ });
+
+ it('传了 trust 就渲染来源卡,并与 diff 同时展示', () => {
+ render(
+ <GhostUpdateReview
+ trust={{
+ level: 'unverified',
+ publisherSigned: false,
+ publisherVerified: false,
+ reviewed: false,
+ }}
+ diff={diffGhostPermissionItems(chip(), next())}
+ />,
+ );
+ expect(screen.getByText(/trust\.unsigned:/)).toBeTruthy(); // 带 publisher 参数的标题行
+ expect(screen.getByText('settings.ghosts.trust.unsignedDetail')).toBeTruthy();
+ expect(screen.getByText(/perm\.networkHost:.*api\.example\.com/)).toBeTruthy();
+ });
+
+ it('没有可展示的来源事实时不渲染来源卡,也不拿假数据占位', () => {
+ render(<GhostUpdateReview diff={diffGhostPermissionItems(chip(), next())} />);
+ expect(screen.queryByText(/trust\.unsigned/)).toBeNull();
+ expect(screen.queryByText(/trust\.unknownPublisher/)).toBeNull();
+ expect(screen.getByText(/perm\.networkHost:.*api\.example\.com/)).toBeTruthy();
+ });
+
+ it('不自套限高滚动区(高度归共享 ConfirmDialog)', () => {
+ const { container } = render(<GhostUpdateReview diff={diffGhostPermissionItems(chip(), next())} />);
+ const scrollers = container.querySelectorAll('.overflow-y-auto');
+ expect(scrollers.length).toBe(0);
+ });
+});
diff --git a/apps/desktop/src/renderer/cindy-brain/installFlow.tsx b/apps/desktop/src/renderer/cindy-brain/installFlow.tsx
index 8e25dc072c..fc0a5df0b3 100644
--- a/apps/desktop/src/renderer/cindy-brain/installFlow.tsx
+++ b/apps/desktop/src/renderer/cindy-brain/installFlow.tsx
@@ -12,11 +12,7 @@ import {
type InstalledGhost,
} from '../../shared/ghost';
import { openGhostTabInSidebar } from '../features/right-sidebar/lib/openGhostTabInSidebar';
-import {
- GhostInstallReview,
- GhostPermissionDiffView,
- GhostTrustSummary,
-} from './GhostPermissionList';
+import { GhostInstallReview, GhostUpdateReview } from './GhostPermissionList';
import { ghostInstallErrorKey } from './installErrorKey';
/**
@@ -102,14 +98,7 @@ async function confirmAndRunUpdate(
from: installed.manifest.version,
to: manifest.version,
}),
- content: (
- <div>
- <GhostTrustSummary trust={trust} />
- <div className="mt-3">
- <GhostPermissionDiffView diff={diff} />
- </div>
- </div>
- ),
+ content: <GhostUpdateReview trust={trust} diff={diff} />,
maxWidth: GHOST_CONFIRM_MAX_WIDTH,
confirmText: t('settings.ghosts.updateConfirm.confirm'),
cancelText: t('settings.ghosts.updateConfirm.cancel'),
diff --git a/apps/desktop/src/renderer/components/ui/__tests__/confirmDialogScroll.test.tsx b/apps/desktop/src/renderer/components/ui/__tests__/confirmDialogScroll.test.tsx
new file mode 100644
index 0000000000..06113dae25
--- /dev/null
+++ b/apps/desktop/src/renderer/components/ui/__tests__/confirmDialogScroll.test.tsx
@@ -0,0 +1,97 @@
+// @vitest-environment jsdom
+/**
+ * confirmDialogScroll.test.tsx — 共享 ConfirmDialog 的「长内容不溢出屏幕」契约。
+ *
+ * 这里锁三件事(都是授权确认框出过的真实问题):
+ * 1. 弹窗自己限高(max-h-[85vh])、标题与按钮固定,长内容在内部滚动;
+ * 2. 滚动主体只有一个 —— caller 不必也不该再套一层限高;
+ * 3. 弹窗一出现就闪一下滚动条:thumb 默认透明,不提示就等于让用户在
+ * 「还有权限没看到」的情况下点同意。
+ */
+import { cleanup, fireEvent, render, screen } from '@testing-library/react';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+
+import { ConfirmDialog } from '../confirm-dialog';
+
+vi.mock('react-i18next', () => ({
+ useTranslation: () => ({ t: (key: string) => key }),
+}));
+
+const flashScrollbar = vi.fn();
+vi.mock('@/lib/scrollbarAutoHide', () => ({
+ flashScrollbar: (el: Element) => flashScrollbar(el),
+}));
+
+afterEach(() => {
+ cleanup();
+ flashScrollbar.mockClear();
+});
+
+const longContent = (
+ <div>
+ {Array.from({ length: 40 }, (_, i) => (
+ <p key={i}>权限条目 {i}</p>
+ ))}
+ </div>
+);
+
+describe('ConfirmDialog 长内容布局', () => {
+ it('弹窗限高、按钮固定,长内容进内部滚动区', () => {
+ render(
+ <ConfirmDialog
+ open
+ onOpenChange={() => {}}
+ title="更新确认"
+ description="从 1.0.0 更新到 2.0.0"
+ content={longContent}
+ confirmText="更新"
+ />,
+ );
+ const dialog = screen.getByRole('alertdialog');
+ expect(dialog.className).toContain('max-h-[85vh]');
+ expect(dialog.className).toContain('flex-col');
+
+ const scrollers = dialog.querySelectorAll('.overflow-y-auto');
+ // 只有共享层这一个滚动主体,不出现嵌套限高。
+ expect(scrollers.length).toBe(1);
+ const scroller = scrollers[0] as HTMLElement;
+ expect(scroller.className).toContain('min-h-0');
+ expect(scroller.className).toContain('flex-1');
+ expect(scroller.textContent).toContain('权限条目 39');
+
+ // 标题与按钮行不参与压缩,内容再长也留在视口内。
+ expect(screen.getByText('更新确认').className).toContain('shrink-0');
+ const confirmBtn = screen.getByRole('button', { name: '更新' });
+ expect((confirmBtn.parentElement as HTMLElement).className).toContain('shrink-0');
+ });
+
+ it('打开时闪一下滚动条,内容里的点击(如展开折叠区)后再闪一次', async () => {
+ render(
+ <ConfirmDialog
+ open
+ onOpenChange={() => {}}
+ title="更新确认"
+ content={longContent}
+ confirmText="更新"
+ />,
+ );
+ await vi.waitFor(() => expect(flashScrollbar).toHaveBeenCalled());
+ const scroller = screen
+ .getByRole('alertdialog')
+ .querySelector('.overflow-y-auto') as HTMLElement;
+ expect(flashScrollbar.mock.calls[0][0]).toBe(scroller);
+
+ flashScrollbar.mockClear();
+ fireEvent.click(screen.getByText('权限条目 0'));
+ await vi.waitFor(() => expect(flashScrollbar).toHaveBeenCalledWith(scroller));
+ });
+
+ it('没有正文也没有富内容时不渲染滚动区(短弹窗排版不变)', () => {
+ render(
+ <ConfirmDialog open onOpenChange={() => {}} title="确定退出?" confirmText="退出" />,
+ );
+ const dialog = screen.getByRole('alertdialog');
+ expect(dialog.querySelectorAll('.overflow-y-auto').length).toBe(0);
+ expect(flashScrollbar).not.toHaveBeenCalled();
+ });
+});
diff --git a/apps/desktop/src/renderer/components/ui/confirm-dialog.tsx b/apps/desktop/src/renderer/components/ui/confirm-dialog.tsx
index 3f49808eea..6822b1ab73 100644
--- a/apps/desktop/src/renderer/components/ui/confirm-dialog.tsx
+++ b/apps/desktop/src/renderer/components/ui/confirm-dialog.tsx
@@ -2,6 +2,7 @@ import { useEffect, useRef, useState, type ReactNode } from 'react';
import * as AlertDialog from '@radix-ui/react-alert-dialog';
import { useTranslation } from 'react-i18next';
+import { flashScrollbar } from '@/lib/scrollbarAutoHide';
import { cn } from '@/lib/utils';
import { Spinner } from '@/components/ui/spinner';
@@ -15,6 +16,10 @@ export interface ConfirmDialogProps {
/**
* 富内容区(如装意识的逐项权限清单):渲染在 description 之后、复选框之前。
* 与 description 独立 —— Radix Description 是 <p>,块级列表不能塞进去。
+ *
+ * 高度与滚动由本组件统一持有(max-h-[85vh] + 内部滚动区),caller 不必也不该
+ * 再给 content 套一层自己的限高滚动容器 —— 两层限高会让"到底了没有"取决于
+ * 内外层谁先触底,行为不好解释,滚动条提示也会落在错误的那一层。
*/
content?: ReactNode;
/**
@@ -90,6 +95,24 @@ export function ConfirmDialog({
if (open) setDontShowAgain(checkboxDefaultChecked);
}, [open, checkboxDefaultChecked]);
const confirmBtnRef = useRef<HTMLButtonElement>(null);
+ const scrollRef = useRef<HTMLDivElement>(null);
+ // 滚动条 thumb 默认透明(globals.css),不滚不 hover 就看不见"下面还有内容"。
+ // 授权确认场景里这不是观感问题:权限清单被折在视口下面而用户不知道,等于
+ // 在信息不全的情况下点了同意。所以弹窗一出现就主动闪一下滚动条(不可滚则
+ // no-op),内容变高(展开简介/工具组)后再闪一次。
+ const revealScrollbar = () => {
+ requestAnimationFrame(() => {
+ if (scrollRef.current) flashScrollbar(scrollRef.current);
+ });
+ };
+ useEffect(() => {
+ if (!open) return;
+ // Radix 开场动画期间 layout 还在变,下一帧再量 scrollHeight 才准。
+ const raf = requestAnimationFrame(() => {
+ if (scrollRef.current) flashScrollbar(scrollRef.current);
+ });
+ return () => cancelAnimationFrame(raf);
+ }, [open]);
return (
<AlertDialog.Root open={open} onOpenChange={onOpenChange}>
<AlertDialog.Portal>
@@ -137,6 +160,10 @@ export function ConfirmDialog({
// 固定、中间内容纵向滚动,避免整个弹窗被撑出屏幕后无法滚动到被裁掉的内容
// (典型:插件更新确认框的权限变更清单)。
<div
+ ref={scrollRef}
+ // 内容里的折叠区(如权限清单的工具组)展开后高度会变,capture 阶段
+ // 收一次点击、下一帧重新判定是否可滚,让滚动条跟着新高度再闪一下。
+ onClickCapture={revealScrollbar}
className={cn(
'min-h-0 flex-1 overflow-y-auto overscroll-contain',
// 保持旧间距:有 description 时紧跟标题 mt-2;仅富内容(无正文)
diff --git a/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx b/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx
index 76cdb40a84..52e9c05647 100644
--- a/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx
+++ b/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx
@@ -34,7 +34,7 @@ import {
import { patchDraft } from '@/state/newMakerDraft';
import { ghostInstallErrorKey } from '@/cindy-brain/installErrorKey';
import { confirmAndInstallGhost, pickAndUpdateGhost } from '@/cindy-brain/installFlow';
-import { GhostPermissionDiffView, GhostPermissionList } from '@/cindy-brain/GhostPermissionList';
+import { GhostPermissionList, GhostUpdateReview } from '@/cindy-brain/GhostPermissionList';
import { cn } from '@/lib/utils';
import { Switch } from '@/components/ui/switch';
import { getLastWorkingDir, subscribeToLastWorkingDir } from '@/state/lastWorkingDir';
@@ -452,7 +452,7 @@ export function GhostPluginPage() {
from: installedGhost?.manifest.version ?? next.version,
to: next.version,
}),
- content: <GhostPermissionDiffView diff={diff} />,
+ content: <GhostUpdateReview diff={diff} />,
maxWidth: 520,
confirmText: t('settings.ghosts.updateConfirm.confirm'),
cancelText: t('settings.ghosts.updateConfirm.cancel'),
@@ -741,17 +741,13 @@ export function GhostPluginPage() {
description: isUpdate
? t('settings.ghosts.market.updateConfirmDescription')
: t('settings.ghosts.market.installConfirmDescription'),
- content: (
- <div
- className="overflow-y-auto overscroll-contain pr-1"
- style={{ maxHeight: 'min(56vh, 520px)', scrollbarGutter: 'stable' }}
- >
- {isUpdate ? (
- <GhostPermissionDiffView diff={diff!} />
- ) : (
- <GhostPermissionList items={ghostPermissionItems(marketDetail.manifest)} />
- )}
- </div>
+ // 限高与滚动交给共享 ConfirmDialog(max-h-[85vh] + 内部滚动区 + 打开时
+ // 闪一下滚动条),这里不再自套一层 min(56vh,520px) —— 两层限高会让
+ // "到底了没有"取决于内外层谁先触底(2026-07-27 收口)。
+ content: isUpdate ? (
+ <GhostUpdateReview diff={diff!} />
+ ) : (
+ <GhostPermissionList items={ghostPermissionItems(marketDetail.manifest)} />
),
maxWidth: 520,
confirmText: isUpdate
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index a0a93ed3f2..70adae07ad 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -2457,6 +2457,7 @@
"perm": {
"grantsTitle": "After installing it will have:",
"toolsGroup": "Registered Tools",
+ "toolsDiffGroup": "Registered Tool Changes",
"itemCount": "{{count}} total",
"cindyImageGenerate": "Image generation (delegated to Cindy)",
"cindyImageEdit": "Image editing (delegated to Cindy, its own images only)",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index fa16697199..0d6df9b04a 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -2456,6 +2456,7 @@
"perm": {
"grantsTitle": "インストール後に持つ権限:",
"toolsGroup": "登録ツール",
+ "toolsDiffGroup": "登録ツールの変更",
"itemCount": "{{count}} 件",
"cindyImageGenerate": "画像生成(Cindy に代行依頼)",
"cindyImageEdit": "画像編集(Cindy に代行依頼、自身が生成した画像のみ)",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index f6c79dcf2b..a069c9659b 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -2456,6 +2456,7 @@
"perm": {
"grantsTitle": "설치 후 갖게 되는 권한:",
"toolsGroup": "등록 도구",
+ "toolsDiffGroup": "등록 도구 변경",
"itemCount": "{{count}}개",
"cindyImageGenerate": "이미지 생성(Cindy에게 대행 요청)",
"cindyImageEdit": "이미지 편집(Cindy에게 대행 요청, 자신이 생성한 이미지만)",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index 3b80cfded0..b5fcd56d10 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -2456,6 +2456,7 @@
"perm": {
"grantsTitle": "安装后它将拥有:",
"toolsGroup": "注册工具",
+ "toolsDiffGroup": "注册工具变化",
"itemCount": "{{count}} 项",
"cindyImageGenerate": "图像生成(请 Cindy 代办)",
"cindyImageEdit": "图像编辑(请 Cindy 代办,仅限它自己生成的图)",