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(desktop): add publishes subtab

fmfsaisaiaa7791f7f616
diff --git a/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx b/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx
index 0fd9935179..438c49945c 100644
--- a/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx
+++ b/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx
@@ -170,6 +170,94 @@ const MAX_VISIBLE_INSTALLED_PLUGINS = 8;
/** 折叠入口只预览前三个隐藏插件,避免头像堆叠反过来抢占操作文案。 */
const MAX_COLLAPSED_INSTALLED_PLUGIN_PREVIEWS = 3;
+/**
+ * 「我的发布」暂以插件页二级 tab 呈现,避免与「已安装」争抢顶层布局。
+ * 用户确认本期效果后会关掉此开关;下期重新开放仍沿用当前 tab 形态。
+ */
+export const SHOW_MY_PUBLISHES_SECTION = true;
+
+/**
+ * Product gate for the whole secondary tab experience. The overview stays mounted while tabs
+ * switch, and a disabled gate returns it without an extra wrapper or hidden publishing effects.
+ */
+export function MyPublishesSectionVisibilityGate({
+ visible,
+ overviewLabel,
+ publishesLabel,
+ tabsAriaLabel,
+ publishes,
+ children,
+}: {
+ visible: boolean;
+ overviewLabel: string;
+ publishesLabel: string;
+ tabsAriaLabel: string;
+ publishes: ReactNode;
+ children: ReactNode;
+}) {
+ const [activeTab, setActiveTab] = useState<'overview' | 'publishes'>('overview');
+ const id = useId();
+ const overviewTabId = `${id}-overview-tab`;
+ const overviewPanelId = `${id}-overview-panel`;
+ const publishesTabId = `${id}-publishes-tab`;
+ const publishesPanelId = `${id}-publishes-panel`;
+
+ if (!visible) return <>{children}</>;
+
+ return (
+ <>
+ <div
+ role="tablist"
+ aria-label={tabsAriaLabel}
+ className="mt-5 flex items-end gap-6 border-b border-[var(--border-default)]"
+ >
+ {([
+ ['overview', overviewLabel, overviewTabId, overviewPanelId],
+ ['publishes', publishesLabel, publishesTabId, publishesPanelId],
+ ] as const).map(([tab, label, tabId, panelId]) => {
+ const active = activeTab === tab;
+ return (
+ <button
+ key={tab}
+ id={tabId}
+ type="button"
+ role="tab"
+ aria-selected={active}
+ aria-controls={panelId}
+ onClick={() => setActiveTab(tab)}
+ className={cn(
+ '-mb-px select-none border-b-2 px-0.5 pb-2.5 pt-1 text-13 font-medium transition-colors',
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',
+ active
+ ? 'border-[var(--text-primary)] text-[var(--text-primary)]'
+ : 'border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]',
+ )}
+ >
+ {label}
+ </button>
+ );
+ })}
+ </div>
+ <div
+ id={overviewPanelId}
+ role="tabpanel"
+ aria-labelledby={overviewTabId}
+ hidden={activeTab !== 'overview'}
+ >
+ {children}
+ </div>
+ <div
+ id={publishesPanelId}
+ role="tabpanel"
+ aria-labelledby={publishesTabId}
+ hidden={activeTab !== 'publishes'}
+ >
+ {publishes}
+ </div>
+ </>
+ );
+}
+
/** Keeps the installed-section disclosure rule deterministic and directly testable. */
function visibleInstalledPluginItems<T>(items: readonly T[]): T[] {
return items.slice(0, MAX_VISIBLE_INSTALLED_PLUGINS);
@@ -1528,6 +1616,18 @@ export function GhostPluginPage({
</div>
</header>
+ <MyPublishesSectionVisibilityGate
+ visible={SHOW_MY_PUBLISHES_SECTION && showEnterprise}
+ overviewLabel={t('settings.ghosts.page.overviewTab')}
+ publishesLabel={t('settings.ghosts.publish.section')}
+ tabsAriaLabel={t('settings.ghosts.page.secondaryTabsAria')}
+ publishes={
+ <MyPublishesSection
+ enabled={showEnterprise}
+ onPublish={() => void handlePublish()}
+ />
+ }
+ >
{scopeDir ? (
<div className="mt-5 flex items-center justify-between gap-3 rounded-xl border border-[var(--border-default)] bg-[var(--surface-chip)] px-4 py-3">
<div className="flex min-w-0 items-center gap-2.5">
@@ -1683,8 +1783,6 @@ export function GhostPluginPage({
) : null}
</section>
- <MyPublishesSection enabled={showEnterprise} onPublish={() => void handlePublish()} />
-
{availableMarketItems.length > 0 ||
searchedAvailableMarketItems.length > 0 ||
marketSnapshot?.unavailableReason ||
@@ -1820,6 +1918,7 @@ export function GhostPluginPage({
)}
</section>
) : null}
+ </MyPublishesSectionVisibilityGate>
</PluginManagementPage>
</main>
{panelAside}
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 9500c35a32..a2af899664 100644
--- a/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsx
+++ b/apps/desktop/src/renderer/features/plugin/__tests__/GhostPluginCard.test.tsx
@@ -34,6 +34,8 @@ import {
LegacyGhostRecoveryNotice,
marketUpdateAllowsPermissionExpansion,
MarketPluginCard,
+ MyPublishesSectionVisibilityGate,
+ SHOW_MY_PUBLISHES_SECTION,
shouldOpenInstalledDetailAfterMarketSuccess,
} from '../GhostPluginPage';
import {
@@ -52,6 +54,98 @@ const {
visibleInstalledPluginItems,
} = __installedPluginLayoutForTests;
+describe('MyPublishesSectionVisibilityGate', () => {
+ const labels = {
+ overviewLabel: 'Overview',
+ publishesLabel: 'My publishes',
+ tabsAriaLabel: 'Plugin page sections',
+ };
+
+ it('shows both secondary tabs and switches their selected panel when enabled', () => {
+ expect(SHOW_MY_PUBLISHES_SECTION).toBe(true);
+ render(
+ <MyPublishesSectionVisibilityGate
+ visible={SHOW_MY_PUBLISHES_SECTION}
+ {...labels}
+ publishes={<div data-testid="publishes-content" />}
+ >
+ <div data-testid="overview-content" />
+ </MyPublishesSectionVisibilityGate>,
+ );
+
+ const overviewTab = screen.getByRole('tab', { name: 'Overview' });
+ const publishesTab = screen.getByRole('tab', { name: 'My publishes' });
+ const overviewPanel = document.getElementById(overviewTab.getAttribute('aria-controls') ?? '');
+ const publishesPanel = document.getElementById(
+ publishesTab.getAttribute('aria-controls') ?? '',
+ );
+
+ expect(screen.getAllByRole('tab')).toHaveLength(2);
+ expect(overviewTab.getAttribute('aria-selected')).toBe('true');
+ expect(publishesTab.getAttribute('aria-selected')).toBe('false');
+ expect(overviewPanel?.hidden).toBe(false);
+ expect(publishesPanel?.hidden).toBe(true);
+
+ fireEvent.click(publishesTab);
+
+ // This excludes a decorative tab row that never switches the visible content.
+ expect(overviewTab.getAttribute('aria-selected')).toBe('false');
+ expect(publishesTab.getAttribute('aria-selected')).toBe('true');
+ expect(overviewPanel?.hidden).toBe(true);
+ expect(publishesPanel?.hidden).toBe(false);
+ });
+
+ it('removes the whole secondary tab row and publishing effects when disabled', () => {
+ const publishesRender = vi.fn();
+ function PublishesProbe() {
+ publishesRender();
+ return <div data-testid="publishes-content-disabled" />;
+ }
+
+ const { container } = render(
+ <MyPublishesSectionVisibilityGate visible={false} {...labels} publishes={<PublishesProbe />}>
+ <div data-testid="overview-content-disabled" />
+ </MyPublishesSectionVisibilityGate>,
+ );
+
+ // This excludes hiding only the publishing panel while leaving a one-tab row or wrapper noise.
+ expect(screen.queryByRole('tablist')).toBeNull();
+ expect(screen.queryByRole('tab')).toBeNull();
+ expect(container.children).toHaveLength(1);
+ expect(container.firstElementChild).toBe(screen.getByTestId('overview-content-disabled'));
+ expect(publishesRender).not.toHaveBeenCalled();
+ });
+
+ it('keeps overview content mounted and in place while viewing publishes', () => {
+ render(
+ <MyPublishesSectionVisibilityGate
+ visible
+ {...labels}
+ publishes={<div data-testid="publishes-content-persistent" />}
+ >
+ <div data-testid="overview-content-persistent" />
+ </MyPublishesSectionVisibilityGate>,
+ );
+
+ const overviewNode = screen.getByTestId('overview-content-persistent');
+ const publishesNode = screen.getByTestId('publishes-content-persistent');
+ const overviewPanel = overviewNode.parentElement;
+ const publishesPanel = publishesNode.parentElement;
+
+ expect(overviewPanel?.nextElementSibling).toBe(publishesPanel);
+ fireEvent.click(screen.getByRole('tab', { name: 'My publishes' }));
+
+ // The same DOM node and panel order exclude conditional unmounting or reordering the catalog.
+ expect(screen.getByTestId('overview-content-persistent')).toBe(overviewNode);
+ expect(overviewPanel?.nextElementSibling).toBe(publishesPanel);
+ expect(overviewPanel?.hidden).toBe(true);
+
+ fireEvent.click(screen.getByRole('tab', { name: 'Overview' }));
+ expect(screen.getByTestId('overview-content-persistent')).toBe(overviewNode);
+ expect(overviewPanel?.hidden).toBe(false);
+ });
+});
+
describe('diffMarketUpdatePermissionItems', () => {
it.each(['legacy-unapproved', 'invalid'] as const)(
'reviews every target permission for a %s install',
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index c0909a6a9c..17fadb2a68 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -4063,6 +4063,8 @@
"page": {
"search": "Search plugins",
"clearSearch": "Clear Plugin Search",
+ "secondaryTabsAria": "Plugin page sections",
+ "overviewTab": "Overview",
"addPlugin": "Add plugin",
"addPluginAria": "Plugin add options",
"installedSection": "Installed",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index 1a6e9707d2..1c7d9391db 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -4062,6 +4062,8 @@
"page": {
"search": "プラグインを検索",
"clearSearch": "プラグイン検索をクリア",
+ "secondaryTabsAria": "プラグインページのセクション",
+ "overviewTab": "概要",
"addPlugin": "プラグインを追加",
"addPluginAria": "プラグイン追加オプション",
"installedSection": "インストール済み",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index eb902d567c..3b2f0666a3 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -4062,6 +4062,8 @@
"page": {
"search": "플러그인 검색",
"clearSearch": "플러그인 검색 지우기",
+ "secondaryTabsAria": "플러그인 페이지 섹션",
+ "overviewTab": "개요",
"addPlugin": "플러그인 추가",
"addPluginAria": "플러그인 추가 옵션",
"installedSection": "설치됨",
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 dd5ac9986a..19d38610b8 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -4062,6 +4062,8 @@
"page": {
"search": "搜索插件",
"clearSearch": "清除插件搜索",
+ "secondaryTabsAria": "插件页内容",
+ "overviewTab": "概览",
"addPlugin": "添加插件",
"addPluginAria": "插件添加选项",
"installedSection": "已安装",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
index 7e534dca02..7c87239c3f 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -4062,6 +4062,8 @@
"page": {
"search": "搜尋插件",
"clearSearch": "清除插件搜尋",
+ "secondaryTabsAria": "插件頁內容",
+ "overviewTab": "總覽",
"addPlugin": "新增插件",
"addPluginAria": "插件新增選項",
"installedSection": "已安裝",
diff --git a/i18n/GLOSSARY.md b/i18n/GLOSSARY.md
index 14f8d081d8..9a43b13702 100644
--- a/i18n/GLOSSARY.md
+++ b/i18n/GLOSSARY.md
@@ -271,6 +271,10 @@ issue #882:模型管理/新对话选择器的分类标签,对应 Gateway mod
腾讯授权页可能展示的外部产品名称,客户端仅按原品牌名展示;先登记为 proposed,待产品术语评审后再决定是否固化。
+### Overview
+
+插件页二级 tab 的总览入口,承载已安装与推荐内容,与「我的发布」并列。该词不重复页面标题「插件」,并保持弱于一级 Plugin / Skill pill 的层级。
+
### Passkey
WebAuthn 可发现凭证的用户可见名称,采用 Apple、Google 与 Microsoft 平台常见译法;先登记为 proposed,待产品术语评审后固化。
diff --git a/i18n/glossary.json b/i18n/glossary.json
index 5eea0b7b44..875e9cd46d 100644
--- a/i18n/glossary.json
+++ b/i18n/glossary.json
@@ -800,6 +800,18 @@
},
"note": "Privacy Policy 是同一份法律文件。繁中设置页与日志上传提示已统一使用「隱私政策」,登录文案曾漂移为「隱私協議」,因此在 zh-TW 中统一为「隱私政策」。禁用项按英文源限定,避免误伤真正指 Agreement 的文案;本次只锁定新增繁中 catalog,不借此改写既有简中口径。"
},
+ {
+ "id": "overview",
+ "status": "proposed",
+ "en": "Overview",
+ "translations": {
+ "zh-CN": "概览",
+ "zh-TW": "總覽",
+ "ja": "概要",
+ "ko": "개요"
+ },
+ "note": "插件页二级 tab 的总览入口,承载已安装与推荐内容,与「我的发布」并列。该词不重复页面标题「插件」,并保持弱于一级 Plugin / Skill pill 的层级。"
+ },
{
"id": "plugin",
"status": "decided",