Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
面板插件的重开入口:右侧栏「+」菜单插件分组、插件详情页「在侧边栏中打开」
Dash8a1457e06bf6
diff --git a/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx b/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsxindex 5fc1629f17..0486fb1adc 100644--- a/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx+++ b/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx@@ -57,6 +57,11 @@ import {} from '../../../shared/ghost';import { type GhostPluginDetail } from './lib/ghostPluginViewModel';import { GhostPluginIcon } from './GhostPluginIcon';+import {+ addGlobalPluginTab,+ setActiveGlobalTabId,+ useGlobalTabs,+} from '@/features/right-sidebar/globalTabs';import { ghostPluginSummary } from './lib/ghostPluginDetailModel';import { ghostPrimaryAction } from './lib/ghostPluginViewModel';import { permissionItemIcon } from './lib/permissionItemIcon';@@ -829,6 +834,10 @@ export function DetailsSection({}) {const { t } = useTranslation();const trustLabelKey = ghostTrustLabelKey(detail.trust);+ const globalTabs = useGlobalTabs();+ const inSidebar = globalTabs.some(+ (tab) => (tab.state as { instanceId?: string } | null)?.instanceId === detail.id,+ );const facts: Array<{key: string;label: string;@@ -882,6 +891,24 @@ export function DetailsSection({detail.panelMinWidth === null? t('settings.ghosts.detail.panelNone'): panelStatus || t('settings.ghosts.detail.panelDismissed'),+ // 停靠形态面板关掉页签后,这里是除右侧栏「+」菜单外的另一个重开入口+ // (这类插件没有左侧栏入口)。已在侧栏、停用、tab 形态或无面板时不渲染。+ ...(detail.panelMinWidth !== null && !detail.tabPanel && detail.enabled && !inSidebar+ ? {+ action: (+ <button+ type="button"+ onClick={() => {+ const tab = addGlobalPluginTab(detail.id);+ if (tab) setActiveGlobalTabId(tab.id);+ }}+ className="shrink-0 rounded-md px-2 py-1 text-12 text-[var(--text-secondary)] transition-colors 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)]"+ >+ {t('settings.ghosts.detail.openInSidebar')}+ </button>+ ),+ }+ : {}),},...(detail.installDir? [diff --git a/apps/desktop/src/renderer/features/right-sidebar/AddTabDropdown.tsx b/apps/desktop/src/renderer/features/right-sidebar/AddTabDropdown.tsxindex b788e63314..d5b7226a16 100644--- a/apps/desktop/src/renderer/features/right-sidebar/AddTabDropdown.tsx+++ b/apps/desktop/src/renderer/features/right-sidebar/AddTabDropdown.tsx@@ -10,8 +10,28 @@import { useEffect } from 'react';import { useTranslation } from 'react-i18next';-import { Bot, FileDiff, FolderTree, Globe, LayoutGrid, ListTodo, Terminal } from 'lucide-react';+import {+ Bot,+ FileDiff,+ FolderTree,+ Globe,+ LayoutGrid,+ ListTodo,+ Puzzle,+ Terminal,+} from 'lucide-react';import type { LucideIcon } from 'lucide-react';+import { MAIN_VIEW_ICONS } from '@/cindy-brain/mainViewIcons';+import { useInstalledGhosts } from '@/cindy-brain/useInstalledGhosts';+import { installedGhostStoragePart } from '../../../shared/pluginIdentity';+import {+ addGlobalPluginTab,+ globalTabTitleForGhost,+ isGlobalTabCapableGhost,+ setActiveGlobalTabId,+ useGlobalTabs,+ type PluginViewTabState,+} from './globalTabs';import {DropdownMenuContent,DropdownMenuItem,@@ -121,6 +141,24 @@ export function AddTabDropdown({subagentsAvailable = false,}: AddTabDropdownProps) {const { t } = useTranslation();+ // 插件分组:声明了面板或 mainView 的已启用插件,点选 = 作为全局页签(不跟对话)钉进+ // 右侧栏。这是没有左侧栏入口的面板插件(关掉页签后)唯一的侧栏内重开入口。+ const installedGhosts = useInstalledGhosts();+ const globalTabs = useGlobalTabs();+ const pluginEntries = installedGhosts+ .filter(isGlobalTabCapableGhost)+ .map((ghost) => {+ const instanceId = installedGhostStoragePart(ghost);+ return {+ instanceId,+ title: globalTabTitleForGhost(ghost),+ icon: MAIN_VIEW_ICONS[ghost.manifest.mainView?.icon ?? 'puzzle'] ?? Puzzle,+ open: globalTabs.some(+ (tab) => (tab.state as PluginViewTabState | null)?.instanceId === instanceId,+ ),+ };+ })+ .sort((a, b) => a.title.localeCompare(b.title) || a.instanceId.localeCompare(b.instanceId));const bots = useBotProfiles();const bot = sessionId ? findBotProfileForSession(bots, sessionId) : undefined;const isBotSession = Boolean(bot);@@ -203,6 +241,25 @@ export function AddTabDropdown({/>);})}+ {pluginEntries.length > 0 && (+ <>+ <DropdownMenuSeparator />+ <DropdownMenuLabel>{t('rightSidebar.tabs.menu.pluginsLabel')}</DropdownMenuLabel>+ {pluginEntries.map((entry) => (+ <AddTabItem+ key={entry.instanceId}+ icon={entry.icon}+ label={entry.title}+ trailing={entry.open ? t('rightSidebar.tabs.menu.alreadyOpen') : undefined}+ onSelect={() => {+ const tab = addGlobalPluginTab(entry.instanceId);+ if (tab) setActiveGlobalTabId(tab.id);+ onClose();+ }}+ />+ ))}+ </>+ )}{coming.length > 0 && (<><DropdownMenuSeparator />diff --git a/apps/desktop/src/renderer/features/right-sidebar/__tests__/TabBar.test.tsx b/apps/desktop/src/renderer/features/right-sidebar/__tests__/TabBar.test.tsxindex b19983f844..c75602f68e 100644--- a/apps/desktop/src/renderer/features/right-sidebar/__tests__/TabBar.test.tsx+++ b/apps/desktop/src/renderer/features/right-sidebar/__tests__/TabBar.test.tsx@@ -4,6 +4,12 @@ import { afterEach, describe, expect, it, vi } from 'vitest';import Sortable, { type SortableEvent } from 'sortablejs';// react-i18next 走 key 透传(仓库同款,见 RightSidebarShell.test.ts):label 直接是 i18n key。+// 「+」菜单的插件分组:声明面板 / mainView 的已启用插件。无桥环境下用桩供数据。+const installedGhostsMock = vi.hoisted(() => ({ list: [] as unknown[] }));+vi.mock('@/cindy-brain/useInstalledGhosts', () => ({+ useInstalledGhosts: () => installedGhostsMock.list,+ readInstalledGhostsSnapshot: () => installedGhostsMock.list,+}));vi.mock('react-i18next', () => ({useTranslation: () => ({ t: (key: string) => key }),}));@@ -136,6 +142,39 @@ describe('TabStrip Cindy Make menu visibility', () => {});});+// 测试价值+// - 生产入口与可观察结果:TabStrip 的「+」菜单;可观察的是声明停靠面板的已启用插件出现在+// 「插件」分组里,点选后成为右侧栏全局页签(globalTabs),再次打开菜单标「已打开」。+// - Bug / 规则依据:停靠面板收束为右侧栏全局页签后,没有左侧栏入口的面板插件(如只声明+// panel 的 Mivo)关掉页签后必须仍有重开入口,否则用户视角等于插件不可用(插件兼容红线)。+// - 现有覆盖缺口:其余「+」菜单用例只覆盖内置 kind。+// - 最小失败输入:一个 enabled 且 panel.position 缺省的插件。+// - tier:unit(jsdom)。+describe('TabStrip add menu · plugins group', () => {+ it('lists panel plugins and pins the chosen one as a global tab', async () => {+ const { __resetGlobalTabsForTest, getGlobalTabs } = await import('../globalTabs');+ __resetGlobalTabsForTest();+ window.localStorage.clear();+ installedGhostsMock.list = [+ { manifest: { id: 'xd-mivo', name: 'XD Mivo', panel: { html: 'panel.html', title: 'Mivo 资产库' } }, enabled: true },+ { manifest: { id: 'tool-only', name: 'Tool Only' }, enabled: true },+ ];+ renderStrip();+ const addButton = screen.getByRole('button', { name: 'rightSidebar.tabs.addAria' });+ vi.spyOn(addButton.parentElement as HTMLElement, 'getBoundingClientRect').mockReturnValue({+ x: 20, y: 20, top: 20, right: 44, bottom: 44, left: 20, width: 24, height: 24, toJSON: () => ({}),+ });+ fireEvent.pointerDown(addButton, { button: 0, ctrlKey: false });+ expect(screen.getByText('rightSidebar.tabs.menu.pluginsLabel')).toBeTruthy();+ expect(screen.queryByText('Tool Only')).toBeNull();+ fireEvent.click(screen.getByText('Mivo 资产库'));+ expect(getGlobalTabs().map((tab) => (tab.state as { instanceId: string }).instanceId)).toEqual(['xd-mivo']);+ installedGhostsMock.list = [];+ __resetGlobalTabsForTest();+ window.localStorage.clear();+ });+});+afterEach(() => cleanup());describe('TabStrip 中键关闭 tab', () => {diff --git a/apps/desktop/src/renderer/features/right-sidebar/globalTabs.ts b/apps/desktop/src/renderer/features/right-sidebar/globalTabs.tsindex 4984282b86..d4290ede06 100644--- a/apps/desktop/src/renderer/features/right-sidebar/globalTabs.ts+++ b/apps/desktop/src/renderer/features/right-sidebar/globalTabs.ts@@ -217,6 +217,20 @@ export function reorderGlobalTabs(orderedIds: string[]): void {persist({ tabs: next, dismissedInstanceIds: current.dismissedInstanceIds });}+/** 页签标题:停靠面板用 panel.title,整页视图用 mainView.title,都没有就用插件名。 */+export function globalTabTitleForGhost(ghost: InstalledGhost): string {+ const { manifest } = ghost;+ return manifest.panel?.title ?? manifest.mainView?.title ?? manifest.name;+}++export function findGlobalTabByInstance(instanceId: string): TabState | null {+ return (+ getGlobalTabs().find(+ (tab) => (tab.state as PluginViewTabState | null)?.instanceId === instanceId,+ ) ?? null+ );+}+/** 停靠形态(非 `tab`)的插件面板 = 应自动出现在右侧栏的全局页签。 */export function isAutoGlobalPanelGhost(ghost: InstalledGhost): boolean {return (diff --git a/apps/desktop/src/renderer/features/right-sidebar/plugins/plugin-view/index.tsx b/apps/desktop/src/renderer/features/right-sidebar/plugins/plugin-view/index.tsxindex 2d7d5c162d..185c11b8d8 100644--- a/apps/desktop/src/renderer/features/right-sidebar/plugins/plugin-view/index.tsx+++ b/apps/desktop/src/renderer/features/right-sidebar/plugins/plugin-view/index.tsx@@ -23,7 +23,7 @@ import { useInstalledGhosts } from '@/cindy-brain/useInstalledGhosts';import { MAIN_VIEW_ICONS } from '@/cindy-brain/mainViewIcons';import type { InstalledGhost } from '../../../../../shared/ghost';import { installedGhostStoragePart } from '../../../../../shared/pluginIdentity';-import type { PluginViewTabState } from '../../globalTabs';+import { globalTabTitleForGhost, type PluginViewTabState } from '../../globalTabs';import { registerTabKind } from '../../registry';import type { TabKindBodyProps, TabKindPlugin } from '../../types';@@ -31,15 +31,9 @@ function useInstalledGhostByInstance(instanceId: string): InstalledGhost | undefreturn useInstalledGhosts().find((ghost) => installedGhostStoragePart(ghost) === instanceId);}-/** 页签标题:停靠面板用 panel.title,整页视图用 mainView.title,都没有就用插件名。 */-export function pluginViewTitle(ghost: InstalledGhost): string {- const { manifest } = ghost;- return manifest.panel?.title ?? manifest.mainView?.title ?? manifest.name;-}-function PluginViewTabPillTitle({ state, t }: { state: PluginViewTabState; t: TFunction }) {const ghost = useInstalledGhostByInstance(state.instanceId);- return <>{ghost ? pluginViewTitle(ghost) : t('rightSidebar.tabs.kinds.pluginView')}</>;+ return <>{ghost ? globalTabTitleForGhost(ghost) : t('rightSidebar.tabs.kinds.pluginView')}</>;}function PluginViewTabPillIcon({ state }: { state: PluginViewTabState }) {diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex 1735add12e..e0552dc4d5 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -6694,7 +6694,8 @@"locationCopyFailed": "Could not copy the install location. Copy it manually.","openLocation": "Open install location","panelInSidebar": "Shown in the right sidebar (kept across tasks)",- "panelDismissed": "Closed from the right sidebar · right-click its entry in the left sidebar to reopen",+ "panelDismissed": "Closed from the right sidebar · reopen here or from the sidebar “+” menu",+ "openInSidebar": "Open in the sidebar","panelPageHosted": "Opens from the Plugin page · closes when you leave","panelNone": "This plugin has no panel","customSlotTitle": "Plugin custom settings area",@@ -8018,7 +8019,8 @@"menu": {"addLabel": "Add tab","comingSoon": "Coming soon",- "alreadyOpen": "Open"+ "alreadyOpen": "Open",+ "pluginsLabel": "Plugins"},"kinds": {"fileBrowser": "File browser",diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex ded0b2a9f0..21e98d5fff 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -6663,7 +6663,8 @@"locationCopyFailed": "インストール場所をコピーできませんでした。手動でコピーしてください","openLocation": "インストール場所を開く","panelInSidebar": "右サイドバーに表示(すべてのタスクで保持)",- "panelDismissed": "右サイドバーから閉じました · 左サイドバーの入口を右クリックで再度開けます",+ "panelDismissed": "右サイドバーから閉じました · ここまたはサイドバーの「+」メニューから再度開けます",+ "openInSidebar": "サイドバーで開く","panelPageHosted": "プラグインページから開く · 離れると自動的に閉じます","panelNone": "このプラグインにパネルはありません","customSlotTitle": "プラグインのカスタム設定エリア",@@ -7986,7 +7987,8 @@"menu": {"addLabel": "タブを追加","comingSoon": "近日対応",- "alreadyOpen": "開いています"+ "alreadyOpen": "開いています",+ "pluginsLabel": "プラグイン"},"kinds": {"fileBrowser": "ファイルブラウザ",diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex 6a6642d3f1..a0755ba93c 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -6663,7 +6663,8 @@"locationCopyFailed": "설치 위치를 복사하지 못했습니다. 수동으로 복사하세요","openLocation": "설치 위치 열기","panelInSidebar": "오른쪽 사이드바에 표시(모든 작업에서 유지)",- "panelDismissed": "오른쪽 사이드바에서 닫음 · 왼쪽 사이드바 항목을 우클릭해 다시 열 수 있습니다",+ "panelDismissed": "오른쪽 사이드바에서 닫음 · 여기 또는 사이드바 “+” 메뉴에서 다시 열 수 있습니다",+ "openInSidebar": "사이드바에서 열기","panelPageHosted": "플러그인 페이지에서 열림 · 벗어나면 자동으로 닫힘","panelNone": "이 플러그인에는 패널이 없습니다","customSlotTitle": "플러그인 사용자 정의 설정 영역",@@ -7986,7 +7987,8 @@"menu": {"addLabel": "탭 추가","comingSoon": "지원 예정",- "alreadyOpen": "열림"+ "alreadyOpen": "열림",+ "pluginsLabel": "플러그인"},"kinds": {"fileBrowser": "파일 브라우저",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex b83713c962..9a5b511f20 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -6663,7 +6663,8 @@"locationCopyFailed": "复制安装位置失败,请手动复制","openLocation": "打开安装位置","panelInSidebar": "显示在右侧栏(所有任务中保留)",- "panelDismissed": "已从右侧栏关闭 · 可在左侧栏入口右键重新打开",+ "panelDismissed": "已从右侧栏关闭 · 可在此处或右侧栏「+」菜单重新打开",+ "openInSidebar": "在侧边栏中打开","panelPageHosted": "从插件页打开 · 离开插件页自动关闭","panelNone": "这个插件不含面板","customSlotTitle": "插件自定义设置区",@@ -7986,7 +7987,8 @@"menu": {"addLabel": "添加标签","comingSoon": "即将支持",- "alreadyOpen": "已打开"+ "alreadyOpen": "已打开",+ "pluginsLabel": "插件"},"kinds": {"fileBrowser": "文件浏览器",diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.jsonindex d12292c53c..95f7dc107b 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json@@ -6663,7 +6663,8 @@"locationCopyFailed": "複製安裝位置失敗,請手動複製","openLocation": "開啟安裝位置","panelInSidebar": "顯示在右側欄(所有任務中保留)",- "panelDismissed": "已從右側欄關閉 · 可在左側欄入口右鍵重新開啟",+ "panelDismissed": "已從右側欄關閉 · 可在此處或右側欄「+」選單重新開啟",+ "openInSidebar": "在側邊欄中開啟","panelPageHosted": "從插件頁開啟 · 離開插件頁自動關閉","panelNone": "這個插件不含面板","customSlotTitle": "插件自定義設定區",@@ -7986,7 +7987,8 @@"menu": {"addLabel": "新增標籤","comingSoon": "即將支援",- "alreadyOpen": "已開啟"+ "alreadyOpen": "已開啟",+ "pluginsLabel": "插件"},"kinds": {"fileBrowser": "檔案瀏覽器",