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): 详情页「在侧边栏中打开」复用 openPluginInSidebar,同步清除窗口放置记忆

Dash12791a755a87
diff --git a/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx b/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx
index 01c3ceb64e..dd512d7ded 100644
--- a/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx
+++ b/apps/desktop/src/renderer/features/plugin/GhostPluginDetailView.tsx
@@ -60,14 +60,14 @@ import {
import { type GhostPluginDetail } from './lib/ghostPluginViewModel';
import { GhostPluginIcon } from './GhostPluginIcon';
import {
- addGlobalPluginTab,
hasPluginPlacementMemory,
- setActiveGlobalTabId,
useGlobalTabs,
} from '@/features/right-sidebar/globalTabs';
-import { requestRightSidebarVisibility } from '@/features/right-sidebar/lib/sidebarCommands';
-import { resetPluginPlacementAndReturn } from '@/features/right-sidebar/pluginPlacement';
-import { getTabGroup, useTabGroupAssignments } from '@/features/right-sidebar/tabGroups';
+import {
+ openPluginInSidebar,
+ resetPluginPlacementAndReturn,
+} from '@/features/right-sidebar/pluginPlacement';
+import { useTabGroupAssignments } from '@/features/right-sidebar/tabGroups';
import { useInstalledGhosts } from '@/cindy-brain/useInstalledGhosts';
import { installedGhostStoragePart } from '../../../shared/pluginIdentity';
import { ghostPluginSummary } from './lib/ghostPluginDetailModel';
@@ -986,14 +986,7 @@ export function DetailsSection({
<button
type="button"
onClick={() => {
- const tab = addGlobalPluginTab(detail.id, {
- ghost: installedGhost,
- view: 'panel',
- });
- if (!tab) return;
- setActiveGlobalTabId(tab.id);
- // 落在右侧组时右侧栏可能是收起的:展开,否则用户点了没有任何反馈。
- if (getTabGroup(tab.id) === 'right') requestRightSidebarVisibility('open');
+ if (installedGhost) void openPluginInSidebar(installedGhost, 'panel');
}}
className={placementActionClass}
>
diff --git a/apps/desktop/src/renderer/features/right-sidebar/pluginPlacement.ts b/apps/desktop/src/renderer/features/right-sidebar/pluginPlacement.ts
index 1d59f6b68d..c1e0527a53 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/pluginPlacement.ts
+++ b/apps/desktop/src/renderer/features/right-sidebar/pluginPlacement.ts
@@ -23,6 +23,7 @@ import {
findGlobalTabByInstance,
resetPluginPlacement,
tabShowsMainView,
+ type PluginViewKind,
type PluginViewTabState,
isPluginWindowPlacement,
rememberPluginWindowPlacement,
@@ -70,10 +71,13 @@ async function returnPluginTabFromWindow(tabId: string): Promise<void> {
}
/** 作为全局页签放进侧边栏(默认边见模块说明),选中它;落在右侧组时展开右侧栏。 */
-export async function openPluginInSidebar(ghost: InstalledGhost): Promise<void> {
+export async function openPluginInSidebar(
+ ghost: InstalledGhost,
+ // 左侧导航入口放进侧栏的是主视图页面;详情页「在侧边栏中打开」放的是停靠面板页面。
+ view: PluginViewKind = 'main',
+): Promise<void> {
const instanceId = installedGhostStoragePart(ghost);
- // 左侧导航入口放进侧栏的是主视图页面(而不是停靠面板)。
- const tab = addGlobalPluginTab(instanceId, { ghost, view: 'main' });
+ const tab = addGlobalPluginTab(instanceId, { ghost, view });
if (!tab) return;
await returnPluginTabFromWindow(tab.id);
rememberPluginWindowPlacement(instanceId, false);