Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 远程 Agent 任务可以移动到其他项目
Lizi28af2225d3ec
diff --git a/apps/desktop/src/main/mcp-integrations/__tests__/moveSession.test.ts b/apps/desktop/src/main/mcp-integrations/__tests__/moveSession.test.tsindex 27542eade7..8d827c008e 100644--- a/apps/desktop/src/main/mcp-integrations/__tests__/moveSession.test.ts+++ b/apps/desktop/src/main/mcp-integrations/__tests__/moveSession.test.ts@@ -194,6 +194,17 @@ describe('moveSession host', () => {},);+ it('moves a task whose agent runs on another computer', async () => {+ h.query.mockResolvedValue([+ { id: 'target', status: 'active', remoteHostId: null, agentDeviceId: 'device-b', source: null },+ ]);+ expect(await run(directory)).toMatchObject({ ok: true, workspaceKind: 'project' });+ expect(h.saved).toHaveBeenLastCalledWith({+ workingDir: directory.replaceAll('\\', '/'),+ workspaceKind: 'project',+ });+ });+it('does not report a committed move as rejected when IM attaches after the write', async () => {h.saved.mockImplementationOnce(() => {h.attached = true;diff --git a/apps/desktop/src/main/mcp-integrations/moveSession.ts b/apps/desktop/src/main/mcp-integrations/moveSession.tsindex b3ec055ad8..63c67350a5 100644--- a/apps/desktop/src/main/mcp-integrations/moveSession.ts+++ b/apps/desktop/src/main/mcp-integrations/moveSession.ts@@ -66,9 +66,8 @@ async function moveSessionProject(if (!target) throwIpcError('NOT_FOUND', 'Task does not exist in this account.');if (target.remoteHostId)throwIpcError('UNSUPPORTED_CAPABILITY', 'Remote tasks cannot be moved.');- // The agent's conversation record lives on that computer, keyed by the project path.- if (target.agentDeviceId)- throwIpcError('UNSUPPORTED_CAPABILITY', 'Tasks whose agent runs on another computer cannot be moved.');+ // A task whose agent runs on another computer may move: that computer keys the agent's+ // workspace (and its conversation record) by task id, not by this computer's project path.if (target.status !== 'active')throwIpcError('PRECONDITION_FAILED', 'Only active tasks can be moved.');// Review immutability is also enforced by updateSessionInDb for all callers.diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionCard.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionCard.tsxindex 62cb5211b7..232f3e7116 100644--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionCard.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionCard.tsx@@ -560,8 +560,7 @@ export const SessionCard = withSidebarNavigation<SessionCardProps>(function Sess!isEmpty &&!session.remoteHostId &&!session.deviceLinkDeviceId &&- // Agent 在另一台电脑运行:它的会话记录按项目路径存在那台,移动后无法继续。- !session.agentDeviceId &&+ // Agent 在另一台电脑运行的任务也可移动:那台按任务 id 定址 Agent 工作区,与本机路径无关。session.status !== 'archived';const moveToProjectSubmenu = canMoveToProject ? (diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionItem.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionItem.tsxindex 55989d3227..ee5cbd6fe6 100644--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionItem.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionItem.tsx@@ -808,8 +808,7 @@ export const SessionItem = withSidebarNavigation<SessionItemProps>(function Sess!isEmpty &&!session.remoteHostId &&!session.deviceLinkDeviceId &&- // Agent 在另一台电脑运行:它的会话记录按项目路径存在那台,移动后无法继续。- !session.agentDeviceId &&+ // Agent 在另一台电脑运行的任务也可移动:那台按任务 id 定址 Agent 工作区,与本机路径无关。session.status !== 'archived';// 导出 .cshare 的可见性:draft 无内容、remote 转录在远端、device-link 数据在diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionTaskMenu.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionTaskMenu.tsxindex 486028afc6..b57bd70622 100644--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionTaskMenu.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionTaskMenu.tsx@@ -283,8 +283,7 @@ function ActiveSessionTaskMenu({))}{!guest && (<>- {/* Agent 在另一台电脑运行的任务:Agent 会话记录在那台,移动与复制到其他电脑都会丢失它。 */}- {!archived && !empty && !session.remoteHostId && !session.agentDeviceId && (+ {!archived && !empty && !session.remoteHostId && (<TaskMoveSubmenusession={session}disabled={ownerActionsBlocked}diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/TaskMoveSubmenu.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/TaskMoveSubmenu.tsxindex b01500255f..b589c24927 100644--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/TaskMoveSubmenu.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/TaskMoveSubmenu.tsx@@ -188,8 +188,11 @@ export function TaskMoveSubmenu({) : (localProjects)}+ {/* Agent 在另一台电脑运行的任务可以换项目(那台按任务 id 定址 Agent 工作区),+ 但不能复制到其他电脑:Agent 会话记录在那台,复制带不走。 */}{['desktop', 'shared', 'feishu'].includes(session.source ?? 'desktop') &&- session.orcaRole !== 'worker' && (+ session.orcaRole !== 'worker' &&+ !session.agentDeviceId && (<><DropdownMenuSeparator /><div className="px-3 py-1.5 text-xs text-[var(--cmd-palette-item-meta)]">diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/SessionTaskMenu.test.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/SessionTaskMenu.test.tsxindex 42a97584a7..1c6f2cedb4 100644--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/SessionTaskMenu.test.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/SessionTaskMenu.test.tsx@@ -116,10 +116,10 @@ it('loads only on open and groups task organization, sharing, viewing and removaexpect(state.rowClick).not.toHaveBeenCalled();});-it('hides moving a task whose agent runs on another computer, since its agent record stays there', () => {+it('offers moving a task whose agent runs on another computer to another project', () => {render(<Harness target={{ ...session, agentDeviceId: 'device-b' } as Session} />);openMenu();- expect(labels()).not.toContain('moveToProject');+ expect(labels()).toContain('moveToProject');expect(labels()).toContain('openInNewWindow');});diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/TaskMoveSubmenu.test.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/TaskMoveSubmenu.test.tsxindex e3c4670a3b..fa5b5e3753 100644--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/TaskMoveSubmenu.test.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/TaskMoveSubmenu.test.tsx@@ -163,6 +163,13 @@ it.each(['bot'] as const)(},);+it('keeps project moves but hides cross-computer copies when the agent runs on another computer', async () => {+ await mount({ ...session, agentDeviceId: 'C' });+ expect(screen.getByRole('menuitem', { name: /another/ })).toBeTruthy();+ expect(screen.queryByText('taskMove.otherComputers')).toBeNull();+ expect(screen.queryByRole('menuitem', { name: 'B' })).toBeNull();+});+it.each(['desktop', 'shared', 'feishu'] as const)('keeps cross-computer migration for a %s task',async (source) => {diff --git a/docs/dev-rules/protocol-compatibility.md b/docs/dev-rules/protocol-compatibility.mdindex 3af39e087f..504c443877 100644--- a/docs/dev-rules/protocol-compatibility.md+++ b/docs/dev-rules/protocol-compatibility.md@@ -638,8 +638,10 @@ handler 无 sender 依赖;不加入共享任务访客白名单,不进入自分享者电脑、受邀者电脑与手机各过一遍。手机经同账号新 channel `maker:provider-share:received-catalogs`(进同账号 allowlist)读取被控电脑收到的分享及其目录;旧版电脑回 `CHANNEL_NOT_ALLOWED`,手机按没有分享处理。跨区域(P3)经服务端开关开放,受邀者用第二条 relay 连接(`ProviderShareGuest` 认证),见契约 §6。-- **暂不支持**:分叉、审查、移动项目、复制到其他电脑、导出 `.cshare`(Agent 会话记录在 B),入口隐藏、+- **暂不支持**:分叉、审查、复制到其他电脑、导出 `.cshare`(Agent 会话记录在 B),入口隐藏、主进程拒绝。+- **移动项目可用**:B 上的影子目录只按「控制端 + 任务 id」定址(虚拟工作区为必需能力),与 A 的工作目录+ 无关;A 换目录后关闭空闲 handle,下次发送按新目录重建,B 上的会话记录原样续用。## 事实来源