Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(plugins): 保留归属解析期间的任务页选择
Dashaaa6348a468a
diff --git a/apps/desktop/src/renderer/features/right-sidebar/__tests__/RightSidebarShell.test.ts b/apps/desktop/src/renderer/features/right-sidebar/__tests__/RightSidebarShell.test.tsindex 8c11d1d831..24edea051e 100644--- a/apps/desktop/src/renderer/features/right-sidebar/__tests__/RightSidebarShell.test.ts+++ b/apps/desktop/src/renderer/features/right-sidebar/__tests__/RightSidebarShell.test.ts@@ -70,6 +70,7 @@ vi.mock('../lib/rsbBrowserBridge', async () => {});import { RightSidebarShell } from '../RightSidebarShell';+import '../plugins/plugin-task';import { BrowserTabBody } from '../plugins/web-browser/BrowserTabBody';import type { WebBrowserState } from '../plugins/web-browser';import type { TabKindBodyProps } from '../types';@@ -898,6 +899,47 @@ describe('RightSidebarShell empty state', () => {view.unmount();});+ // #6861:冷启动归属未知不能收起插件任务页或改写恢复的选择;正文只在确认本机后加载。+ // 真实 Shell → 可用性投影 → plugin-task → GhostWebviewBody;旧覆盖只测已解析的清单。+ // 最小输入:持久化任务页 + undefined→null/远端;另带普通页检测选中位丢失。tier:unit。+ it.each([+ { device: null, mixed: false }, { device: 'other-device', mixed: false },+ { device: null, mixed: true }, { device: 'other-device', mixed: true },+ ])('preserves plugin task selection until ownership resolves ($device, mixed=$mixed)', async ({ device, mixed }) => {+ installedGhostsMock.list = [{+ manifest: { id: 'alpha', name: 'Alpha', taskView: { html: 'task.html', title: 'Task Page' } },+ enabled: true, dir: '/tmp/alpha',+ }];+ const onAllTabsClosed = vi.fn();+ tabsIpc.list.mockResolvedValueOnce({+ tabs: [+ ...(mixed ? [{ id: 'files', kind: 'file-browser', state: null }] : []),+ { id: 'plugin-task', kind: 'plugin-task', state: { instanceId: 'alpha' } },+ ], activeTabId: 'plugin-task',+ });+ const props = {+ sessionId: 's1', workdir: '/tmp/repo', remoteHostId: null, isMac: true, onAllTabsClosed,+ };+ const view = render(createElement(RightSidebarShell, props));+ await waitFor(() => expect(getBucket('s1').hydrated).toBe(true));+ expect(screen.getByText('Task Page')).toBeTruthy();+ expect(onAllTabsClosed).not.toHaveBeenCalled();+ expect(tabsIpc.setActive).not.toHaveBeenCalled();+ expect(document.querySelector('webview')).toBeNull();+ view.rerender(createElement(RightSidebarShell, { ...props, deviceLinkDeviceId: device }));+ if (device === null) {+ await waitFor(() => expect(document.querySelector('webview')?.getAttribute('src')).toBe('cindy-ghost://alpha/task.html?session=s1'));+ expect(getBucket('s1').activeTabId).toBe('plugin-task');+ expect(onAllTabsClosed).not.toHaveBeenCalled();+ expect(tabsIpc.setActive).not.toHaveBeenCalled();+ } else {+ await waitFor(() => expect(screen.queryByText('Task Page')).toBeNull());+ expect(document.querySelector('webview')).toBeNull();+ expect(onAllTabsClosed).toHaveBeenCalledTimes(mixed ? 0 : 1);+ }+ expect(tabsIpc.close).not.toHaveBeenCalled();+ });+it('keeps a persisted Subagents-only sidebar intact while Pi eligibility is loading', async () => {const onAllTabsClosed = vi.fn();tabsIpc.list.mockResolvedValueOnce({diff --git a/apps/desktop/src/renderer/features/right-sidebar/plugins/plugin-task/index.tsx b/apps/desktop/src/renderer/features/right-sidebar/plugins/plugin-task/index.tsxindex 08e7e8df23..0eeab00ebc 100644--- a/apps/desktop/src/renderer/features/right-sidebar/plugins/plugin-task/index.tsx+++ b/apps/desktop/src/renderer/features/right-sidebar/plugins/plugin-task/index.tsx@@ -52,6 +52,8 @@ function PluginTaskTabPillIcon({ state }: { state: PluginTaskTabState }) {function PluginTaskBody({ state, ctx }: TabKindBodyProps<PluginTaskTabState>) {const ghost = useInstalledGhostByInstance(state.instanceId);const runtimeState = useGhostRuntimeState(state.instanceId);+ // 归属未知时只保留页签和选中位,不为可能属于远端的任务加载本机插件页。+ if (ctx.remoteHostId || ctx.deviceLinkDeviceId !== null) return null;// 停用 / 卸载的瞬间可用性投影已把页签隐藏,这里只兜住收起前的一两帧。if (!ghost || ghost.enabled === false || !ghost.manifest.taskView) return null;if (runtimeState === 'crashed' || runtimeState === 'fused') {diff --git a/apps/desktop/src/renderer/features/right-sidebar/tabAvailability.ts b/apps/desktop/src/renderer/features/right-sidebar/tabAvailability.tsindex db5f0ef412..f6d1f0b576 100644--- a/apps/desktop/src/renderer/features/right-sidebar/tabAvailability.ts+++ b/apps/desktop/src/renderer/features/right-sidebar/tabAvailability.ts@@ -19,6 +19,8 @@ export interface RightSidebarTabAvailability {* 不随任务归属变化。缺省 = 不做可用性过滤。*/pluginViewGhosts?: readonly InstalledGhost[];+ /** 任务归属未解析时仍保留本机插件页签的投影;正文另按已确认的归属加载。 */+ pluginTaskGhosts?: readonly InstalledGhost[];}function isUnavailablePluginView(@@ -42,7 +44,7 @@ function isUnavailablePluginTask(if (tab.kind !== 'plugin-task') return false;const instanceId = (tab.state as { instanceId?: unknown } | null)?.instanceId;if (typeof instanceId !== 'string' || !instanceId) return true;- const ghost = availability.installedGhosts.find(+ const ghost = (availability.pluginTaskGhosts ?? availability.installedGhosts).find((candidate) => installedGhostStoragePart(candidate) === instanceId,);return !ghost || ghost.enabled === false || !ghost.manifest.taskView;@@ -143,6 +145,8 @@ export function buildTabAvailabilities(input: TabAvailabilityInput): TabAvailabisession: {installedGhosts:input.remoteHostId || input.deviceLinkDeviceId !== null ? [] : input.installedGhosts,+ pluginTaskGhosts:+ input.remoteHostId || input.deviceLinkDeviceId ? [] : input.installedGhosts,subagentsAvailable: input.subagentsAvailable === true || !eligibilityKnown,hiddenTabIds: input.hiddenTabIds,},