Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(plugins): 保留分离侧栏跳转来源并同步协议文档
Dash330f92a14f9d
diff --git a/apps/desktop/src/main/right-sidebar-window/__tests__/controller.test.ts b/apps/desktop/src/main/right-sidebar-window/__tests__/controller.test.tsindex 46769a1311..17fd2fecfb 100644--- a/apps/desktop/src/main/right-sidebar-window/__tests__/controller.test.ts+++ b/apps/desktop/src/main/right-sidebar-window/__tests__/controller.test.ts@@ -175,6 +175,31 @@ const ctx = { sessionId: 's1', workdir: '/w', remoteHostId: null, available: trubeforeEach(() => { vi.useFakeTimers(); });afterEach(() => { vi.useRealTimers(); });+// PR #6939 discussion_r4357929340:点击来源必须跨即刻投递/切任务排队保持一致。+// unit:真实 routeCommand,旧上下文 → 排队 → 目标上下文;原覆盖没有插件来源字段。+describe('plugin task focus intent', () => {+ it.each([true, false, undefined])('preserves explicit intent through queued adoption: %s', async (userInitiated) => {+ const h = makeHarness({ detached: true }, { resolveHostContext: () => null });+ h.controller.setContext({ ...ctx, sessionId: 's2' });+ h.controller.open();+ markReady(h.controller, h.windows[0]);+ h.sends.length = 0;+ // 即使 command 自报 true,也只能沿用信封里显式给出的来源。+ const command = { type: 'open-plugin-task' as const, sessionId: 's1', instanceId: 'sim', userInitiated: true };+ await expect(h.controller.routeCommand({ command, allowOpen: true, userInitiated })).resolves.toBe('queued');+ expect(h.sends.filter((entry) => entry.channel === 'cmd-channel')).toEqual([]);+ h.controller.setContext(ctx);+ const expected = [+ { channel: 'cmd-channel', payload: { ...command, userInitiated: userInitiated === true } },+ ];+ expect(h.sends.filter((entry) => entry.channel === 'cmd-channel')).toEqual(expected);+ // 同一来源在宿主已就绪的直接投递路径不能得到另一套语义。+ h.sends.length = 0;+ await expect(h.controller.routeCommand({ command, allowOpen: true, userInitiated })).resolves.toBe('routed');+ expect(h.sends.filter((entry) => entry.channel === 'cmd-channel')).toEqual(expected);+ });+});+// ═══════════════════════════════════════════════════════════════════════// prewarm: 后台预热// ═══════════════════════════════════════════════════════════════════════diff --git a/apps/desktop/src/main/right-sidebar-window/controller.ts b/apps/desktop/src/main/right-sidebar-window/controller.tsindex 4efeb31ffa..0147aec619 100644--- a/apps/desktop/src/main/right-sidebar-window/controller.ts+++ b/apps/desktop/src/main/right-sidebar-window/controller.ts@@ -458,7 +458,12 @@ export class RsbWindowController {async routeCommand(request: RsbWindowCommandRouteRequest,): Promise<RsbWindowCommandRouteResult> {- const { command, allowOpen } = request;+ const { allowOpen } = request;+ // 子窗口执行开页时也需要原点击来源。只从既有路由信封派生一次,+ // 与 command 一起经过现有排队/交接路径;不信任 command 内自报的来源。+ const command: RsbWindowCommand = request.command.type === 'open-plugin-task'+ ? { ...request.command, userInitiated: request.userInitiated === true }+ : request.command;const userInitiated = request.userInitiated !== false;if (!this.deps.settings.read().detached) return 'attached';const hostSessionId = commandHostSessionId(command);diff --git a/apps/desktop/src/renderer/features/right-sidebar/lib/__tests__/executeSidebarCommand.test.ts b/apps/desktop/src/renderer/features/right-sidebar/lib/__tests__/executeSidebarCommand.test.tsindex fb77c77f43..1ef1cc7e9c 100644--- a/apps/desktop/src/renderer/features/right-sidebar/lib/__tests__/executeSidebarCommand.test.ts+++ b/apps/desktop/src/renderer/features/right-sidebar/lib/__tests__/executeSidebarCommand.test.ts@@ -14,6 +14,9 @@ vi.mock('../../store', () => ({vi.mock('../openInSidebarBrowser', () => ({openUrlInSidebarBrowser: vi.fn(async () => undefined),}));+vi.mock('../openPluginTaskTab', () => ({+ openPluginTaskTab: vi.fn(async () => undefined),+}));vi.mock('../openInSidebarFileBrowser', () => ({openDirInSidebarFileBrowser: vi.fn(async () => undefined),openExternalFileInSidebarFileBrowser: vi.fn(async () => undefined),@@ -33,6 +36,7 @@ import {ensureOrcaWorkersTab,} from '../../plugins/orca-workers/actions';import { executeSidebarCommand } from '../executeSidebarCommand';+import { openPluginTaskTab } from '../openPluginTaskTab';import {openDirInSidebarFileBrowser,openExternalFileInSidebarFileBrowser,@@ -44,6 +48,13 @@ import { openSubagentsTab } from '../openSubagentsTab';describe('executeSidebarCommand', () => {beforeEach(() => vi.clearAllMocks());+ // PR #6939 discussion_r4357929340:分离宿主执行命令不能降级已验证的点击来源。+ // unit:真实 executor 的输出是传给开页入口的来源协议;原用例未覆盖插件命令。+ it.each([true, false, undefined])('preserves plugin task intent, defaulting old commands to passive: %s', async (userInitiated) => {+ await executeSidebarCommand({ type: 'open-plugin-task', sessionId: 's1', instanceId: 'sim', userInitiated });+ expect(openPluginTaskTab).toHaveBeenCalledWith('s1', 'sim', { userInitiated: userInitiated === true });+ });+it('dispatches every command kind to the current renderer host implementation', async () => {const searchJump = {kind: 'conversation-search' as const,diff --git a/apps/desktop/src/renderer/features/right-sidebar/lib/executeSidebarCommand.ts b/apps/desktop/src/renderer/features/right-sidebar/lib/executeSidebarCommand.tsindex 28481b1860..ec50b772b2 100644--- a/apps/desktop/src/renderer/features/right-sidebar/lib/executeSidebarCommand.ts+++ b/apps/desktop/src/renderer/features/right-sidebar/lib/executeSidebarCommand.ts@@ -30,7 +30,9 @@ export async function executeSidebarCommand(command: RsbWindowCommand): Promise<return;}if (command.type === 'open-plugin-task') {- await openPluginTaskTab(command.sessionId, command.instanceId, { userInitiated: false });+ await openPluginTaskTab(command.sessionId, command.instanceId, {+ userInitiated: command.userInitiated === true,+ });return;}if (command.type === 'open-routines-tab') {diff --git a/apps/desktop/src/shared/rightSidebarWindow.ts b/apps/desktop/src/shared/rightSidebarWindow.tsindex d8e06f8f52..614498beb4 100644--- a/apps/desktop/src/shared/rightSidebarWindow.ts+++ b/apps/desktop/src/shared/rightSidebarWindow.ts@@ -43,7 +43,13 @@ export interface RsbWindowContext {export type RsbWindowCommand =| { type: 'open-routines-tab'; sessionId: string; botId: string }/** 打开 / 聚焦插件任务页(taskView):instanceId 是已装插件实例的存储键。 */- | { type: 'open-plugin-task'; sessionId: string; instanceId: string }+ | {+ type: 'open-plugin-task';+ sessionId: string;+ instanceId: string;+ /** Main 从路由请求写入的来源;缺省为被动,仅用于保留选中与焦点语义。 */+ userInitiated?: boolean;+ }| { type: 'open-terminal'; sessionId: string }| { type: 'toggle-review-tab'; sessionId: string }| { type: 'open-web-browser'; sessionId: string; url: string }diff --git a/docs/dev-rules/plugin-security-and-authoring.md b/docs/dev-rules/plugin-security-and-authoring.mdindex f6680367d5..0987815e87 100644--- a/docs/dev-rules/plugin-security-and-authoring.md+++ b/docs/dev-rules/plugin-security-and-authoring.md@@ -763,10 +763,19 @@ Forge 新装默认 root,不按当前登录组织自动创建组织实例。已`taskView`(跟对话的任务页)的现行协议在 `FORGE_GUIDE` §4.22;v2 对应 `task-view` 槽。任务页页签(右侧栏 kind `plugin-task`)存在各任务自己的页签桶里,随任务切换;页面与panel / mainView 同一 Ghost WebView 沙箱(零桥、专属分区),只经查询参数 `session`-得知所在任务。逻辑页经 `cindy.taskView({sessionId?})`(管子 `task-view-request`)打开或-聚焦它:只承载包内页面、不收网址,因此不设 preview 式白名单与限速;Host 只做资格审+得知所在任务。逻辑页经 `cindy.taskView({sessionId?, focus?})`(管子 `task-view-request`)+打开或聚焦它:只承载包内页面、不收网址,因此不设 preview 式白名单与限速。Host 做资格审(已装、启用、声明 taskView)与落点解析(显式任务优先,缺省台前任务),回执带回落点-任务。远程任务不投影本机插件的任务页;插件停用、卸载或不再声明 taskView 时页签隐藏。+任务。缺省或 `focus: false` 只打开页签,不切换任务或抢前台。+用户点击跳转时可传 `focus: true`:Host 须消费该插件实例最近 3 秒内的真实鼠标/键盘手势+(复用派活的一次性账本),无手势、过期或已消费均返回 `PERMISSION_DENIED`,不开页也不导航。+有效请求复用任务导航切到目标任务,并按用户操作显示任务页签;内嵌、分离侧栏和弹出页签均+保留用户放置位置,分离命令由 Main 沿既有路由与排队路径传递来源,不在执行端降级为后台。+成功回执的 `focusRequested: true` 仅表示导航请求已投递,不保证任务存在或已呈现;+旧 Host 可能忽略 focus,缺该回执字段时插件应提示更新。`peek: true` 始终只查询落点,+即使同时传 focus 也不消费手势或导航。实现与回归见 `taskViewSlot.ts`、`taskViewSlot.test.ts`+和 right-sidebar 的 `openPluginTaskTab.test.ts`、`executeSidebarCommand.test.ts`。+远程任务不投影本机插件的任务页;插件停用、卸载或不再声明 taskView 时页签隐藏。使用该能力的插件须声明实际支持且完成整包验收的最低宿主版本。旧 Host 可能保留未知顶层字段,但会拒绝 `locale.taskView` 或 v2 的 `task-view` 槽;运行时检测 API 不能替代安装兼容验证。`mainView.icon` 只接受 Cindy 系统线性图标