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。

feat(desktop): 统一协同模式入口 (#1353)

Dashc2689a104fe9
diff --git a/apps/desktop/help-knowledge/collaboration.md b/apps/desktop/help-knowledge/collaboration.md
index 259cd4ed40..19710e2dfe 100644
--- a/apps/desktop/help-knowledge/collaboration.md
+++ b/apps/desktop/help-knowledge/collaboration.md
@@ -7,7 +7,7 @@ Collaboration ("协同" / Collab) lets one session — the **lead** — bring in
**Turning it on:**
-- In a project session — local or SSH remote — click the **Collab** pill in the composer toolbar. Both Claude Code and Codex sessions can be the lead, on either side.
+- In any regular project or dialogue session, open the composer's **+** menu and choose **Collaboration mode**. You can also choose it before sending the first message of a new task. Both Claude Code and Codex sessions can be the lead.
- Pick the first worker's agent (Claude Code or Codex), and optionally its role / model / effort / an initial task.
- Start. This creates the team plus that first worker.
@@ -28,5 +28,5 @@ Collaboration ("协同" / Collab) lets one session — the **lead** — bring in
**Notes:**
-- The lead must be a Claude Code / Codex **project** session — local **or SSH remote**. On a remote lead, workers are spawned on the **same remote host**, and the collaboration MCP reaches the remote side over an SSH remote-forward to the local bridge (with a persistent bearer token). A worker can't start its own sub-collab (no nesting).
+- The lead can be a Claude Code / Codex **project or dialogue** session. On an SSH remote lead, workers are spawned on the **same remote host**, and the collaboration MCP reaches the remote side over an SSH remote-forward to the local bridge (with a persistent bearer token). A worker can't start its own sub-collab (no nesting).
- A lead can have only **one active collaboration workflow** at a time. If you have two clients open on the same account (e.g. dev + release) and start collab on the same session in both, the second fails with "开启协同失败" because a workflow is already active — close one client or end the existing collab.
diff --git a/apps/desktop/src/main/__tests__/makerSendToSessionOrdering.test.ts b/apps/desktop/src/main/__tests__/makerSendToSessionOrdering.test.ts
index 0fc47f9e74..9860617c58 100644
--- a/apps/desktop/src/main/__tests__/makerSendToSessionOrdering.test.ts
+++ b/apps/desktop/src/main/__tests__/makerSendToSessionOrdering.test.ts
@@ -119,6 +119,28 @@ describe('sendToSession ordering', () => {
expectOrder(policyGuardBlock, 'leadRow?.workingDir', 'lead?.workDir');
expect(policyGuardBlock).toContain(' : leadRow?.workspaceKind;');
expectOrder(policyGuardBlock, 'const liveWorkspaceKind =', 'assertCollabProjectEnabled(');
+ expect(policyGuardBlock).toContain(
+ 'matchDialogueWorkspacePath(workingDir, dialogueWorkspaceRootDir()) !== null',
+ );
+ });
+
+ it('uses the same trusted collab scope helper and acknowledges the accepted workspace kind', () => {
+ const pluginStateBlock = extractBetween(
+ source,
+ 'ipcMain.handle(MAKER_INVOKE.PLUGINS_GET_STATE',
+ 'ipcMain.handle(MAKER_INVOKE.PLUGINS_SET_ENABLED',
+ );
+
+ expect(pluginStateBlock).toContain('resolveLocalCollabPolicyWorkingDir(');
+ expect(pluginStateBlock).toContain("typeof workspaceKind === 'string' ? workspaceKind : null");
+ expect(pluginStateBlock).toContain(
+ 'matchDialogueWorkspacePath(candidate, dialogueWorkspaceRootDir()) !== null',
+ );
+ expect(pluginStateBlock).toContain('getEnableState(id, policyWorkingDir)');
+ expect(pluginStateBlock).toContain(
+ "workspaceKind === 'project' || workspaceKind === 'dialogue'",
+ );
+ expect(pluginStateBlock).toContain('collabWorkspaceKind: acceptedWorkspaceKind');
});
it('keeps non-composer direct sends from inheriting armed plan mode', () => {
diff --git a/apps/desktop/src/main/maker-host/plugins/plugin-registry.ts b/apps/desktop/src/main/maker-host/plugins/plugin-registry.ts
index 9b84c872dd..60586e2b2a 100644
--- a/apps/desktop/src/main/maker-host/plugins/plugin-registry.ts
+++ b/apps/desktop/src/main/maker-host/plugins/plugin-registry.ts
@@ -30,6 +30,8 @@ export interface PluginEnableState {
projectOverride?: { enabled: boolean; workingDir: string } | null;
userOverride?: { enabled: boolean } | null;
globalOverride?: { enabled: boolean } | null;
+ /** collab 查询对 workspaceKind 的显式确认;旧被控端缺省,控制端据此关闭 dialogue 入口。 */
+ collabWorkspaceKind?: 'project' | 'dialogue';
}
export interface PluginListItem {
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/collabProjectPolicy.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/collabProjectPolicy.test.ts
index 0d5109feaf..cb4aa2b59b 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/collabProjectPolicy.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/collabProjectPolicy.test.ts
@@ -1,8 +1,47 @@
import { describe, expect, it } from 'vitest';
-import { assertCollabProjectEnabled } from '../collabProjectPolicy.js';
+import {
+ assertCollabProjectEnabled,
+ resolveLocalCollabPolicyWorkingDir,
+} from '../collabProjectPolicy.js';
+
+describe('resolveLocalCollabPolicyWorkingDir', () => {
+ const isManagedDialogueWorkspace = (workingDir: string) =>
+ workingDir.startsWith('/app-managed/dialogues/');
+
+ it('drops app-managed dialogue cwd so policy queries use only the user/global level', () => {
+ expect(
+ resolveLocalCollabPolicyWorkingDir(
+ ' /app-managed/dialogues/2026-08-02/session-1 ',
+ 'dialogue',
+ isManagedDialogueWorkspace,
+ ),
+ ).toBeUndefined();
+ });
+
+ it('keeps and normalizes an explicitly bound real directory', () => {
+ expect(
+ resolveLocalCollabPolicyWorkingDir(
+ ' /projects/cindy ',
+ 'dialogue',
+ isManagedDialogueWorkspace,
+ ),
+ ).toBe('/projects/cindy');
+ });
+
+ it('keeps a project path even when it has the same shape as a managed dialogue cwd', () => {
+ expect(
+ resolveLocalCollabPolicyWorkingDir(
+ '/app-managed/dialogues/2026-08-02/session-1',
+ 'project',
+ isManagedDialogueWorkspace,
+ ),
+ ).toBe('/app-managed/dialogues/2026-08-02/session-1');
+ });
+});
describe('assertCollabProjectEnabled', () => {
+ const neverManagedDialogue = () => false;
const project = {
workingDir: 'C:\\projects\\cindy',
workspaceKind: 'project',
@@ -10,13 +49,15 @@ describe('assertCollabProjectEnabled', () => {
} as const;
it('allows an enabled local project', () => {
- expect(() => assertCollabProjectEnabled(project, () => true)).not.toThrow();
+ expect(() =>
+ assertCollabProjectEnabled(project, () => true, neverManagedDialogue),
+ ).not.toThrow();
});
it('rejects a project with collab disabled', () => {
- expect(() => assertCollabProjectEnabled(project, () => false)).toThrow(
- '[PRECONDITION_FAILED] collaboration is disabled for this project',
- );
+ expect(() =>
+ assertCollabProjectEnabled(project, () => false, neverManagedDialogue),
+ ).toThrow('[PRECONDITION_FAILED] collaboration is disabled for this session');
});
it('trims the working directory before checking the project policy', () => {
@@ -28,30 +69,111 @@ describe('assertCollabProjectEnabled', () => {
checkedPath = workingDir;
return true;
},
+ neverManagedDialogue,
),
).not.toThrow();
expect(checkedPath).toBe('C:\\projects\\cindy');
});
- it('rejects dialogue sessions regardless of plugin policy', () => {
- const isPluginEnabled = () => {
- throw new Error('must not query project policy for an ineligible session');
- };
+ it('allows dialogue sessions using only the user/global policy', () => {
+ for (const remoteHostId of [null, 'host-1'] as const) {
+ const calls: Array<string | undefined> = [];
+ expect(() =>
+ assertCollabProjectEnabled(
+ {
+ workingDir: '/app-managed/dialogues/2026-08-02/session-1',
+ workspaceKind: 'dialogue',
+ remoteHostId,
+ },
+ (_pluginId, workingDir) => {
+ calls.push(workingDir);
+ return true;
+ },
+ (workingDir) => workingDir.startsWith('/app-managed/dialogues/'),
+ ),
+ ).not.toThrow();
+ expect(calls).toEqual([undefined]);
+ }
+ });
+ it('rejects dialogue sessions when collab is disabled at the user/global level', () => {
expect(() =>
assertCollabProjectEnabled(
- { workingDir: null, workspaceKind: 'dialogue', remoteHostId: null },
- isPluginEnabled,
+ {
+ workingDir: '/app-managed/dialogues/2026-08-02/session-1',
+ workspaceKind: 'dialogue',
+ remoteHostId: null,
+ },
+ () => false,
+ (workingDir) => workingDir.startsWith('/app-managed/dialogues/'),
),
- ).toThrow('[PRECONDITION_FAILED] collaboration requires an enabled local project session');
+ ).toThrow('[PRECONDITION_FAILED] collaboration is disabled for this session');
+ });
- // 远端会话同样是项目会话才放行:无 workingDir 的远端 dialogue 照样拒绝。
+ it('applies project policy to a local dialogue that explicitly binds a real directory', () => {
+ const explicitWorkingDir = '/projects/private-collab-disabled';
+ const calls: Array<string | undefined> = [];
+ expect(() =>
+ assertCollabProjectEnabled(
+ {
+ workingDir: explicitWorkingDir,
+ workspaceKind: 'dialogue',
+ remoteHostId: null,
+ },
+ (_pluginId, workingDir) => {
+ calls.push(workingDir);
+ return false;
+ },
+ neverManagedDialogue,
+ ),
+ ).toThrow('[PRECONDITION_FAILED] collaboration is disabled for this session');
+ expect(calls).toEqual([explicitWorkingDir]);
+ });
+
+ it('does not let a project session skip its override just because the path resembles a managed cwd', () => {
+ const calls: Array<string | undefined> = [];
+ expect(() =>
+ assertCollabProjectEnabled(
+ {
+ workingDir: '/app-managed/dialogues/2026-08-02/session-1',
+ workspaceKind: 'project',
+ remoteHostId: null,
+ },
+ (_pluginId, workingDir) => {
+ calls.push(workingDir);
+ return true;
+ },
+ (workingDir) => workingDir.startsWith('/app-managed/dialogues/'),
+ ),
+ ).not.toThrow();
+ expect(calls).toEqual(['/app-managed/dialogues/2026-08-02/session-1']);
+ });
+
+ it('rejects unsupported workspace kinds and missing runtime directories', () => {
+ const mustNotQuery = () => {
+ throw new Error('must not query policy for an invalid session');
+ };
+ expect(() =>
+ assertCollabProjectEnabled(
+ { workingDir: '/tmp/session', workspaceKind: 'unknown', remoteHostId: null },
+ mustNotQuery,
+ neverManagedDialogue,
+ ),
+ ).toThrow('[PRECONDITION_FAILED] collaboration requires a supported lead session');
+ expect(() =>
+ assertCollabProjectEnabled(
+ { workingDir: null, workspaceKind: 'dialogue', remoteHostId: null },
+ mustNotQuery,
+ neverManagedDialogue,
+ ),
+ ).toThrow('[PRECONDITION_FAILED] collaboration requires a session working directory');
expect(() =>
assertCollabProjectEnabled(
- { workingDir: null, workspaceKind: 'dialogue', remoteHostId: 'host-1' },
- isPluginEnabled,
+ { workingDir: ' ', workspaceKind: 'project', remoteHostId: null },
+ mustNotQuery,
+ neverManagedDialogue,
),
- ).toThrow('[PRECONDITION_FAILED] collaboration requires an enabled local project session');
+ ).toThrow('[PRECONDITION_FAILED] collaboration requires a session working directory');
});
it('allows remote project sessions for both agents without querying local fs policy', () => {
@@ -67,6 +189,7 @@ describe('assertCollabProjectEnabled', () => {
calls.push(workingDir);
return true;
},
+ neverManagedDialogue,
),
).not.toThrow();
expect(calls).toEqual([undefined]);
@@ -80,7 +203,8 @@ describe('assertCollabProjectEnabled', () => {
assertCollabProjectEnabled(
{ ...project, workingDir: '/remote/repo', remoteHostId: 'host-1', agentKind: 'codex' },
() => false,
+ neverManagedDialogue,
),
- ).toThrow('[PRECONDITION_FAILED] collaboration is disabled for this project');
+ ).toThrow('[PRECONDITION_FAILED] collaboration is disabled for this session');
});
});
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/orcaWorkerCreationService.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/orcaWorkerCreationService.test.ts
index 5da0ff695a..6f5da01dce 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/orcaWorkerCreationService.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/orcaWorkerCreationService.test.ts
@@ -80,6 +80,7 @@ function createDeps(overrides: Partial<OrcaWorkerCreationDeps> = {}) {
getLeadSessionRow: vi.fn(async () => ({
id: 'lead-1',
agentKind: 'codex' as const,
+ workspaceKind: 'project' as const,
workingDir: 'C:\\repo',
model: 'gpt-5.5',
effort: 'medium',
@@ -296,6 +297,7 @@ describe('OrcaWorkerCreationService', () => {
const remoteLeadRow = {
id: 'lead-1',
agentKind: 'codex' as const,
+ workspaceKind: 'project' as const,
workingDir: '/srv/repo',
model: 'gpt-5.5',
effort: 'medium',
@@ -621,6 +623,7 @@ describe('OrcaWorkerCreationService', () => {
getLeadSessionRow: vi.fn(async () => ({
id: 'lead-1',
agentKind: 'codex' as const,
+ workspaceKind: 'project' as const,
workingDir: '/srv/repo',
model: 'gpt-5.5',
effort: 'medium',
@@ -663,11 +666,44 @@ describe('OrcaWorkerCreationService', () => {
expect('remoteHostId' in arg).toBe(false);
});
+ it('inherits dialogue workspace identity and the managed cwd from its lead', async () => {
+ const dialogueWorkingDir = '/app-managed/dialogues/2026-08-02/lead-1';
+ const { deps, service } = createDeps({
+ getLeadSessionRow: vi.fn(async () => ({
+ id: 'lead-1',
+ agentKind: 'codex' as const,
+ workspaceKind: 'dialogue' as const,
+ workingDir: dialogueWorkingDir,
+ model: 'gpt-5.5',
+ effort: 'medium',
+ permissionMode: 'default',
+ fastMode: false,
+ providerId: 'xd',
+ remoteHostId: null,
+ })),
+ });
+
+ await expect(
+ service.createWorker({
+ leadSessionId: 'lead-1',
+ role: 'reviewer',
+ agent: 'codex',
+ label: 'reviewer',
+ }),
+ ).resolves.toMatchObject({ ok: true });
+
+ expect(deps.buildCreateOptsWithStderr).toHaveBeenCalledWith(expect.objectContaining({
+ workspaceKind: 'dialogue',
+ workingDir: dialogueWorkingDir,
+ }));
+ });
+
it('normalizes inherited minimal effort from the lead session to low for a Codex GPT worker', async () => {
const { deps, service } = createDeps({
getLeadSessionRow: vi.fn(async () => ({
id: 'lead-1',
agentKind: 'codex' as const,
+ workspaceKind: 'project' as const,
workingDir: 'C:\\repo',
model: 'gpt-5.4-mini',
effort: 'minimal',
@@ -1734,6 +1770,7 @@ describe('SSH remote worker model/provider compatibility gate (R23 P2)', () => {
const remoteLeadRow = {
id: 'lead-1',
agentKind: 'codex' as const,
+ workspaceKind: 'project' as const,
workingDir: '/srv/repo',
model: 'gpt-5.5',
effort: 'medium',
@@ -1847,6 +1884,7 @@ describe('SSH remote worker model/provider compatibility gate (R23 P2)', () => {
getLeadSessionRow: vi.fn(async () => ({
id: 'lead-1',
agentKind: 'codex' as const,
+ workspaceKind: 'project' as const,
workingDir: '/srv/repo',
model: 'gpt-5.5',
effort: 'medium',
@@ -1888,6 +1926,7 @@ describe('SSH remote worker model/provider compatibility gate (R23 P2)', () => {
getLeadSessionRow: vi.fn(async () => ({
id: 'lead-1',
agentKind: 'codex' as const,
+ workspaceKind: 'project' as const,
workingDir: '/srv/repo',
model: 'deepseek-v4',
effort: 'medium',
diff --git a/apps/desktop/src/main/maker-ipc/collabProjectPolicy.ts b/apps/desktop/src/main/maker-ipc/collabProjectPolicy.ts
index 830bcb5647..4c95bf70a0 100644
--- a/apps/desktop/src/main/maker-ipc/collabProjectPolicy.ts
+++ b/apps/desktop/src/main/maker-ipc/collabProjectPolicy.ts
@@ -8,7 +8,31 @@ export interface CollabProjectPolicyContext {
}
/**
- * 协同 Team 只能由启用 collab 插件的项目会话创建;SSH 远端会话 codex 与
+ * Main 侧唯一的本地 collab 策略作用域判据。
+ *
+ * app 托管的 dialogue cwd 属于运行时目录,其中即使出现 `.cindy/plugins.json` 也不能把它
+ * 当成用户项目覆盖;显式绑定的真实目录则继续尊重项目策略。只有 workspaceKind 明确为
+ * dialogue 且 Main 自己验证路径归属时才跳过项目级,不能靠自报 kind 单独越权;项目会话
+ * 即使选中同形路径也保留项目语义。查询入口与最终授权必须共用这个函数,否则 UI 会与
+ * mutation 的 PRECONDITION 判定漂移。
+ */
+export function resolveLocalCollabPolicyWorkingDir(
+ workingDir: string,
+ workspaceKind: string | null | undefined,
+ isManagedDialogueWorkspace: (workingDir: string) => boolean,
+): string | undefined {
+ const normalizedWorkingDir = workingDir.trim();
+ if (
+ normalizedWorkingDir === '' ||
+ (workspaceKind === 'dialogue' && isManagedDialogueWorkspace(normalizedWorkingDir))
+ ) {
+ return undefined;
+ }
+ return normalizedWorkingDir;
+}
+
+/**
+ * 协同 Team 可由启用 collab 插件的普通 Lead 会话创建,项目与对话都支持;SSH 远端会话 codex 与
* claude-code 均已接通 —— 远端 agent 经 SSH remote-forward 直连本机 HTTP
* MCP bridge(codex 走 daemon config 注入 + persistent token,cc 走
* per-query http 注入 + persistent token 与 ?session= 路由),cindy_orca
@@ -16,7 +40,7 @@ export interface CollabProjectPolicyContext {
*
* device-link(跨设备远程控制)不需要在这里开任何例外:控制端的 enable-orca
* 经隧道路由到**被控端**执行,到了那一侧它就是一个普通本地会话
- * (remoteHostId 为空、workingDir 是被控端真实路径),自然走下面的本机项目级
+ * (remoteHostId 为空、workingDir 是被控端真实路径),自然走下面对应的项目级或用户级
* 分支。控制端 renderer 会先隧道读被控端的 collab 开关来置灰入口(见
* makerTransport.pluginEnableStateFor),那只是体验层的提前告知。
*
@@ -26,18 +50,20 @@ export interface CollabProjectPolicyContext {
export function assertCollabProjectEnabled(
context: CollabProjectPolicyContext,
isPluginEnabled: (pluginId: 'collab', workingDir?: string) => boolean,
+ isManagedDialogueWorkspace: (workingDir: string) => boolean,
): void {
const workingDir = typeof context.workingDir === 'string' ? context.workingDir.trim() : null;
- if (
- context.workspaceKind !== 'project' ||
- workingDir === null ||
- workingDir === ''
- ) {
+ if (context.workspaceKind !== 'project' && context.workspaceKind !== 'dialogue') {
throwIpcError(
'PRECONDITION_FAILED',
- 'collaboration requires an enabled local project session',
+ 'collaboration requires a supported lead session',
);
}
+ // 正常 dialogue 在 createSession 时已经拿到 app 托管的运行目录。这里仍要求非空,
+ // 防止损坏/legacy 行把空 cwd 带进 Worker bootstrap;区别只在它不参与项目级策略查询。
+ if (workingDir === null || workingDir === '') {
+ throwIpcError('PRECONDITION_FAILED', 'collaboration requires a session working directory');
+ }
// 远端会话的 workingDir 是远端机器上的路径, 在本机 fs 上查项目级插件配置
// (.cindy/plugins.json) 没有意义 —— 命中同路径的本机目录会误判, 查不到又
@@ -49,18 +75,19 @@ export function assertCollabProjectEnabled(
// 或 per-host 设置) 有需求时再做。
if (context.remoteHostId) {
if (!isPluginEnabled('collab')) {
- throwIpcError(
- 'PRECONDITION_FAILED',
- 'collaboration is disabled for this project',
- );
+ throwIpcError('PRECONDITION_FAILED', 'collaboration is disabled for this session');
}
return;
}
- if (!isPluginEnabled('collab', workingDir)) {
- throwIpcError(
- 'PRECONDITION_FAILED',
- 'collaboration is disabled for this project',
- );
+ // Main 按 dialogue kind + 路径归属解析策略作用域,不信任 workspaceKind 单独裁决。这个判据也被
+ // PLUGINS_GET_STATE 查询复用,保证入口置灰与最终授权读取同一层 override。
+ const policyWorkingDir = resolveLocalCollabPolicyWorkingDir(
+ workingDir,
+ context.workspaceKind,
+ isManagedDialogueWorkspace,
+ );
+ if (!isPluginEnabled('collab', policyWorkingDir)) {
+ throwIpcError('PRECONDITION_FAILED', 'collaboration is disabled for this session');
}
}
diff --git a/apps/desktop/src/main/maker-ipc/helpKnowledge.generated.ts b/apps/desktop/src/main/maker-ipc/helpKnowledge.generated.ts
index 28e23d14dd..122e73f0da 100644
--- a/apps/desktop/src/main/maker-ipc/helpKnowledge.generated.ts
+++ b/apps/desktop/src/main/maker-ipc/helpKnowledge.generated.ts
@@ -28,7 +28,7 @@ export const HELP_KNOWLEDGE: HelpKnowledgeDoc[] = [
id: "collaboration",
title: "Collaboration mode (lead + workers)",
summary: "Turn on Collab to bring one or more worker agents in beside your session and delegate tasks to them.",
- content: "Collaboration (\"协同\" / Collab) lets one session — the **lead** — bring in one or more **worker** agents to run alongside it (a \"team\"). The lead delegates tasks to workers through a built-in MCP, and you can watch and steer each worker.\n\n**Turning it on:**\n\n- In a project session — local or SSH remote — click the **Collab** pill in the composer toolbar. Both Claude Code and Codex sessions can be the lead, on either side.\n- Pick the first worker's agent (Claude Code or Codex), and optionally its role / model / effort / an initial task.\n- Start. This creates the team plus that first worker.\n\n**Adding more workers:**\n\n- From the collaboration tab's worker list, use **Create new worker** (+) to add more.\n- Default limits are a **soft cap of 5** and a **hard cap of 8** workers per lead — you'll see a warning past the soft cap, and creation is blocked at the hard cap. Both are adjustable (1–20) in the Collaboration section under **Settings > General**.\n\n**While collaborating:**\n\n- Each worker is a full session with its own history, tools, working directory, and model, and runs with permissions bypassed so it doesn't stop to ask. It inherits the lead's working directory by default (or shares the worktree when the lead uses one).\n- A worker's model defaults to your last new-session choice for that vendor, falling back to the lead's model.\n- Only one worker is **focused** (shown) at a time — switch between them with the worker tabs / dropdown. You can intervene in any worker directly, and archive workers individually.\n\n**Turning it off:**\n\n- Closing collab **confirms with you first** (in-progress work is lost), then ends the workflow and archives **all** the team's workers. The conversation history stays searchable.\n\n**Notes:**\n\n- The lead must be a Claude Code / Codex **project** session — local **or SSH remote**. On a remote lead, workers are spawned on the **same remote host**, and the collaboration MCP reaches the remote side over an SSH remote-forward to the local bridge (with a persistent bearer token). A worker can't start its own sub-collab (no nesting).\n- A lead can have only **one active collaboration workflow** at a time. If you have two clients open on the same account (e.g. dev + release) and start collab on the same session in both, the second fails with \"开启协同失败\" because a workflow is already active — close one client or end the existing collab.",
+ content: "Collaboration (\"协同\" / Collab) lets one session — the **lead** — bring in one or more **worker** agents to run alongside it (a \"team\"). The lead delegates tasks to workers through a built-in MCP, and you can watch and steer each worker.\n\n**Turning it on:**\n\n- In any regular project or dialogue session, open the composer's **+** menu and choose **Collaboration mode**. You can also choose it before sending the first message of a new task. Both Claude Code and Codex sessions can be the lead.\n- Pick the first worker's agent (Claude Code or Codex), and optionally its role / model / effort / an initial task.\n- Start. This creates the team plus that first worker.\n\n**Adding more workers:**\n\n- From the collaboration tab's worker list, use **Create new worker** (+) to add more.\n- Default limits are a **soft cap of 5** and a **hard cap of 8** workers per lead — you'll see a warning past the soft cap, and creation is blocked at the hard cap. Both are adjustable (1–20) in the Collaboration section under **Settings > General**.\n\n**While collaborating:**\n\n- Each worker is a full session with its own history, tools, working directory, and model, and runs with permissions bypassed so it doesn't stop to ask. It inherits the lead's working directory by default (or shares the worktree when the lead uses one).\n- A worker's model defaults to your last new-session choice for that vendor, falling back to the lead's model.\n- Only one worker is **focused** (shown) at a time — switch between them with the worker tabs / dropdown. You can intervene in any worker directly, and archive workers individually.\n\n**Turning it off:**\n\n- Closing collab **confirms with you first** (in-progress work is lost), then ends the workflow and archives **all** the team's workers. The conversation history stays searchable.\n\n**Notes:**\n\n- The lead can be a Claude Code / Codex **project or dialogue** session. On an SSH remote lead, workers are spawned on the **same remote host**, and the collaboration MCP reaches the remote side over an SSH remote-forward to the local bridge (with a persistent bearer token). A worker can't start its own sub-collab (no nesting).\n- A lead can have only **one active collaboration workflow** at a time. If you have two clients open on the same account (e.g. dev + release) and start collab on the same session in both, the second fails with \"开启协同失败\" because a workflow is already active — close one client or end the existing collab.",
},
{
id: "commands",
@@ -144,7 +144,7 @@ export const HELP_KNOWLEDGE: HelpKnowledgeDoc[] = [
id: "skills",
title: "Skills (reusable agent capabilities)",
summary: "Browse, install, publish, and update agent skills; installed skills appear as \"/\" slash commands and are shared across Claude Code and Codex.",
- content: "Skills are reusable agent capabilities you package as a folder and load into your sessions. They're managed on the same page as Plugins — **Skills** and **Plugins** are two tabs of one management surface (the Skills tab is the in-app browser for finding, installing, publishing, and updating skills).\n\n**Skills work with both agents:**\n\n- Skills are **engine-shared** — the same installed skill is available to both Claude Code and Codex, so you install it once.\n\n**Where skills live on disk:**\n\n- Global (available to every session): the shared root `~/.agents/skills/<name>/`, which is cross-linked to `~/.claude/skills/` and `~/.codex/skills/` so every engine sees the same skills. On Windows that's under `C:\\Users\\<you>\\`.\n- Project-scoped (only inside one working directory): `<working-dir>/.agents/skills/<name>/` or `<working-dir>/.claude/skills/<name>/`.\n- Each skill is its own folder with a required `SKILL.md` at the root (the prompt / spec the agent reads). Sibling files and subfolders in that folder are also visible to the agent.\n\n**Using an installed skill:**\n\n- Type `/` in the composer to open the slash-command palette; your installed skills show up there alongside built-in and agent commands. Pick one to run it.\n\n**Publishing your own skill:**\n\n- Find the publish action on the Skills page and point it at the skill's local folder. It zips the folder and uploads it — reading your directory in place, without copying or moving anything.\n- On first publish, you set the skill's **visibility**: PUBLIC (anyone in the org) or DEPARTMENT_SCOPED (only the departments you choose).\n- The local registry records what you published, so the app knows it's \"yours\" for future updates.\n\n**Updating an already-published skill:**\n\n- On your own skill's detail page you'll see a **发布新版本** (Publish New Version) button.\n- Edit the local folder however you want and publish — the version is **auto-incremented server-side**, you don't pick a number.\n- **Old versions stay live alongside the new one.** Users who already installed an older version keep it until they choose to update.\n- The display name and description are sent on every republish, so editing those metadata fields just means doing a republish.\n\n**Managing an already-published skill:**\n\n- Change who can see or use your skill from the management menu — public, shared with selected teams / departments, or private to you.\n- **Unpublish** makes it private again and returns ownership to your personal scope; it does not remove copies other users already installed.\n- **Authorship is fixed.** Only the original author's account can publish new versions of a given skill (enforced server-side as `NOT_AUTHOR`).\n\n**Browsing and installing others' skills:**\n\n- The marketplace lets you install skills into your global skills directory. You can request a specific version on install; the local registry tracks which version you have.\n\n**Notes:**\n\n- A skill folder without a `SKILL.md` at its root won't be picked up (lowercase `skill.md` is also accepted).\n- Project-scoped skills only show up in sessions whose working directory matches — useful for skills tied to a particular repo's conventions.\n- Editing files inside an installed skill folder takes effect on the next session start; you don't need to reinstall.\n- Uninstalling only removes your local copy. For your own published skills, use unpublish or manage visibility to change market availability.",
+ content: "Skills are reusable agent capabilities you package as a folder and load into your sessions. They're managed on the same page as Plugins — **Skills** and **Plugins** are two tabs of one management surface (the Skills tab is the in-app browser for finding, installing, publishing, and updating skills).\n\n**Skills work with both agents:**\n\n- Skills are **engine-shared** — the same installed skill is available to both Claude Code and Codex, so you install it once.\n\n**Where skills live on disk:**\n\n- Global (available to every session): the shared root `~/.agents/skills/<name>/`, which is cross-linked to `~/.claude/skills/` and `~/.codex/skills/` so every engine sees the same skills. On Windows that's under `C:\\Users\\<you>\\`.\n- Project-scoped (only inside one working directory): `<working-dir>/.agents/skills/<name>/` or `<working-dir>/.claude/skills/<name>/`.\n- Each skill is its own folder with a required `SKILL.md` at the root (the prompt / spec the agent reads). Sibling files and subfolders in that folder are also visible to the agent.\n\n**Importing a local skill:**\n\n- On the Skills page, use **Import skill** (top-right) to pick a `.zip` package or a standalone `SKILL.md` file.\n- A zip must contain a `SKILL.md` (at the package root, or inside a single top-level folder). The YAML frontmatter must include non-empty `name` and `description` fields; `name` must match `^[a-z0-9-]{1,200}$`.\n- You then choose where to install: global, a known project, or another directory. Cindy extracts metadata from the file automatically and lists the skill with that name and description.\n- Imported skills can be uninstalled from the detail page, and you can publish them to SkillHub later if you want.\n\n**Using an installed skill:**\n\n- Type `/` in the composer to open the slash-command palette; your installed skills show up there alongside built-in and agent commands. Pick one to run it.\n\n**Publishing your own skill:**\n\n- Find the publish action on the Skills page and point it at the skill's local folder. It zips the folder and uploads it — reading your directory in place, without copying or moving anything.\n- On first publish, you set the skill's **visibility**: PUBLIC (anyone in the org) or DEPARTMENT_SCOPED (only the departments you choose).\n- The local registry records what you published, so the app knows it's \"yours\" for future updates.\n\n**Updating an already-published skill:**\n\n- On your own skill's detail page you'll see a **发布新版本** (Publish New Version) button.\n- Edit the local folder however you want and publish — the version is **auto-incremented server-side**, you don't pick a number.\n- **Old versions stay live alongside the new one.** Users who already installed an older version keep it until they choose to update.\n- The display name and description are sent on every republish, so editing those metadata fields just means doing a republish.\n\n**Managing an already-published skill:**\n\n- Change who can see or use your skill from the management menu — public, shared with selected teams / departments, or private to you.\n- **Unpublish** makes it private again and returns ownership to your personal scope; it does not remove copies other users already installed.\n- **Authorship is fixed.** Only the original author's account can publish new versions of a given skill (enforced server-side as `NOT_AUTHOR`).\n\n**Browsing and installing others' skills:**\n\n- The marketplace lets you install skills into your global skills directory. You can request a specific version on install; the local registry tracks which version you have.\n\n**Notes:**\n\n- A skill folder without a `SKILL.md` at its root won't be picked up (lowercase `skill.md` is also accepted).\n- Project-scoped skills only show up in sessions whose working directory matches — useful for skills tied to a particular repo's conventions.\n- Editing files inside an installed skill folder takes effect on the next session start; you don't need to reinstall.\n- Uninstalling only removes your local copy. For your own published skills, use unpublish or manage visibility to change market availability.",
},
{
id: "updates-and-about",
diff --git a/apps/desktop/src/main/maker-ipc/orcaWorkerCreationService.ts b/apps/desktop/src/main/maker-ipc/orcaWorkerCreationService.ts
index 87a61c99b6..8a29530a85 100644
--- a/apps/desktop/src/main/maker-ipc/orcaWorkerCreationService.ts
+++ b/apps/desktop/src/main/maker-ipc/orcaWorkerCreationService.ts
@@ -16,6 +16,7 @@ export interface OrcaTeamSnapshot {
export interface OrcaLeadSessionSnapshot {
id: string;
agentKind: AgentKind;
+ workspaceKind: 'project' | 'dialogue';
workingDir: string | null;
model: string;
effort: string | null;
@@ -790,6 +791,9 @@ export function createOrcaWorkerCreationService(deps: OrcaWorkerCreationDeps): O
const workerOpts = deps.buildCreateOptsWithStderr({
id: workerSessionId,
agentKind: params.agent,
+ // Worker 与 Lead 共享同一种 workspace 语义。dialogue Lead 虽然已有 main 自动分配
+ // 的运行目录,也不能把 Worker 落成 project,否则侧栏分组和项目能力都会误判。
+ workspaceKind: lead.workspaceKind,
workingDir: lead.workingDir ?? '',
// remote lead 的 worker 继承 remoteHostId:在同一台远端主机上 spawn,
// 与 lead 共享远端 workingDir;本地 lead 不带此字段 (本地 worker)。
diff --git a/apps/desktop/src/main/maker-ipc/register.ts b/apps/desktop/src/main/maker-ipc/register.ts
index ce93783318..53d7949aa5 100644
--- a/apps/desktop/src/main/maker-ipc/register.ts
+++ b/apps/desktop/src/main/maker-ipc/register.ts
@@ -129,7 +129,10 @@ import {
saveAgentInputQueueSnapshot,
} from '../localDb/agentInputQueueSnapshots.js';
import { ensureDialogueWorkspaceDir, dialogueWorkspaceRootDir } from '../localDb/dialogueWorkspace.js';
-import { healMissingDialogueWorkdir } from '../localDb/dialogueWorkdirSelfHeal.js';
+import {
+ healMissingDialogueWorkdir,
+ matchDialogueWorkspacePath,
+} from '../localDb/dialogueWorkdirSelfHeal.js';
import {
broadcastMessageRow,
broadcastMessageDeleted,
@@ -215,7 +218,10 @@ import {
writeMemorySetting,
} from '../maker-host/memory-settings-store.js';
import { GLOBAL_PLUGIN_IDS } from '../maker-host/plugins/types.js';
-import { assertCollabProjectEnabled } from './collabProjectPolicy.js';
+import {
+ assertCollabProjectEnabled,
+ resolveLocalCollabPolicyWorkingDir,
+} from './collabProjectPolicy.js';
import type { GitSnapshotCoordinator } from '../git-snapshot/gitSnapshotCoordinator.js';
import {
getRemoteNewMakerDefaults,
@@ -5768,6 +5774,8 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
agentKind: lead?.agentKind ?? leadRow?.agentKind ?? null,
},
(pluginId, workingDir) => getPluginRegistry().isEnabled(pluginId, workingDir),
+ (workingDir) =>
+ matchDialogueWorkspacePath(workingDir, dialogueWorkspaceRootDir()) !== null,
);
}
@@ -7153,6 +7161,7 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
// 走转换正本:pi lead 不能被压成 claude-code,否则 input.agent===lead.agentKind
// 判等失效,pi-lead 建 pi-worker 会走错默认分支(见 orcaWorkerCreationService)。
agentKind: dbToMakerAgentKind(leadRow.agentKind),
+ workspaceKind: leadRow.workspaceKind,
workingDir: leadRow.workingDir,
model: leadRow.model,
effort: leadRow.effort,
@@ -9815,12 +9824,39 @@ export function registerMakerIpc(maker: Maker, options: RegisterMakerIpcOptions)
// Read one plugin's enable state by id. Unlike PLUGINS_LIST this does NOT skip
// hidden (HOSTED_ELSEWHERE) plugins, so a dedicated Settings section (e.g.
// 「电脑使用」for `browser`) can read its real project-override state.
- ipcMain.handle(MAKER_INVOKE.PLUGINS_GET_STATE, async (_e, id: unknown, workingDir: unknown) => {
+ ipcMain.handle(MAKER_INVOKE.PLUGINS_GET_STATE, async (
+ _e,
+ id: unknown,
+ workingDir: unknown,
+ workspaceKind: unknown,
+ ) => {
if (typeof id !== 'string') {
throwIpcError('INVALID_PARAMS', 'id (string) required');
}
const wd = typeof workingDir === 'string' ? workingDir : undefined;
- return getPluginRegistry().getEnableState(id, wd);
+ // collab 的 app 托管 dialogue cwd 只读取用户/全局级;显式真实目录仍读取项目覆盖。
+ // 这里与 mutation 最终授权共用「dialogue kind + Main 可信路径」判据,device-link
+ // 隧道到被控端后也由被控端自己的 dialogue root 解析,Renderer 无需知道或猜 userData。
+ const policyWorkingDir =
+ id === 'collab' && wd !== undefined
+ ? resolveLocalCollabPolicyWorkingDir(
+ wd,
+ typeof workspaceKind === 'string' ? workspaceKind : null,
+ (candidate) =>
+ matchDialogueWorkspacePath(candidate, dialogueWorkspaceRootDir()) !== null,
+ )
+ : wd;
+ const state = await getPluginRegistry().getEnableState(id, policyWorkingDir);
+ const acceptedWorkspaceKind =
+ id === 'collab' && (workspaceKind === 'project' || workspaceKind === 'dialogue')
+ ? workspaceKind
+ : undefined;
+ // 远端控制端不能只靠 channel 存在判断 dialogue 协同:旧被控端也已有这个 channel,
+ // 但它会忽略第三个参数,且最终授权不接受 dialogue。回显被 Main 接受的 kind 作为
+ // 同一次只读查询的向后兼容握手;旧端缺字段,新端即可 fail-closed。
+ return acceptedWorkspaceKind
+ ? { ...state, collabWorkspaceKind: acceptedWorkspaceKind }
+ : state;
});
ipcMain.handle(MAKER_INVOKE.PLUGINS_SET_ENABLED, async (_e, id: unknown, enabled: unknown) => {
diff --git a/apps/desktop/src/preload/preload.ts b/apps/desktop/src/preload/preload.ts
index bb47e79c39..4745a8889c 100644
--- a/apps/desktop/src/preload/preload.ts
+++ b/apps/desktop/src/preload/preload.ts
@@ -569,6 +569,7 @@ interface PluginEnableState {
projectOverride?: { enabled: boolean; workingDir: string } | null;
userOverride?: { enabled: boolean } | null;
globalOverride?: { enabled: boolean } | null;
+ collabWorkspaceKind?: 'project' | 'dialogue';
}
interface PluginEnableUpdateResult {
@@ -5418,8 +5419,12 @@ contextBridge.exposeInMainWorld('electronAPI', {
plugins: {
list: (workingDir?: string): Promise<PluginListItem[]> =>
ipcRenderer.invoke('maker:plugins:list', workingDir),
- getState: (id: string, workingDir?: string): Promise<PluginEnableState> =>
- ipcRenderer.invoke('maker:plugins:get-state', id, workingDir),
+ getState: (
+ id: string,
+ workingDir?: string,
+ workspaceKind?: string | null,
+ ): Promise<PluginEnableState> =>
+ ipcRenderer.invoke('maker:plugins:get-state', id, workingDir, workspaceKind),
setEnabled: (id: string, enabled: boolean): Promise<PluginEnableUpdateResult> =>
ipcRenderer.invoke('maker:plugins:set-enabled', id, enabled),
clearEnabled: (id: string): Promise<PluginEnableUpdateResult> =>
diff --git a/apps/desktop/src/renderer/__tests__/collabEntryPolicy.test.ts b/apps/desktop/src/renderer/__tests__/collabEntryPolicy.test.ts
index e2a442149d..2d4604e1b3 100644
--- a/apps/desktop/src/renderer/__tests__/collabEntryPolicy.test.ts
+++ b/apps/desktop/src/renderer/__tests__/collabEntryPolicy.test.ts
@@ -47,15 +47,23 @@ describe('resolveCollabEntryPolicy 五类场景', () => {
expect(scope.skipProjectQuery).toBe(false);
});
- it('对话模式(无项目目录):不挂入口', () => {
- // dialogue 会话在 main 侧也会拿到一个自动分配的运行目录,所以必须靠 workspaceKind
- // 判定,不能从 workingDir 反推。
+ it('对话模式:可挂入口;已有目录交给 Main 区分托管目录与显式真实目录', () => {
+ // 已创建 dialogue 的 workingDir 可能是 app 托管目录,也可能是显式真实目录。
+ // Renderer 不持有受信任的 root,所以统一把目录交给 Main 查询:前者无项目配置时自然
+ // 回落全局,后者必须尊重项目覆盖,避免入口放行后才撞授权拒绝。
expect(
resolveCollabEntryPolicy({
workspaceKind: 'dialogue',
workingDir: '/Users/me/Library/.../dialogues/2026-07-31/s1',
- }).eligible,
- ).toBe(false);
+ }),
+ ).toEqual({ eligible: true, skipProjectQuery: false });
+ // 草稿还没创建 session,自然没有 main 分配的运行目录,入口同样应出现。
+ expect(
+ resolveCollabEntryPolicy({ workspaceKind: 'dialogue', workingDir: null }),
+ ).toEqual({ eligible: true, skipProjectQuery: true });
+ });
+
+ it('项目模式仍要求有效目录', () => {
expect(
resolveCollabEntryPolicy({ workspaceKind: 'project', workingDir: null }).eligible,
).toBe(false);
@@ -64,6 +72,26 @@ describe('resolveCollabEntryPolicy 五类场景', () => {
).toBe(false);
});
+ it('device-link 对话草稿:隧道到被控设备,并只查它的用户/全局级', () => {
+ expect(
+ resolveCollabEntryPolicy({
+ workspaceKind: 'dialogue',
+ workingDir: null,
+ deviceLinkDeviceId: 'dev-1',
+ }),
+ ).toEqual({ eligible: true, policyDeviceId: 'dev-1', skipProjectQuery: true });
+ });
+
+ it('device-link 已创建对话:把目录隧道到被控端查询', () => {
+ expect(
+ resolveCollabEntryPolicy({
+ workspaceKind: 'dialogue',
+ workingDir: '/Users/other/dialogues/2026-08-02/session-1',
+ deviceLinkDeviceId: 'dev-1',
+ }),
+ ).toEqual({ eligible: true, policyDeviceId: 'dev-1', skipProjectQuery: false });
+ });
+
it('Orca Worker 子会话:不挂入口(worker 自己不能再开协同)', () => {
expect(
resolveCollabEntryPolicy({
@@ -72,6 +100,13 @@ describe('resolveCollabEntryPolicy 五类场景', () => {
orcaRole: 'worker',
}).eligible,
).toBe(false);
+ expect(
+ resolveCollabEntryPolicy({
+ workspaceKind: 'dialogue',
+ workingDir: '/app-managed/dialogues/2026-08-02/worker-1',
+ orcaRole: 'worker',
+ }).eligible,
+ ).toBe(false);
});
it('Orca Lead 会话本身仍 eligible(ON 态的 pill 要能渲染成关闭按钮)', () => {
@@ -116,6 +151,7 @@ describe('drift 守卫:两个入口共用同一份判定', () => {
const src = read(f);
expect(src, f).toContain('resolveCollabEntryPolicy({');
expect(src, f).toContain('collabEntry.eligible');
+ expect(src, f).toContain('workspaceKind: collabWorkspaceKind');
// 内联判据的两个历史形态:草稿的 `effectiveDeviceLinkDeviceId == null`(把
// device-link 整个排除掉)与会话页的 `orcaRole !== 'worker'` 链。
expect(src, f).not.toContain('effectiveDeviceLinkDeviceId == null');
diff --git a/apps/desktop/src/renderer/__tests__/dialogueSidebarSection.test.ts b/apps/desktop/src/renderer/__tests__/dialogueSidebarSection.test.ts
index 743632ed1a..ada7fc19b7 100644
--- a/apps/desktop/src/renderer/__tests__/dialogueSidebarSection.test.ts
+++ b/apps/desktop/src/renderer/__tests__/dialogueSidebarSection.test.ts
@@ -124,7 +124,7 @@ describe('Dialogue sidebar section', () => {
});
it('creates a standalone dialogue without inheriting a project draft directory', () => {
- expect(sidebarSource).toContain('patchNewMakerDraft({ workingDir: null, remoteHostId: null, extraDirs: [] })');
+ expect(sidebarSource).toContain('resetDraftWorkspaceTargets();');
expect(sidebarSource).toMatch(/navigate\(['`]\/cc-agent\/new['`],\s*\{\s*state:\s*makeNewMakerRouteState\('dialogue'\)\s*\}\)/);
expect(sidebarSource).toContain('onCreateDialogue={handleCreateDialogue}');
});
diff --git a/apps/desktop/src/renderer/__tests__/makerTransportRouting.test.ts b/apps/desktop/src/renderer/__tests__/makerTransportRouting.test.ts
index d322b43827..e57734bd8e 100644
--- a/apps/desktop/src/renderer/__tests__/makerTransportRouting.test.ts
+++ b/apps/desktop/src/renderer/__tests__/makerTransportRouting.test.ts
@@ -248,18 +248,25 @@ describe('makerApiFor 路由(完整对等会话级操作)', () => {
invoke.mockResolvedValue({ effectiveEnabled: false });
const { pluginEnableStateFor } = await import('@/lib/makerTransport');
- await expect(pluginEnableStateFor('dev-1', 'collab', '/host/proj')).resolves.toEqual({
+ await expect(
+ pluginEnableStateFor('dev-1', 'collab', '/host/proj', 'project'),
+ ).resolves.toEqual({
effectiveEnabled: false,
});
expect(invoke).toHaveBeenCalledWith('dev-1', 'maker:plugins:get-state', [
'collab',
'/host/proj',
+ 'project',
]);
expect(makerSpies.plugins.getState).not.toHaveBeenCalled();
invoke.mockClear();
- await pluginEnableStateFor(null, 'collab', '/local/proj');
- expect(makerSpies.plugins.getState).toHaveBeenCalledWith('collab', '/local/proj');
+ await pluginEnableStateFor(null, 'collab', '/local/proj', 'project');
+ expect(makerSpies.plugins.getState).toHaveBeenCalledWith(
+ 'collab',
+ '/local/proj',
+ 'project',
+ );
expect(invoke).not.toHaveBeenCalled();
// skipQuery 档(SSH 远端):不传 workingDir → 落用户级/全局级,两条路由都要保持原样透传。
diff --git a/apps/desktop/src/renderer/__tests__/morphPopover.test.tsx b/apps/desktop/src/renderer/__tests__/morphPopover.test.tsx
index e669abbfd0..36332038df 100644
--- a/apps/desktop/src/renderer/__tests__/morphPopover.test.tsx
+++ b/apps/desktop/src/renderer/__tests__/morphPopover.test.tsx
@@ -140,6 +140,87 @@ describe('MorphPopover interaction contract', () => {
expect(document.activeElement).toBe(screen.getByRole('button', { name: 'Destination' }));
});
+ it('鼠标选择菜单动作后不回焦 trigger,避免重新弹出 trigger tooltip', async () => {
+ function PointerSelectionHarness() {
+ const [open, setOpen] = useState(false);
+ return (
+ <MorphPopover
+ open={open}
+ onOpenChange={setOpen}
+ trigger={
+ <button type="button" onClick={() => setOpen(true)}>
+ Toggle
+ </button>
+ }
+ >
+ <button type="button" onClick={() => setOpen(false)}>
+ Select action
+ </button>
+ </MorphPopover>
+ );
+ }
+
+ render(<PointerSelectionHarness />);
+ const trigger = screen.getByRole('button', { name: 'Toggle' });
+ fireEvent.click(trigger);
+ const action = await screen.findByRole('button', { name: 'Select action' });
+ action.focus();
+ fireEvent.pointerDown(action);
+ fireEvent.click(action);
+
+ await waitFor(() =>
+ expect(screen.queryByRole('button', { name: 'Select action' })).toBeNull(),
+ );
+ expect(document.activeElement).not.toBe(trigger);
+ });
+
+ it('动作延迟打开下一层交互面时不在收合结束后抢回 trigger', async () => {
+ setReducedMotion(false);
+
+ function DelayedFocusHandoffHarness() {
+ const [open, setOpen] = useState(false);
+ const destinationRef = useRef<HTMLButtonElement>(null);
+ return (
+ <>
+ <MorphPopover
+ open={open}
+ onOpenChange={setOpen}
+ trigger={
+ <button type="button" onClick={() => setOpen(true)}>
+ Toggle
+ </button>
+ }
+ >
+ <button
+ type="button"
+ onClick={() => {
+ setOpen(false);
+ // Radix Dialog 会在菜单开始收合后才 autofocus 新弹层。
+ window.setTimeout(() => destinationRef.current?.focus(), 10);
+ }}
+ >
+ Open dialog
+ </button>
+ </MorphPopover>
+ <button ref={destinationRef} type="button">
+ Dialog field
+ </button>
+ </>
+ );
+ }
+
+ render(<DelayedFocusHandoffHarness />);
+ fireEvent.click(screen.getByRole('button', { name: 'Toggle' }));
+ const action = await screen.findByRole('button', { name: 'Open dialog' });
+ action.focus();
+ fireEvent.click(action);
+
+ await waitFor(() =>
+ expect(screen.queryByRole('button', { name: 'Open dialog' })).toBeNull(),
+ );
+ expect(document.activeElement).toBe(screen.getByRole('button', { name: 'Dialog field' }));
+ });
+
it('嵌套 Radix portal 内 pointerdown 不算 outside;真正 outside pointerdown 关闭', async () => {
render(<Harness />);
fireEvent.click(screen.getByRole('button', { name: 'Toggle' }));
diff --git a/apps/desktop/src/renderer/__tests__/newMakerDraft.test.ts b/apps/desktop/src/renderer/__tests__/newMakerDraft.test.ts
index 77ffe5099a..c1805417dc 100644
--- a/apps/desktop/src/renderer/__tests__/newMakerDraft.test.ts
+++ b/apps/desktop/src/renderer/__tests__/newMakerDraft.test.ts
@@ -769,15 +769,13 @@ describe('newMakerDraft store', () => {
expect(getDraft().deviceLinkDeviceName).toBeNull();
});
- // issue #1170:device-link 草稿曾被硬编码禁用协同,而同一个项目建成会话后入口又出现。
- // 现在草稿与会话页共用同一份判定(resolveCollabEntryPolicy),device-link **项目**可开协同;
- // 关掉协同的只剩「对话模式」这一条(workingDir == null)。
- it('选设备但没选项目(对话模式)→ 协同仍然关闭', async () => {
+ // 协同与项目/对话形态正交:切设备后落到该设备的对话态也不能静默关掉用户选择。
+ it('选设备但没选项目(对话模式)→ 协同开关保留', async () => {
const { getDraft, patchDraft } = await loadModule();
patchDraft({ workingDir: '/local/proj' });
patchDraft({ collab: { enabled: true, worker: 'cc' } });
patchDraft({ deviceLinkDeviceId: 'dev-a', deviceLinkDeviceName: 'Studio Mac', workingDir: null });
- expect(getDraft().collab.enabled).toBe(false);
+ expect(getDraft().collab.enabled).toBe(true);
});
it('选设备上的项目 → 协同开关保留(不再被 device-link 一刀切关掉)', async () => {
diff --git a/apps/desktop/src/renderer/__tests__/newMakerDraftRemoteHost.test.ts b/apps/desktop/src/renderer/__tests__/newMakerDraftRemoteHost.test.ts
index 177df2710e..71372f4d40 100644
--- a/apps/desktop/src/renderer/__tests__/newMakerDraftRemoteHost.test.ts
+++ b/apps/desktop/src/renderer/__tests__/newMakerDraftRemoteHost.test.ts
@@ -76,6 +76,32 @@ describe('newMakerDraft remote host identity', () => {
expect(getDraft().collab.enabled).toBe(true);
});
+ it('keeps collab enabled when switching from a project to dialogue', async () => {
+ const { getDraft, patchDraft, patchCollab } = await loadModule();
+ patchDraft({ workingDir: '/local/app' });
+ patchCollab({ enabled: true });
+
+ patchDraft({ workingDir: null });
+
+ expect(getDraft().workingDir).toBeNull();
+ expect(getDraft().collab.enabled).toBe(true);
+ });
+
+ it('keeps collab on reload for a persisted dialogue draft', async () => {
+ memStorage.setItem(
+ 'xdt:newMakerDraft:v1',
+ JSON.stringify({
+ vendor: 'cc',
+ workingDir: null,
+ collab: { enabled: true, worker: 'codex' },
+ }),
+ );
+ vi.resetModules();
+ const { getDraft } = await loadModule();
+ expect(getDraft().workingDir).toBeNull();
+ expect(getDraft().collab.enabled).toBe(true);
+ });
+
it('keeps collab on reload when a persisted draft is remote', async () => {
memStorage.setItem(
'xdt:newMakerDraft:v1',
diff --git a/apps/desktop/src/renderer/__tests__/newMakerDraftWorkspaceReset.test.ts b/apps/desktop/src/renderer/__tests__/newMakerDraftWorkspaceReset.test.ts
index 0a178a936e..9af30521e5 100644
--- a/apps/desktop/src/renderer/__tests__/newMakerDraftWorkspaceReset.test.ts
+++ b/apps/desktop/src/renderer/__tests__/newMakerDraftWorkspaceReset.test.ts
@@ -31,7 +31,7 @@ describe('resetDraftWorkspaceTargets', () => {
expect(getDraft().extraDirs).toEqual([]);
});
- it('清空工作目录,并级联清掉远程目标与协同开关', () => {
+ it('清空工作目录和远程目标,并显式消费本次协同选择', () => {
patchDraft({ workingDir: '/Users/someone/project' });
patchDraft({ remoteHostId: 'host-1' });
patchCollab({ enabled: true });
diff --git a/apps/desktop/src/renderer/__tests__/newMakerGenericCreatePreservesDraft.test.ts b/apps/desktop/src/renderer/__tests__/newMakerGenericCreatePreservesDraft.test.ts
index 6d8b566116..b610228c25 100644
--- a/apps/desktop/src/renderer/__tests__/newMakerGenericCreatePreservesDraft.test.ts
+++ b/apps/desktop/src/renderer/__tests__/newMakerGenericCreatePreservesDraft.test.ts
@@ -5,7 +5,7 @@
*
* 背景:草稿页(/cc-agent/new)的「对话或选择项目」选择由 newMakerDraft store
* 持久化。此前展开态 SidebarTopNav.handleNew 与折叠态 CCAgentSidebarUpper.handleNewCCS
- * 都会先 patchNewMakerDraft({ workingDir: null, remoteHostId: null, extraDirs: [] })
+ * 都会先重置 newMakerDraft
* 再 navigate,导致用户选好项目后切到别的会话、再点「新建」回来时选择被重置为默认、
* 需要重新选。修复后这两个通用入口只 navigate、不清空;清空语义只保留在「新建对话」
* 等显式入口(handleCreateDialogue)。
@@ -59,7 +59,7 @@ describe('通用「新建」保留 newMakerDraft 选择', () => {
it('显式「新建对话」入口 handleCreateDialogue 仍清空 workingDir(不受本次修复影响)', () => {
const block = extractHandlerBlock(sidebarUpperSource, 'handleCreateDialogue');
- expect(block).toContain('patchNewMakerDraft({ workingDir: null, remoteHostId: null, extraDirs: [] })');
+ expect(block).toContain('resetDraftWorkspaceTargets();');
});
// 保留与清空的分界(2026-07-25 用户定稿):workingDir / 文本 / 模型是便利性
diff --git a/apps/desktop/src/renderer/__tests__/orcaWorkflowRoute.test.ts b/apps/desktop/src/renderer/__tests__/orcaWorkflowRoute.test.ts
index 2271dafd22..8ca22733b0 100644
--- a/apps/desktop/src/renderer/__tests__/orcaWorkflowRoute.test.ts
+++ b/apps/desktop/src/renderer/__tests__/orcaWorkflowRoute.test.ts
@@ -79,8 +79,8 @@ const chatInputSource = readTextLf(
resolve(__dirname, '..', 'components', 'new-chat', 'ChatInput.tsx'),
'utf8',
);
-const collaborationModeToggleSource = readTextLf(
- resolve(__dirname, '..', 'components', 'new-chat', 'CollaborationModeToggle.tsx'),
+const extraDirsButtonSource = readTextLf(
+ resolve(__dirname, '..', 'components', 'new-chat', 'ExtraDirsButton.tsx'),
'utf8',
);
const sessionStatusIconSource = readTextLf(
@@ -158,33 +158,24 @@ describe('OrcaWorkflowRoute source invariants', () => {
it('uses the right-sidebar UsersRound mark for every collaboration entry point', () => {
expect(rightSidebarTabBarSource).toContain("'orca-workers': UsersRound");
expect(orcaWorkersPluginSource).toContain('<UsersRound size={13} />');
- expect(collaborationModeToggleSource.match(/<UsersRound/g)).toHaveLength(3);
- expect(collaborationModeToggleSource).not.toContain('<Puzzle');
+ expect(extraDirsButtonSource).toContain('<UsersRound');
+ expect(extraDirsButtonSource).not.toContain('<Puzzle');
expect(sessionStatusIconSource).toContain('<UsersRound');
expect(sessionStatusIconSource).not.toContain('<Puzzle');
expect(sessionStatusIconSource).toContain("'text-[var(--cmd-palette-item-meta)]'");
});
- it('keeps policy reasons scoped to disabled collaboration controls', () => {
- expect(collaborationModeToggleSource).toContain(
- 'const effectiveDisabledReason = disabled ? disabledReason : undefined;',
+ it('keeps policy reasons scoped to the disabled collaboration menu item', () => {
+ expect(extraDirsButtonSource).toContain(
+ 'const collaborationPolicyDisabled = collaboration?.disabled === true;',
);
- expect(collaborationModeToggleSource).toContain(
- "text={effectiveDisabledReason ?? t('newChat.collaboration.stopHint')}",
+ expect(extraDirsButtonSource).toContain(
+ 'text={collaborationPolicyDisabled ? collaboration.disabledReason : null}',
);
- expect(collaborationModeToggleSource.match(/disabledWrapperProps\(/g)).toHaveLength(3);
- expect(collaborationModeToggleSource.match(/aria-hidden=\{disabled \|\| undefined\}/g)).toHaveLength(3);
- expect(collaborationModeToggleSource).toContain(
- "'aria-disabled': onDisabledActivate ? undefined : true",
+ expect(extraDirsButtonSource).toContain(
+ 'collaborationPolicyDisabled && !collaborationRetryable ? true : undefined',
);
- expect(collaborationModeToggleSource).toContain(
- 'onKeyDown: blockDisabledKeyboardActivation',
- );
- expect(collaborationModeToggleSource).toContain(
- "if (event.key !== 'Enter' && event.key !== ' ') return;",
- );
- expect(collaborationModeToggleSource).toContain('onClick: onDisabledActivate');
- expect(collaborationModeToggleSource).toContain('if (!event.repeat) onDisabledActivate?.();');
+ expect(extraDirsButtonSource).toContain('collaboration.onDisabledActivate?.();');
});
it('keeps the active collaboration tooltip free of policy-disabled reasons', () => {
@@ -203,10 +194,8 @@ describe('OrcaWorkflowRoute source invariants', () => {
expect(sessionViewSource).toContain('onDisabledActivate: collabPolicy.unavailable');
expect(sessionViewSource).toContain('void collabPolicy.refresh().then((policy) => {');
expect(sessionViewSource).toContain('if (policy.enabled && !policy.unavailable) {');
- expect(chatInputSource).toContain(
- '!disabled && collaboration.disabled\n' +
- ' ? collaboration.disabledReason',
- );
+ expect(chatInputSource).toContain('collaboration={collaboration}');
+ expect(extraDirsButtonSource).toContain('!!collaboration?.onDisabledActivate');
});
it('does not subscribe to project policy updates from the legacy Orca route', () => {
@@ -297,7 +286,8 @@ describe('OrcaWorkflowRoute source invariants', () => {
expect(sessionViewSource).toContain('label: createWorkerLabel(form.role, [])');
expect(sessionViewSource).toContain('model: form.model');
expect(sessionViewSource).toContain('delegateTask: form.initialTask || undefined');
- expect(chatInputSource).toContain('onOpenDetails={collaboration.onOpenDetails}');
+ expect(chatInputSource).toContain('collaboration={collaboration}');
+ expect(extraDirsButtonSource).toContain('collaboration.onOpenDetails();');
});
it('maps manual collaboration start failures through i18n instead of raw IPC messages', () => {
diff --git a/apps/desktop/src/renderer/__tests__/planModeComposerEntry.test.ts b/apps/desktop/src/renderer/__tests__/planModeComposerEntry.test.ts
index 6855b62da9..d4b9f79498 100644
--- a/apps/desktop/src/renderer/__tests__/planModeComposerEntry.test.ts
+++ b/apps/desktop/src/renderer/__tests__/planModeComposerEntry.test.ts
@@ -3,9 +3,9 @@
/**
* planModeComposerEntry.test.tsx
* ---------------------------------------------------------------------------
- * issue #475 — 计划模式一级入口的 DOM 级渲染断言:
- * - ExtraDirsButton:「计划模式」菜单项与「新建目标」同级;点击回调 toggle;
- * 勾选态 aria-checked;codex 也能只凭 planMode 渲染「+」按钮
+ * issue #475 — 模式菜单一级入口的 DOM 级渲染断言:
+ * - ExtraDirsButton:「计划模式」/「协同模式」菜单项与「新建目标」同级;
+ * 勾选态 aria-checked;单独提供任一模式也能渲染「+」按钮
* - PlanModeIndicator:激活 chip 文案 + 退出按钮;disabled 时隐藏退出按钮
* - PlanActionCard:取消收敛为次级动作(仅 Esc,无独立行)与 ⏎ 去重
* (编辑反馈时批准行 ⏎ 隐藏,反馈 ⏎ 仅在有文字时出现且可点击发送)
@@ -73,7 +73,7 @@ afterEach(() => {
vi.clearAllMocks();
});
-describe('ExtraDirsButton 计划模式菜单项', () => {
+describe('ExtraDirsButton 模式菜单项', () => {
it('附件接线单独存在时也渲染「+」入口,并把多选文件交给 composer', () => {
const onAddFiles = vi.fn();
const { container } = render(
@@ -155,6 +155,84 @@ describe('ExtraDirsButton 计划模式菜单项', () => {
expect(onToggle).toHaveBeenCalledWith(false);
});
+ it('只凭协同模式也渲染「+」入口, 关闭态点击打开完整 Worker 配置', () => {
+ const onChange = vi.fn();
+ const onOpenDetails = vi.fn();
+ render(
+ createElement(ExtraDirsButton, {
+ extraDirs: [],
+ collaboration: {
+ enabled: false,
+ worker: 'codex',
+ onChange,
+ onOpenDetails,
+ },
+ }),
+ );
+
+ fireEvent.click(screen.getByLabelText('extraDirs.menuAria'));
+ const item = screen.getByRole('menuitemcheckbox', {
+ name: 'newChat.collaboration.modeLabel',
+ });
+ expect(item.getAttribute('aria-checked')).toBe('false');
+ fireEvent.click(item);
+ expect(onOpenDetails).toHaveBeenCalledTimes(1);
+ expect(onChange).not.toHaveBeenCalled();
+ });
+
+ it('协同开启态与目标/计划同级共存, 使用橙色状态并可直接关闭', () => {
+ const onChange = vi.fn();
+ render(
+ createElement(ExtraDirsButton, {
+ extraDirs: [],
+ onChange: () => {},
+ onNewGoal: vi.fn(),
+ planMode: { enabled: false, onToggle: vi.fn() },
+ collaboration: { enabled: true, worker: 'cc', onChange },
+ }),
+ );
+
+ fireEvent.click(screen.getByLabelText('extraDirs.menuAria'));
+ expect(screen.getByText('goal.newGoalMenuItem')).toBeTruthy();
+ expect(screen.getByText('planMode.menuItem')).toBeTruthy();
+ const item = screen.getByRole('menuitemcheckbox', {
+ name: 'newChat.collaboration.modeLabel',
+ });
+ expect(item.getAttribute('aria-checked')).toBe('true');
+ expect(item.className).toContain('bg-[var(--model-item-hover)]');
+ expect(screen.getByText('newChat.collaboration.modeLabel').className).toContain(
+ 'text-[var(--warning-accent)]',
+ );
+ expect(item.querySelector('svg.lucide-check')).toBeTruthy();
+ fireEvent.click(item);
+ expect(onChange).toHaveBeenCalledWith({ enabled: false, worker: 'cc' });
+ });
+
+ it('策略暂不可用时保留可重试的协同菜单项', () => {
+ const onDisabledActivate = vi.fn();
+ render(
+ createElement(ExtraDirsButton, {
+ extraDirs: [],
+ collaboration: {
+ enabled: false,
+ worker: 'pi',
+ onChange: vi.fn(),
+ disabled: true,
+ disabledReason: 'policy unavailable',
+ onDisabledActivate,
+ },
+ }),
+ );
+
+ fireEvent.click(screen.getByLabelText('extraDirs.menuAria'));
+ const item = screen.getByRole('menuitemcheckbox', {
+ name: 'newChat.collaboration.modeLabel: policy unavailable',
+ });
+ expect((item as HTMLButtonElement).disabled).toBe(false);
+ fireEvent.click(item);
+ expect(onDisabledActivate).toHaveBeenCalledTimes(1);
+ });
+
it('没有任何入口时保持不渲染', () => {
const { container } = render(
createElement(ExtraDirsButton, {
diff --git a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx
index bc305f2af3..376b89b6c0 100644
--- a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx
+++ b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx
@@ -123,13 +123,12 @@ import {
} from './sourceSwitch';
import { useConfirmDialog } from '@/components/ui/confirm-dialog-provider';
import { PermissionSelector } from './PermissionSelector';
-import { ExtraDirsButton } from './ExtraDirsButton';
+import { ExtraDirsButton, type CollaborationMenuConfig } from './ExtraDirsButton';
import { focusComposerEndNextFrame, placeGhostAtComposerStart } from './ghostComposerPlacement';
import { NewGoalDialog } from './NewGoalDialog';
import { PlanModeIndicator } from './PlanModeIndicator';
import { PendingQueuePanel } from './PendingQueuePanel';
import { SendButton } from './SendButton';
-import { CollaborationModeToggle, type CollabWorkerKind } from './CollaborationModeToggle';
import { FolderPickerPopover, addRecentFolder } from './FolderPickerPopover';
import { SlashCommandPalette } from './SlashCommandPalette';
import {
@@ -273,7 +272,7 @@ const ComposerHardBreak = HardBreak.extend({
// 工具行宽度自适应阈值(input card 像素宽)。低于阈值时自动收紧工具行,避免窄宽
// 下换行 / 文字溢出,与 doc rail / orca 的显式 compactToolbar / denseToolbar 取 OR。
-// 两档:先 dense(控件字号 / 图标压一档、协同 pill 收成 logo),更窄再 compact
+// 两档:先 dense(控件字号 / 图标压一档),更窄再 compact
// (左侧 permission 可 truncate 成 "完..."、右侧 shrink-0 防换行)。数值按主会话工具行
// 自然宽度(permission + model + voice + send 等)估,实测可微调。
const TOOLBAR_DENSE_MAX_WIDTH = 520;
@@ -578,7 +577,7 @@ interface ChatInputProps {
/** 强制使用紧凑单行工具栏;容器测宽也会自动进入同一状态。 */
narrowToolbar?: boolean;
/**
- * 工具行采用更紧凑的视觉密度 (字号 -1px, 协同 toggle 只剩 logo)。
+ * 工具行采用更紧凑的视觉密度 (字号 -1px)。
* 用于 doc rail 这种宽度受限的容器,与 compactToolbar (wrap 兜底) 正交:
* - dense=true 把控件本身压瘦, 一般就够单行塞下
* - compactToolbar 是宽度极端时的 wrap 兜底, split-pane 仍然需要
@@ -598,21 +597,13 @@ interface ChatInputProps {
*/
topSlot?: React.ReactNode;
/**
- * 协同模式开关 (Claude / Codex Lead session 中途 toggle Worker)。
- * 提供时:底部工具行右侧渲染双人像 pill (CollaborationModeToggle),
- * ON 态点击 pill 即触发关闭 (由 parent 决定确认弹窗)。
- * 不提供时:不渲染 (老调用方零迁移)。
+ * 协同模式入口 (Claude / Codex Lead session 中途 toggle Worker)。
+ * 提供时:与目标模式、计划模式同级渲染在 composer「+」菜单;
+ * ON 态点击菜单项即触发关闭 (由 parent 决定确认弹窗)。
+ * 不提供时:菜单里不渲染该项。
* 状态完全由 parent 持有 (controlled);ChatInput 只做展示与事件转发。
*/
- collaboration?: {
- enabled: boolean;
- worker: CollabWorkerKind;
- onChange: (next: { enabled: boolean; worker: CollabWorkerKind }) => void;
- onOpenDetails?: () => void;
- onDisabledActivate?: () => void;
- disabled?: boolean;
- disabledReason?: string;
- };
+ collaboration?: CollaborationMenuConfig;
}
function vendorKeyToAgentKind(v?: 'cc' | 'codex' | 'pi'): AgentKind | null {
@@ -5598,7 +5589,7 @@ export function ChatInput({
// create-agent 按 Figma 使用 hug-content pills;默认会话页仍保留左侧优先压缩。
)}
>
- {/* composer 「+」菜单(权限左侧):本机会话提供附件入口;目标、计划模式、
+ {/* composer 「+」菜单(权限左侧):本机会话提供附件入口;目标、计划/协同模式、
Plugin、引用目录按各自能力与接线显示。远程会话不能把控制端绝对路径
交给远端 agent,因此不接本机文件选择器。 */}
<ExtraDirsButton
@@ -5606,6 +5597,7 @@ export function ChatInput({
workingDir={workingDir}
onAddFiles={localAttachmentPickerEnabled ? addFiles : undefined}
planMode={planModeEntry}
+ collaboration={collaboration}
plugins={pluginsForMenu}
pluginAvailableIds={pluginAvailableIds}
onPluginSelect={handlePluginSelect}
@@ -5652,34 +5644,13 @@ export function ChatInput({
: 'flex min-w-0 shrink items-center justify-end gap-1'
: 'flex items-center gap-2',
// compact 模式下所有输入框工具行保持单行;权限 / 模型 pill 内部截断承压,
- // vendor tab、圆形操作按钮与协同图标按钮保持固定宽,避免控件重叠或掉到第二行。
+ // vendor tab 与圆形操作按钮保持固定宽,避免控件重叠或掉到第二行。
)}
>
{(!useNarrowToolbar || useCompactMiddleToolbar) &&
(useCompactMiddleToolbar
? compactMiddleToolbarSlot ?? <>{middleToolbarSlot}</>
: <>{middleToolbarSlot}</>)}
- {collaboration && (
- <CollaborationModeToggle
- enabled={collaboration.enabled}
- worker={collaboration.worker}
- onChange={collaboration.onChange}
- onOpenDetails={collaboration.onOpenDetails}
- onDisabledActivate={
- !disabled && collaboration.disabled
- ? collaboration.onDisabledActivate
- : undefined
- }
- disabled={disabled || collaboration.disabled}
- disabledReason={
- !disabled && collaboration.disabled
- ? collaboration.disabledReason
- : undefined
- }
- dense={effectiveDenseToolbar}
- iconOnly={effectiveDenseToolbar}
- />
- )}
<div className={useNarrowToolbar ? 'min-w-0 shrink' : undefined}>
<ModelSelector
modelId={activeModel}
diff --git a/apps/desktop/src/renderer/components/new-chat/CollaborationModeToggle.tsx b/apps/desktop/src/renderer/components/new-chat/CollaborationModeToggle.tsx
deleted file mode 100644
index d591db52f1..0000000000
--- a/apps/desktop/src/renderer/components/new-chat/CollaborationModeToggle.tsx
+++ /dev/null
@@ -1,276 +0,0 @@
-/**
- * CollaborationModeToggle —— ChatInput 底部工具行的"协同模式"开关 pill。
- *
- * 两态:
- * - OFF: 灰描边 pill,点击弹 Popover 选 Worker agent → 点 "开启协同" 确认
- * - ON: 橙描边 pill,点击直接触发 onChange({ enabled: false }),由 parent
- * 决定是否要弹确认对话框
- *
- * 该组件不持有任何业务状态:enabled / worker / onChange 全部由 parent 传入。
- * 内部仅有 popover 的开合状态 + 选择 Worker 的草稿值。
- *
- * 视觉状态固定为 OFF / Popover / ON 三态。
- */
-import { useState, type KeyboardEvent, type ReactElement } from 'react';
-import { UsersRound, Check } from 'lucide-react';
-import { useTranslation } from 'react-i18next';
-
-import { cn } from '@/lib/utils';
-import { Popover, PopoverTrigger, PopoverContent } from '@/components/ui/popover';
-import { Tip } from '@/components/ui/tooltip';
-import { CodexMark } from '@/components/icons/CodexMark';
-import { ClaudeMark } from '@/components/icons/ClaudeMark';
-import { PiMark } from '@/components/icons/PiMark';
-
-export type CollabWorkerKind = 'cc' | 'codex' | 'pi';
-
-interface Props {
- enabled: boolean;
- worker: CollabWorkerKind;
- onChange: (next: { enabled: boolean; worker: CollabWorkerKind }) => void;
- onOpenDetails?: () => void;
- onDisabledActivate?: () => void;
- disabled?: boolean;
- disabledReason?: string;
- /** 窄容器下把 pill 字号压一档,默认 false。 */
- dense?: boolean;
- /** 只渲染 UsersRound 图标,不渲染 "协同" 文案,默认 false。 */
- iconOnly?: boolean;
-}
-
-const WORKER_OPTIONS: ReadonlyArray<{
- kind: CollabWorkerKind;
- label: string;
- renderMark: (size: number) => ReactElement;
-}> = [
- {
- kind: 'codex',
- label: 'Codex',
- renderMark: (size) => <CodexMark size={size} className="shrink-0" />,
- },
- {
- kind: 'cc',
- label: 'Claude',
- renderMark: (size) => <ClaudeMark size={size} className="shrink-0" />,
- },
- {
- kind: 'pi',
- label: 'Pi',
- renderMark: (size) => <PiMark size={size} className="shrink-0" />,
- },
-];
-
-export function CollaborationModeToggle({
- enabled,
- worker,
- onChange,
- onOpenDetails,
- onDisabledActivate,
- disabled,
- disabledReason,
- dense = false,
- iconOnly = false,
-}: Props) {
- const { t } = useTranslation();
- const [open, setOpen] = useState(false);
- const [draftWorker, setDraftWorker] = useState<CollabWorkerKind>(worker);
-
- // iconOnly 时 pill 退化成 30px 圆形图标按钮,与同行其它 trigger
- // (PermissionSelector / ExtraDirsButton / VoiceInputButton) 同尺寸同底同描边。
- const pillSizeCn = iconOnly
- ? 'h-[30px] w-[30px] justify-center px-0'
- : cn('h-[30px] px-2.5', dense ? 'text-[11.5px]' : 'text-[12px]');
- const iconSize = iconOnly ? 14 : 11;
- const effectiveDisabledReason = disabled ? disabledReason : undefined;
- const blockDisabledKeyboardActivation = (event: KeyboardEvent<HTMLSpanElement>) => {
- if (event.key !== 'Enter' && event.key !== ' ') return;
- event.preventDefault();
- if (!event.repeat) onDisabledActivate?.();
- };
- const disabledWrapperProps = (label: string) =>
- disabled
- ? {
- role: 'button' as const,
- tabIndex: 0,
- 'aria-disabled': onDisabledActivate ? undefined : true,
- 'aria-label': disabledReason ?? label,
- onClick: onDisabledActivate,
- onKeyDown: blockDisabledKeyboardActivation,
- }
- : {};
-
- const handleOpenChange = (next: boolean) => {
- if (next) setDraftWorker(worker);
- setOpen(next);
- };
-
- const handleConfirm = () => {
- onChange({ enabled: true, worker: draftWorker });
- setOpen(false);
- };
-
- // ON 态:pill 本身就是"停止协同"的触发器
- if (enabled) {
- return (
- <Tip text={effectiveDisabledReason ?? t('newChat.collaboration.stopHint')} side="top">
- <span
- {...disabledWrapperProps(t('newChat.collaboration.toggleOnAria'))}
- className={cn('inline-flex', onDisabledActivate && 'cursor-pointer')}
- >
- <button
- type="button"
- disabled={disabled}
- // 与 VendorSegmentedSwitcher / FastModeToggle 一致:阻 mousedown 抢焦点
- onMouseDown={(e) => e.preventDefault()}
- onClick={() => onChange({ enabled: false, worker })}
- aria-label={t('newChat.collaboration.toggleOnAria')}
- aria-hidden={disabled || undefined}
- aria-pressed
- className={cn(
- 'flex shrink-0 items-center gap-1.5 rounded-full font-medium transition-colors',
- 'bg-[var(--composer-pill-bg,#FCFCFC)] dark:bg-[var(--composer-pill-bg,#393838)] text-[var(--warning-accent)]' /* ON 态恢复橙(用户改稿 2026-07-20,覆盖 07-17 去橙中性);OFF 态仍中性 */,
- 'border border-[var(--border-default)]',
- 'hover:bg-[var(--model-trigger-hover)]',
- pillSizeCn,
- disabled && 'cursor-not-allowed opacity-50',
- disabled && onDisabledActivate && 'pointer-events-none',
- )}
- >
- <UsersRound size={iconSize} className="shrink-0" />
- {!iconOnly && <span>{t('newChat.collaboration.pillLabel')}</span>}
- </button>
- </span>
- </Tip>
- );
- }
-
- // OFF 态:点击弹 Popover 选 Worker
- if (onOpenDetails) {
- return (
- <Tip
- text={effectiveDisabledReason ?? (iconOnly ? t('newChat.collaboration.pillLabel') : null)}
- side="top"
- >
- <span
- {...disabledWrapperProps(t('newChat.collaboration.toggleOffAria'))}
- className={cn('inline-flex', onDisabledActivate && 'cursor-pointer')}
- >
- <button
- type="button"
- disabled={disabled}
- onMouseDown={(e) => e.preventDefault()}
- onClick={onOpenDetails}
- aria-label={t('newChat.collaboration.toggleOffAria')}
- aria-hidden={disabled || undefined}
- aria-pressed={false}
- className={cn(
- 'flex shrink-0 items-center gap-1.5 rounded-full font-medium transition-colors',
- 'bg-[var(--composer-pill-bg,#FCFCFC)] dark:bg-[var(--composer-pill-bg,#393838)] text-[var(--text-primary)]' /* spec 2026-07-17, token by 一哥 */,
- 'border border-[var(--border-default)]',
- 'hover:bg-[var(--model-trigger-hover)]',
- pillSizeCn,
- disabled && 'cursor-not-allowed opacity-50',
- disabled && onDisabledActivate && 'pointer-events-none',
- )}
- >
- <UsersRound size={iconSize} className="shrink-0" />
- {!iconOnly && <span>{t('newChat.collaboration.pillLabel')}</span>}
- </button>
- </span>
- </Tip>
- );
- }
-
- return (
- <Popover open={open} onOpenChange={handleOpenChange}>
- <PopoverTrigger asChild>
- <Tip
- text={effectiveDisabledReason ?? (iconOnly ? t('newChat.collaboration.pillLabel') : null)}
- side="top"
- >
- <span
- {...disabledWrapperProps(t('newChat.collaboration.toggleOffAria'))}
- className={cn('inline-flex', onDisabledActivate && 'cursor-pointer')}
- >
- <button
- type="button"
- disabled={disabled}
- onMouseDown={(e) => e.preventDefault()}
- aria-label={t('newChat.collaboration.toggleOffAria')}
- aria-hidden={disabled || undefined}
- aria-pressed={false}
- className={cn(
- 'flex shrink-0 items-center gap-1.5 rounded-full font-medium transition-colors',
- 'bg-[var(--composer-pill-bg,#FCFCFC)] dark:bg-[var(--composer-pill-bg,#393838)] text-[var(--text-primary)]' /* spec 2026-07-17, token by 一哥 */,
- 'border border-[var(--border-default)]',
- 'hover:bg-[var(--model-trigger-hover)]',
- pillSizeCn,
- disabled && 'cursor-not-allowed opacity-50',
- disabled && onDisabledActivate && 'pointer-events-none',
- )}
- >
- <UsersRound size={iconSize} className="shrink-0" />
- {!iconOnly && <span>{t('newChat.collaboration.pillLabel')}</span>}
- </button>
- </span>
- </Tip>
- </PopoverTrigger>
- <PopoverContent
- side="top"
- align="end"
- sideOffset={8}
- collisionPadding={8}
- className={cn(
- 'w-[260px] rounded-[12px] p-3',
- // 复用 ModelSelector 的 popover token,保证视觉一致
- 'bg-[var(--model-dropdown-bg)]',
- 'border border-[var(--model-dropdown-border)]',
- )}
- >
- <div className="flex flex-col gap-3">
- <div className="text-[13px] font-medium text-foreground">
- {t('newChat.collaboration.popoverTitle')}
- </div>
- <div className="flex flex-col gap-[2px]" role="listbox" aria-label="Worker agent">
- {WORKER_OPTIONS.map((opt) => {
- const isSelected = opt.kind === draftWorker;
- return (
- <button
- key={opt.kind}
- type="button"
- role="option"
- aria-selected={isSelected}
- onClick={() => setDraftWorker(opt.kind)}
- className={cn(
- 'flex w-full items-center justify-between rounded-[8px] px-3 py-2',
- 'transition-colors',
- 'hover:bg-[var(--model-item-hover)]',
- isSelected && 'bg-[var(--model-item-hover)]',
- )}
- >
- <span className="flex items-center gap-2 text-[14px] font-medium text-[var(--model-item-text)]">
- {opt.renderMark(14)}
- <span>{opt.label}</span>
- </span>
- {isSelected && (
- <Check size={14} className="shrink-0 text-[var(--model-item-check)]" />
- )}
- </button>
- );
- })}
- </div>
- <button
- type="button"
- onClick={handleConfirm}
- className={cn(
- 'flex h-8 items-center justify-center rounded-full text-[12px] font-medium transition-colors',
- 'bg-[var(--send-btn-bg)] text-[var(--send-btn-icon)] hover:bg-[var(--confirm-btn-primary-hover)]',
- )}
- >
- {t('newChat.collaboration.startButton')}
- </button>
- </div>
- </PopoverContent>
- </Popover>
- );
-}
diff --git a/apps/desktop/src/renderer/components/new-chat/ExtraDirsButton.tsx b/apps/desktop/src/renderer/components/new-chat/ExtraDirsButton.tsx
index 65fd184039..8878c2df17 100644
--- a/apps/desktop/src/renderer/components/new-chat/ExtraDirsButton.tsx
+++ b/apps/desktop/src/renderer/components/new-chat/ExtraDirsButton.tsx
@@ -1,9 +1,10 @@
/**
* ExtraDirsButton —— composer 的「+」操作菜单(左置于权限选择器之前)。
*
- * 合并了四类入口(参考 Codex 的 + 菜单):
+ * 合并了五类入口(参考 Codex 的 + 菜单):
* - 添加文件、图片或视频→ 复用 composer 既有附件管线。
* - 新建目标(`onNewGoal` 提供时显示;仅会话中,父组件按 sessionId 决定)→ 打开 NewGoalDialog。
+ * - 计划模式 / 协同模式→ 与新建目标同级的模式入口。
* - 已安装 Plugin:选择后由 ChatInput 把 command 放到消息开头,保留正文并聚焦末尾。
* - 附加只读引用目录(Claude vendor;`onChange` 提供时显示)→ 列表 / 添加。
*
@@ -19,7 +20,16 @@
*/
import { useRef, useState } from 'react';
-import { Check, ClipboardList, FolderPlus, Paperclip, Plus, Target, X } from 'lucide-react';
+import {
+ Check,
+ ClipboardList,
+ FolderPlus,
+ Paperclip,
+ Plus,
+ Target,
+ UsersRound,
+ X,
+} from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { cn } from '@/lib/utils';
@@ -37,6 +47,20 @@ const log = createLogger('ExtraDirsButton');
/** 与 main 端 EXTRA_DIRS_MAX 保持一致;UI 满了 disable 添加按钮。 */
const MAX_EXTRA_DIRS = 10;
+export type CollabWorkerKind = 'cc' | 'codex' | 'pi';
+
+export interface CollaborationMenuConfig {
+ enabled: boolean;
+ worker: CollabWorkerKind;
+ onChange: (next: { enabled: boolean; worker: CollabWorkerKind }) => void;
+ /** 关闭态优先打开完整 Worker 配置;未提供时直接沿用当前 worker 开启。 */
+ onOpenDetails?: () => void;
+ /** 策略暂不可用时允许从菜单项触发刷新。 */
+ onDisabledActivate?: () => void;
+ disabled?: boolean;
+ disabledReason?: string;
+}
+
export interface ExtraDirsButtonProps {
extraDirs: string[];
workingDir?: string | null;
@@ -54,6 +78,8 @@ export interface ExtraDirsButtonProps {
* 父组件负责能力门控(capabilities.planMode)与持久化,这里只做 UI。
*/
planMode?: { enabled: boolean; onToggle: (next: boolean) => void };
+ /** 协同模式入口;与新建目标、计划模式同级显示在「+」菜单。 */
+ collaboration?: CollaborationMenuConfig;
/** 已安装 Plugin 清单;无指令或未生效项仍展示,但不可选。 */
plugins?: readonly InstalledGhost[];
/** 当前会话范围内可直接使用的 Plugin id;未命中项保留展示但置灰。 */
@@ -122,6 +148,7 @@ export function ExtraDirsButton({
onChange,
onNewGoal,
planMode,
+ collaboration,
plugins = [],
pluginAvailableIds,
onPluginSelect,
@@ -141,11 +168,43 @@ export function ExtraDirsButton({
// hover 展开「添加」文案已移除(2026-07-22 用户定稿:展开必须承载信息,
// 图标自明的 + 不需要;裸态→hover 外框→点击直接长出菜单)。
- // 能力感知:附件、新建目标、计划模式、Plugin 与引用目录都由父组件是否接线决定。
- if (!onAddFiles && !onNewGoal && !planMode && !hasReferenceDirs && plugins.length === 0)
+ // 能力感知:附件、新建目标、计划/协同模式、Plugin 与引用目录都由父组件是否接线决定。
+ if (
+ !onAddFiles &&
+ !onNewGoal &&
+ !planMode &&
+ !collaboration &&
+ !hasReferenceDirs &&
+ plugins.length === 0
+ ) {
return null;
+ }
const atLimit = count >= MAX_EXTRA_DIRS;
+ const collaborationPolicyDisabled = collaboration?.disabled === true;
+ const collaborationRetryable =
+ !disabled && collaborationPolicyDisabled && !!collaboration?.onDisabledActivate;
+ const collaborationAriaLabel = collaboration?.disabledReason
+ ? `${t('newChat.collaboration.modeLabel')}: ${collaboration.disabledReason}`
+ : t('newChat.collaboration.modeLabel');
+
+ const handleCollaborationActivate = () => {
+ if (!collaboration || disabled) return;
+ setOpen(false);
+ if (collaborationPolicyDisabled) {
+ collaboration.onDisabledActivate?.();
+ return;
+ }
+ if (collaboration.enabled) {
+ collaboration.onChange({ enabled: false, worker: collaboration.worker });
+ return;
+ }
+ if (collaboration.onOpenDetails) {
+ collaboration.onOpenDetails();
+ return;
+ }
+ collaboration.onChange({ enabled: true, worker: collaboration.worker });
+ };
const handleAdd = async () => {
if (atLimit || !onChange) return;
@@ -283,7 +342,7 @@ export function ExtraDirsButton({
{t('extraDirs.addFiles')}
</span>
</button>
- {(onNewGoal || planMode || plugins.length > 0 || hasReferenceDirs) && (
+ {(onNewGoal || planMode || collaboration || plugins.length > 0 || hasReferenceDirs) && (
<div className="my-1 h-px bg-[var(--model-dropdown-border)]" />
)}
</>
@@ -334,9 +393,62 @@ export function ExtraDirsButton({
</button>
)}
+ {/* 协同模式与目标/计划同级。开启态保留 Thinking Orange,右侧对勾表示当前状态。 */}
+ {collaboration && (
+ <Tip
+ text={collaborationPolicyDisabled ? collaboration.disabledReason : null}
+ side="right"
+ >
+ <span className="block">
+ <button
+ type="button"
+ role="menuitemcheckbox"
+ aria-checked={collaboration.enabled}
+ aria-label={collaborationAriaLabel}
+ aria-disabled={
+ collaborationPolicyDisabled && !collaborationRetryable ? true : undefined
+ }
+ disabled={disabled || (collaborationPolicyDisabled && !collaborationRetryable)}
+ onClick={handleCollaborationActivate}
+ className={cn(
+ 'flex w-full items-center gap-2 rounded-[8px] px-3 py-2',
+ 'transition-colors hover:bg-[var(--model-item-hover)]',
+ collaboration.enabled && 'bg-[var(--model-item-hover)]',
+ (disabled || collaborationPolicyDisabled) && 'opacity-50',
+ (disabled || (collaborationPolicyDisabled && !collaborationRetryable)) &&
+ 'cursor-not-allowed',
+ )}
+ >
+ <UsersRound
+ size={14}
+ className={cn(
+ 'shrink-0',
+ collaboration.enabled
+ ? 'text-[var(--warning-accent)]'
+ : 'text-[var(--model-item-text)]',
+ )}
+ />
+ <span
+ className={cn(
+ 'min-w-0 flex-1 truncate text-left text-[13px]',
+ collaboration.enabled
+ ? 'font-medium text-[var(--warning-accent)]'
+ : 'text-[var(--model-item-text)]',
+ )}
+ >
+ {t('newChat.collaboration.modeLabel')}
+ </span>
+ {collaboration.enabled && (
+ <Check size={13} className="shrink-0 text-[var(--model-item-check)]" />
+ )}
+ </button>
+ </span>
+ </Tip>
+ )}
+
{plugins.length > 0 && (
<>
- {(onNewGoal || planMode) && (
+ {(onNewGoal || planMode || collaboration) && (
<div className="my-1 h-px bg-[var(--model-dropdown-border)]" />
)}
<div className="px-2 pb-1 pt-1 text-[12px] text-[var(--model-trigger-text)] opacity-70">
@@ -397,7 +509,7 @@ export function ExtraDirsButton({
{/* 引用目录段:Claude 与 Codex 共用;未接 onChange 时不暴露空操作入口。 */}
{hasReferenceDirs && (
<>
- {(onNewGoal || planMode || plugins.length > 0) && (
+ {(onNewGoal || planMode || collaboration || plugins.length > 0) && (
<div className="my-1 h-px bg-[var(--model-dropdown-border)]" />
)}
diff --git a/apps/desktop/src/renderer/components/new-chat/VendorSegmentedSwitcher.tsx b/apps/desktop/src/renderer/components/new-chat/VendorSegmentedSwitcher.tsx
index dfa63d655f..d978048c74 100644
--- a/apps/desktop/src/renderer/components/new-chat/VendorSegmentedSwitcher.tsx
+++ b/apps/desktop/src/renderer/components/new-chat/VendorSegmentedSwitcher.tsx
@@ -14,9 +14,9 @@
* - icon: 14×14 Agent 身份 mark (Claude Code / Codex CLI)
* - 文字: Inter 14, active weight 500,inactive weight 400
*
- * F-COLLAB (2026-05): 原本第 3 个 "协同模式" tab 已被 ChatInput 底部的
- * CollaborationModeToggle 取代 — 用户先选 Claude 走单 session,需要时再 toggle
- * 召集 Worker。删 tab 后整体回到 2-tab 220 宽,与历史版本视觉对齐。
+ * F-COLLAB (2026-05): 原本第 3 个 "协同模式" tab 已移入 ChatInput 的「+」菜单 —
+ * 用户先选 Claude 走单 session,需要时再从菜单召集 Worker。删 tab 后整体回到
+ * 2-tab 220 宽,与历史版本视觉对齐。
*/
import { cn } from '@/lib/utils';
diff --git a/apps/desktop/src/renderer/components/ui/morph-popover.tsx b/apps/desktop/src/renderer/components/ui/morph-popover.tsx
index 9302caad2d..6170c4af0e 100644
--- a/apps/desktop/src/renderer/components/ui/morph-popover.tsx
+++ b/apps/desktop/src/renderer/components/ui/morph-popover.tsx
@@ -144,6 +144,9 @@ export function MorphPopover({
const chipRectRef = useRef<DOMRect | null>(null);
// 初始形变是否已完成(ResizeObserver 只在其后接管,避免和开场动画打架)
const settledRef = useRef(false);
+ // 指针选择菜单动作时不把焦点归还 trigger:否则 trigger 的 focus tooltip 会压在
+ // 动作打开的下一层弹窗上。键盘关闭仍按 §14.2 回焦。
+ const pointerInteractionRef = useRef(false);
const requestClose = useCallback(() => onOpenChange(false), [onOpenChange]);
@@ -251,6 +254,7 @@ export function MorphPopover({
if (open) {
settledRef.current = false;
+ pointerInteractionRef.current = false;
const rect = wrap.getBoundingClientRect();
chipRectRef.current = rect;
// 1) 面板落到 chip 精确几何(与 chip 重合的起点),transition 关闭防测量污染。
@@ -343,6 +347,7 @@ export function MorphPopover({
focusSnapTimerRef.current = null;
const active = document.activeElement;
ownedFocusAtClose =
+ !pointerInteractionRef.current &&
active instanceof Node && (panel.contains(active) || wrap.contains(active));
// 快照之后才上 inert(inert 会立刻 blur 面板内焦点,先上会破坏上面的判定):
// pointer-events-none 只挡鼠标不挡 Tab,键盘用户 Esc/选完后立刻 Tab 会摸进
@@ -353,7 +358,17 @@ export function MorphPopover({
() => {
setMounted(false);
if (ownedFocusAtClose) {
- wrap.querySelector<HTMLElement>('button, [tabindex]')?.focus({ preventScroll: true });
+ const active = document.activeElement;
+ const focusClaimedElsewhere =
+ active instanceof Node &&
+ active !== document.body &&
+ !panel.contains(active) &&
+ !wrap.contains(active);
+ if (!focusClaimedElsewhere) {
+ wrap.querySelector<HTMLElement>('button, [tabindex]')?.focus({
+ preventScroll: true,
+ });
+ }
}
},
reducedClose ? 0 : MORPH_MS + 20,
@@ -403,7 +418,11 @@ export function MorphPopover({
requestClose();
};
const onKeyDown = (e: KeyboardEvent) => {
+ if (e.key === 'Enter' || e.key === ' ') {
+ pointerInteractionRef.current = false;
+ }
if (e.key !== 'Escape') return;
+ pointerInteractionRef.current = false;
// 分层关闭(必须 capture,原因见文件头注释)
if (document.querySelector('[data-radix-popper-content-wrapper] [role="dialog"]')) return;
// Esc 时焦点仍在面板内,收合分支的 shouldRestoreFocus 会据此归还 trigger(§14.2)
@@ -434,7 +453,13 @@ export function MorphPopover({
return (
<>
- <span ref={wrapRef} className={cn('relative inline-flex', wrapperClassName)}>
+ <span
+ ref={wrapRef}
+ className={cn('relative inline-flex', wrapperClassName)}
+ onPointerDownCapture={() => {
+ pointerInteractionRef.current = true;
+ }}
+ >
{trigger}
</span>
{mounted &&
@@ -448,6 +473,9 @@ export function MorphPopover({
role="group"
aria-label={panelAriaLabel}
tabIndex={-1}
+ onPointerDownCapture={() => {
+ pointerInteractionRef.current = true;
+ }}
// data-[state=closed]:pointer-events-none —— 收合动画期间面板已透明但仍以
// position:fixed 覆盖视口,不加会拦住底下点击(选完项 / Esc 后那 300ms)。
className="group fixed z-50 overflow-hidden border outline-none data-[state=closed]:pointer-events-none"
diff --git a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx
index e633e8deeb..aa805cdb7c 100644
--- a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx
@@ -1884,12 +1884,12 @@ export function CCAgentSessionView({
// remote-forward 直连本机 MCP bridge、worker 创建继承 remoteHostId;device-link 会话的
// Lead / Worker / team 真身都在被控端,enableOrca 与团队读写经隧道路由过去 ——
// 三类都已接通,不再按 agent 或远端形态限流。
- // 注意:doc rail (isCompactRail) 也允许显示 toggle —— WorkdirBrowseRoute 已经
+ // 注意:doc rail (isCompactRail) 也允许显示协同菜单项 —— WorkdirBrowseRoute 已经
// 针对 Lead session 接入了 OrcaSplitView toggle 布局,普通 session 必须能从
- // ChatInput 工具行启用协同变成 Lead,否则 doc 模式下首次开启入口完全没有。
- // 工具行同时传 denseToolbar=true,协同 pill 自动收成 icon-only,窄 rail 视觉 OK。
+ // ChatInput「+」菜单启用协同变成 Lead,否则 doc 模式下首次开启入口完全没有。
+ const collabWorkspaceKind = session?.workspaceKind;
const collabEntry = resolveCollabEntryPolicy({
- workspaceKind: session?.workspaceKind,
+ workspaceKind: collabWorkspaceKind,
workingDir: session?.workingDir,
orcaRole: session?.orcaRole,
remoteHostId: session?.remoteHostId,
@@ -1899,6 +1899,7 @@ export function CCAgentSessionView({
});
const collabPolicyEligible = !orcaMode && collabEntry.eligible;
const collabPolicy = useCollabProjectPolicy(session?.workingDir, collabPolicyEligible, {
+ workspaceKind: collabWorkspaceKind,
// SSH 远端会话的 workingDir 是远端主机路径, 跳过项目级查询; 用户级/全局级 collab
// 开关仍生效 (与 main 侧 remote 分支同口径)。
skipQuery: collabEntry.skipProjectQuery,
@@ -1972,7 +1973,7 @@ export function CCAgentSessionView({
// navigate 触发条件:仅兼容 orca route 仍在场时需要跳回单 session 路由。
// doc 模式 (isCompactRail=true) 下 OrcaSplitView 把 Lead pane 渲染为
// <CCAgentSessionView ... orcaMode compact />,orcaMode 这里只是表"在 split-pane 里"的语义标,
- // 不能当 navigate 判据 —— 否则用户在 doc rail 工具行点协同 pill 关协同会跳出 doc 模式。
+ // 不能当 navigate 判据 —— 否则用户在 doc rail 的「+」菜单关闭协同会跳出 doc 模式。
// disableOrca 后 lead.orcaRole 被清掉,WorkdirBrowseRoute 的 isOrcaLeadSession 自动 fallback
// 到单 CCAgentSessionView,留在 doc 模式即可。
const { requestStop: requestStopCollab } = useStopOrcaCollab({
@@ -3620,21 +3621,18 @@ export function CCAgentSessionView({
extraDirs={session?.extraDirs ?? []}
onExtraDirsChange={handleExtraDirsChange}
compactToolbar={compactToolbar}
- // doc rail (isCompactRail) 宽度受限 + 拖宽上限,工具行需要把
- // 字号/控件压一档,同时让协同 toggle 只剩 logo。
+ // doc rail (isCompactRail) 宽度受限 + 拖宽上限,工具行需要把字号/控件压一档。
denseToolbar={isCompactRail}
// doc 模式右栏:不抢焦点,避免 TipTap contenteditable 激活
// Windows 中文 IME 后,Ctrl+Shift+F 等组合键被 OS 层吞掉。
// 详见 ChatInput 的 disableAutofocus prop 注释。
disableAutofocus={isCompactRail}
focusOnStorageKeyChange={ownsRoute}
- // F-COLLAB: 协同模式 toggle。在以下场景渲染:
- // - 普通主会话视图 (含 doc rail) 的 Claude / Codex 项目会话,本地 /
- // SSH 远端 / device-link 被控端三类都算(判定见 collabEntry)。
- // 排除 worker 子会话(worker 自己不能再开协同)与对话模式(无项目目录)。
- // orcaMode 路由下 toggle 也保留显示 — ON 态的 orange pill 本身就是
+ // F-COLLAB:「+」菜单里的协同模式项。普通 Lead 的项目/对话会话都渲染,
+ // 项目级与用户级策略范围由 collabEntry 决定;只排除 Worker 子会话
+ // (worker 自己不能再开协同)。
+ // orcaMode 路由下也保留显示 — ON 态菜单项本身就是
// 关闭按钮 (点击触发 onChange({enabled:false}),走 requestStopCollab)。
- // doc rail 的 denseToolbar=true 会把 pill 收成 icon-only 形态。
collaboration={
allowCollabToggle || (orcaMode && collabEnabled)
? {
diff --git a/apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx b/apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx
index 98bc6a0e53..fe4b63afd0 100644
--- a/apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx
@@ -73,7 +73,10 @@ import {
useSessionAttentionKinds,
useSessionAttentionSnapshot,
} from '@/lib/sessionAttentionStore';
-import { patchDraft as patchNewMakerDraft } from '@/state/newMakerDraft';
+import {
+ patchDraft as patchNewMakerDraft,
+ resetDraftWorkspaceTargets,
+} from '@/state/newMakerDraft';
import { consumePendingProjectFocus, usePendingProjectFocus } from '@/state/pendingProjectFocus';
import { requestConversationSearch } from '@/state/conversationSearchRequest';
@@ -1650,7 +1653,7 @@ function ExpandedView({
const handleCreateDialogue = useCallback(() => {
handleClearSelection();
- patchNewMakerDraft({ workingDir: null, remoteHostId: null, extraDirs: [] });
+ resetDraftWorkspaceTargets();
navigate('/cc-agent/new', { state: makeNewMakerRouteState('dialogue') });
}, [handleClearSelection, navigate]);
diff --git a/apps/desktop/src/renderer/features/cc-agent/CreateWorkerPopover.tsx b/apps/desktop/src/renderer/features/cc-agent/CreateWorkerPopover.tsx
index dcb2e6a355..c2fb1ee21e 100644
--- a/apps/desktop/src/renderer/features/cc-agent/CreateWorkerPopover.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/CreateWorkerPopover.tsx
@@ -626,7 +626,7 @@ export function CreateWorkerPopover({
if (!open) return null;
return (
- <div className={cn('fixed inset-0 z-50 flex items-start justify-center pt-[10vh]', className)}>
+ <div className={cn('fixed inset-0 z-50 flex items-center justify-center', className)}>
<div className="absolute inset-0 bg-[var(--overlay-modal)]" onClick={onClose} />
<div
className="relative z-10 w-[500px] rounded-2xl border border-[var(--border-default)] bg-[var(--surface-elevated)] p-6"
@@ -684,87 +684,91 @@ export function CreateWorkerPopover({
)}
</div>
- <div className="mb-4">
- <div className="mb-2 text-12 font-medium uppercase tracking-[0.5px] text-[var(--text-tertiary)]">
- {t('orca.createWorker.agentLabel')}
- </div>
- {/* 应用标准 Agent 分段控件(替换此前手写的按钮组;与 New Maker / IM 目录偏好同款,
- 「不自建选择 UI」的组件复用原则)。 */}
- <VendorSegmentedSwitcher
- value={vendorKey}
- width={220}
- ariaLabel={t('orca.createWorker.agentLabel')}
- onChange={(next) =>
- updateAgent(next === 'codex' ? 'codex' : next === 'pi' ? 'pi' : 'claude-code')
- }
- />
- </div>
-
- <div className="mb-4">
- <div className="mb-2 text-12 font-medium uppercase tracking-[0.5px] text-[var(--text-tertiary)]">
- {t('orca.createWorker.modelLabel')}
- </div>
- {/* composer 同款全功能标准面板(2026-07 用户定稿基准:全软件一个模型选择面板,
- 处处同行为):供应商分段、订阅来源、推理强度、Fast(行级配置列,替代此前的
- 外置开关)全开;选定来源随创建参数显式下发,由 OrcaWorkerCreationService
- 精确 preflight。device-link 远程创建维持既有退化:被控端纯列表、无来源维度,
- 且面板行级 Fast 依赖来源分段(fastEditable 走 connected 目录),故远程仍用
- 外置 FastModeToggle,不能删。 */}
- <div className="flex items-center gap-2">
- {deviceId && currentModelSupportsFast && (
- <FastModeToggle enabled={fast} onToggle={() => setFast((v) => !v)} />
- )}
- <ModelSelector
- modelId={model}
- effort={effort}
- onModelChange={updateModel}
- onEffortChange={updateEffort}
- vendorKey={vendorKey}
- deviceId={deviceId}
- // SSH 远程 Lead:与 ChatInput 同口径藏掉仅本地可桥接的模型/来源
- // (订阅直连接本地 compat-proxy,openai-chat 桥接 Codex 接本地
- // codex-proxy,远端都不经翻译)—— 否则提交才被 main 侧 guard 拒绝。
- excludeSubscriptionDirect={sshRemote === true}
- excludeChatBridgedCodex={sshRemote === true}
- popoverSide="bottom"
- currentProviderId={
- deviceId
- ? undefined
- : sshRemote === true
- ? narrowProviderSource(providerSource, model)
- : providerSource
+ <div className="mb-4 grid grid-cols-[220px_minmax(0,1fr)] gap-4">
+ <div className="min-w-0">
+ <div className="mb-2 text-12 font-medium uppercase tracking-[0.5px] text-[var(--text-tertiary)]">
+ {t('orca.createWorker.agentLabel')}
+ </div>
+ {/* 应用标准 Agent 分段控件(替换此前手写的按钮组;与 New Maker / IM 目录偏好同款,
+ 「不自建选择 UI」的组件复用原则)。 */}
+ <VendorSegmentedSwitcher
+ value={vendorKey}
+ width={220}
+ ariaLabel={t('orca.createWorker.agentLabel')}
+ onChange={(next) =>
+ updateAgent(next === 'codex' ? 'codex' : next === 'pi' ? 'pi' : 'claude-code')
}
- onProviderChange={deviceId ? undefined : handleProviderChange}
- // providerSource=null 时面板高亮的是**解析出来的生效默认来源**,点它的
- // 语义是「把默认来源钉成显式偏好」,必须照常回调(codex review)——否则
- // 用户点了没反应,之后默认路由一变创建就静默换来源。显式同值幂等无害。
- reselectEmitsChange
- // 分离侧栏窗口固定在 /sidebar-window 壳路由,本地 navigate 会把辅助
- // 窗口整壳替换成主设置路由(codex review)——与 OrcaWorkerPanel 的
- // settingsEnabled={!isSidebarWindow()} 同禁用口径,不接线跳转。
- onNavigateToProviders={
- deviceId || isSidebarWindow()
- ? undefined
- : () => {
- onClose();
- navigate('/settings?tab=providers');
- }
- }
- modelMemory={modelMemory}
- // worker 创建链的显式 Fast 派发支持 Codex 与 Pi(resolveWorkerConfig 对二者
- // 消费 input.fast,并按模型 supportsFastMode 收口):cc 层面为 no-op,不接线,
- // 面板就不显示 Fast 开关,避免「开关能开、提交被丢」的名不副实(codex review)。
- fastMode={deviceId || !(agent === 'codex' || agent === 'pi') ? undefined : fast}
- onFastModeChange={deviceId || !(agent === 'codex' || agent === 'pi') ? undefined : updateFast}
/>
</div>
- {noAvailableLocalModels ? (
- <p className="mt-1.5 text-11 leading-snug text-[var(--error-fg)]" role="status">
- {t('orca.createWorker.noAvailableModels', {
- agent: agent === 'codex' ? 'Codex' : agent === 'pi' ? 'Pi' : 'Claude Code',
- })}
- </p>
- ) : null}
+
+ <div className="min-w-0">
+ <div className="mb-2 text-12 font-medium uppercase tracking-[0.5px] text-[var(--text-tertiary)]">
+ {t('orca.createWorker.modelLabel')}
+ </div>
+ {/* composer 同款全功能标准面板(2026-07 用户定稿基准:全软件一个模型选择面板,
+ 处处同行为):供应商分段、订阅来源、推理强度、Fast(行级配置列,替代此前的
+ 外置开关)全开;选定来源随创建参数显式下发,由 OrcaWorkerCreationService
+ 精确 preflight。device-link 远程创建维持既有退化:被控端纯列表、无来源维度,
+ 且面板行级 Fast 依赖来源分段(fastEditable 走 connected 目录),故远程仍用
+ 外置 FastModeToggle,不能删。 */}
+ <div className="flex min-w-0 items-center gap-2">
+ {deviceId && currentModelSupportsFast && (
+ <FastModeToggle enabled={fast} onToggle={() => setFast((v) => !v)} />
+ )}
+ <ModelSelector
+ modelId={model}
+ effort={effort}
+ onModelChange={updateModel}
+ onEffortChange={updateEffort}
+ vendorKey={vendorKey}
+ deviceId={deviceId}
+ // SSH 远程 Lead:与 ChatInput 同口径藏掉仅本地可桥接的模型/来源
+ // (订阅直连接本地 compat-proxy,openai-chat 桥接 Codex 接本地
+ // codex-proxy,远端都不经翻译)—— 否则提交才被 main 侧 guard 拒绝。
+ excludeSubscriptionDirect={sshRemote === true}
+ excludeChatBridgedCodex={sshRemote === true}
+ popoverSide="bottom"
+ currentProviderId={
+ deviceId
+ ? undefined
+ : sshRemote === true
+ ? narrowProviderSource(providerSource, model)
+ : providerSource
+ }
+ onProviderChange={deviceId ? undefined : handleProviderChange}
+ // providerSource=null 时面板高亮的是**解析出来的生效默认来源**,点它的
+ // 语义是「把默认来源钉成显式偏好」,必须照常回调(codex review)——否则
+ // 用户点了没反应,之后默认路由一变创建就静默换来源。显式同值幂等无害。
+ reselectEmitsChange
+ // 分离侧栏窗口固定在 /sidebar-window 壳路由,本地 navigate 会把辅助
+ // 窗口整壳替换成主设置路由(codex review)——与 OrcaWorkerPanel 的
+ // settingsEnabled={!isSidebarWindow()} 同禁用口径,不接线跳转。
+ onNavigateToProviders={
+ deviceId || isSidebarWindow()
+ ? undefined
+ : () => {
+ onClose();
+ navigate('/settings?tab=providers');
+ }
+ }
+ modelMemory={modelMemory}
+ // worker 创建链的显式 Fast 派发支持 Codex 与 Pi(resolveWorkerConfig 对二者
+ // 消费 input.fast,并按模型 supportsFastMode 收口):cc 层面为 no-op,不接线,
+ // 面板就不显示 Fast 开关,避免「开关能开、提交被丢」的名不副实(codex review)。
+ fastMode={deviceId || !(agent === 'codex' || agent === 'pi') ? undefined : fast}
+ onFastModeChange={
+ deviceId || !(agent === 'codex' || agent === 'pi') ? undefined : updateFast
+ }
+ />
+ </div>
+ {noAvailableLocalModels ? (
+ <p className="mt-1.5 text-11 leading-snug text-[var(--error-fg)]" role="status">
+ {t('orca.createWorker.noAvailableModels', {
+ agent: agent === 'codex' ? 'Codex' : agent === 'pi' ? 'Pi' : 'Claude Code',
+ })}
+ </p>
+ ) : null}
+ </div>
</div>
<div className="mb-5">
diff --git a/apps/desktop/src/renderer/features/cc-agent/NewMakerDraftRoute.tsx b/apps/desktop/src/renderer/features/cc-agent/NewMakerDraftRoute.tsx
index c918a23cab..c94664fef6 100644
--- a/apps/desktop/src/renderer/features/cc-agent/NewMakerDraftRoute.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/NewMakerDraftRoute.tsx
@@ -225,8 +225,8 @@ const log = createLogger('NewMakerDraftRoute');
const IS_MAC_PLATFORM = typeof window !== 'undefined' && window.electronAPI?.platform === 'darwin';
// F-COLLAB (2026-05): 老的 vendor='orca' 入口已退役,OrcaHeaderStrip 组件随之
// 删除(它是给 isOrca 分支的 ChatInput.topSlot 用的)。Lead/Worker 协作组合现在
-// 由 ChatInput 底部 CollaborationModeToggle 控制,Lead 是当前 vendor 本身,
-// Worker 通过 toggle popover 选 cc / codex。
+// 由 ChatInput「+」菜单里的协同模式项控制,Lead 是当前 vendor 本身,
+// Worker 通过完整配置弹窗选择 cc / codex / pi。
function makeDraftSessionId(): string {
return crypto.randomUUID();
@@ -596,12 +596,8 @@ export function NewMakerDraftRoute() {
const [wtSupportsRecoveryKeyDiscard, setWtSupportsRecoveryKeyDiscard] = useState<boolean | null>(null);
// F-COLLAB: 协同模式状态(enabled + worker 类型)直接读自 draft store,
// 和 workingDir 走同一份 localStorage,重启 / 切走再回都能恢复。
- // 互斥约束(本组件 enforce):
- // - draft.workingDir == null (对话模式) → 不向 ChatInput 传 collaboration prop,
- // CollaborationModeToggle 不渲染
- // - draft.collab.enabled = true → 工作区选择入口隐藏
- // "对话(不在项目中)"入口,workdir 不可能切到 null
- // 兜底见 patchDraft: 任何把 workingDir 设回 null 的路径会自动关 collab。
+ // 协同与项目/对话形态正交:两种草稿都向 ChatInput 提供入口;项目读项目级策略,
+ // 对话只读用户级/全局级策略。发送成功后 resetDraftWorkspaceTargets 显式消费本次选择。
const collab = draft.collab;
// ChatInput 现在要求显式拥有 attachmentState。这条 transient 路由没有
// sessionId(还没建会话),sessionId 仍传 undefined(图片本地缓存走 base64
@@ -764,16 +760,18 @@ export function NewMakerDraftRoute() {
// 协同入口判定与会话视图共用同一个 helper(issue #1170:两处各写一份判据,于是同一个
// device-link 项目在草稿里没入口、进会话页又有)。草稿的 workspaceKind 显式按
// "有没有选项目目录" 给出 —— 与它提交给 createSession 的值同源,不让 helper 反推。
+ const collabWorkspaceKind = effectiveWorkingDir ? 'project' : 'dialogue';
const collabEntry = resolveCollabEntryPolicy({
- workspaceKind: effectiveWorkingDir ? 'project' : 'dialogue',
+ workspaceKind: collabWorkspaceKind,
workingDir: effectiveWorkingDir,
remoteHostId: effectiveRemoteHostId,
deviceLinkDeviceId: effectiveDeviceLinkDeviceId,
});
const collabPolicyEligible = collabEntry.eligible;
const collabPolicy = useCollabProjectPolicy(effectiveWorkingDir, collabPolicyEligible, {
- // SSH 远端 draft 的 workingDir 是远端主机路径, 本机项目级查询无意义, 跳过;
- // 用户级/全局级 collab 开关仍生效 (与 main 侧 remote 分支同口径)。
+ workspaceKind: collabWorkspaceKind,
+ // dialogue 没有用户项目,SSH 远端 draft 的 workingDir 又是远端主机路径;两者都跳过
+ // 本机项目级查询,但用户级/全局级 collab 开关仍生效。
skipQuery: collabEntry.skipProjectQuery,
// device-link draft:项目级开关的真相在被控端, 隧道过去查(控制端本机查那条远端
// 路径只会读到自己的用户级开关, 可能与被控端 main 的授权相反)。
@@ -1716,7 +1714,7 @@ export function NewMakerDraftRoute() {
attachmentState.clearFiles();
}
resetDraftWorkspaceAfterSend();
- // F-COLLAB: draft 阶段开了协同 toggle → 与 send/goal 路径同口径,
+ // F-COLLAB: draft 阶段开了协同模式 → 与 send/goal 路径同口径,
// createSession 后立刻 enableOrca 拉起 Worker;失败 toast 但保留
// Lead 会话继续 navigate (用户可继续单 session, 不阻断)。
let orcaWorkersRevealState: { focusWorkerSessionId: string } | null = null;
@@ -2493,9 +2491,9 @@ export function NewMakerDraftRoute() {
}
// F-COLLAB (2026-05): 老的 vendor='orca' 创建分支已删除。协同模式现在
- // 走 ChatInput 底部 toggle (CollaborationModeToggle):用户开了 toggle 后
+ // 走 ChatInput「+」菜单:用户开启后
// Send 流程会先 createSession (本段下方) 创建 Lead,然后立刻调 enableOrca
- // 拉起 Worker (见下方 "F-COLLAB: draft 阶段开了协同 toggle" 段)。
+ // 拉起 Worker (见下方 "F-COLLAB: draft 阶段开了协同模式" 段)。
const sessionId = makeDraftSessionId();
const workingDir = selectedWorkingDir;
@@ -2761,7 +2759,7 @@ export function NewMakerDraftRoute() {
}
}
- // F-COLLAB: draft 阶段开了协同 toggle → createSession 之后立刻 enableOrca
+ // F-COLLAB: draft 阶段开了协同模式 → createSession 之后立刻 enableOrca
// 拉起 Worker。失败 toast 但保留 Lead session(用户可以继续单 session 聊),
// 不阻断 send 流程。worker 类型由 popover 选择,失败回退到单 session 路由。
let orcaNavTarget: string | null = null;
@@ -3471,8 +3469,6 @@ export function NewMakerDraftRoute() {
externalDragOver={pageDragOver}
visualVariant="create-agent"
compactToolbar
- // denseToolbar 去除(2026-07-22):hero 输入框够宽,协同 toggle 应显示「协同」文字
- // 与会话内主视图一致;窄窗口仍由 autoDenseToolbar 自动收成 icon-only。
placeholder="Hi Cindy!"
sessionId={undefined}
initialWorkingDir={effectiveWorkingDir}
@@ -3507,10 +3503,8 @@ export function NewMakerDraftRoute() {
hiddenVendors={hiddenSwitcherVendors}
/>
}
- // 协同 toggle(与对话界面同一控件):本地 / SSH 远端 / device-link 项目 draft
- // 均可用 —— eligible 由 resolveCollabEntryPolicy 单点判定,与会话视图同一份
- // (issue #1170:两处各写一份判据造成入口前后不一致)。仍然不支持的只有对话
- // 模式(无 workingDir)。Lead = 当前
+ // 「+」菜单协同模式项:普通 Lead 的项目/对话 draft 都可用 —— eligible 由
+ // resolveCollabEntryPolicy 单点判定,与会话视图同一份(issue #1170)。Lead = 当前
// vendor(上方 VendorSegmentedSwitcher)。onOpenDetails 打开「开启协同」富弹窗
// (CreateWorkerPopover:role/agent/model/初始任务),与会话内完全一致;OFF 态点击
// 走它而非简单 worker popover。ON 态点击 onChange(enabled:false) 关闭协同。
diff --git a/apps/desktop/src/renderer/features/cc-agent/__tests__/CreateWorkerPopover.test.tsx b/apps/desktop/src/renderer/features/cc-agent/__tests__/CreateWorkerPopover.test.tsx
index 6295e18c63..2364e22eda 100644
--- a/apps/desktop/src/renderer/features/cc-agent/__tests__/CreateWorkerPopover.test.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/__tests__/CreateWorkerPopover.test.tsx
@@ -208,6 +208,28 @@ describe('CreateWorkerPopover', () => {
resetProviderModelMemoryForTest();
});
+ it('centers the setup and keeps agent and model on one row without changing its size', () => {
+ render(<CreateWorkerPopover open onClose={vi.fn()} onCreate={vi.fn()} />);
+
+ const panel = screen.getByText('orca.createWorker.title').closest('.relative.z-10');
+ const overlay = panel?.parentElement;
+ expect(overlay?.className).toContain('items-center');
+ expect(overlay?.className).not.toContain('items-start');
+ expect(overlay?.className).not.toContain('pt-[10vh]');
+ expect(panel?.className).toContain('w-[500px]');
+ expect(panel?.className).toContain('p-6');
+
+ const agentSwitcher = screen.getByRole('tablist', {
+ name: 'orca.createWorker.agentLabel',
+ });
+ const pairedFields = agentSwitcher.closest('.grid');
+ expect(pairedFields?.className).toContain('grid-cols-[220px_minmax(0,1fr)]');
+ expect(pairedFields?.contains(screen.getByTestId('model-selector'))).toBe(true);
+
+ const initialTask = screen.getByPlaceholderText('orca.createWorker.initialTaskPlaceholder');
+ expect(initialTask.className).toContain('h-[96px]');
+ });
+
it('disables immediately and collapses repeated click events into one request', async () => {
let finishCreate!: () => void;
const onCreate = vi.fn(
diff --git a/apps/desktop/src/renderer/features/cc-agent/collabEntryPolicy.ts b/apps/desktop/src/renderer/features/cc-agent/collabEntryPolicy.ts
index 5a06cb00e4..db57854142 100644
--- a/apps/desktop/src/renderer/features/cc-agent/collabEntryPolicy.ts
+++ b/apps/desktop/src/renderer/features/cc-agent/collabEntryPolicy.ts
@@ -39,9 +39,10 @@ export interface CollabEntryPolicyScope {
policyDeviceId?: string;
/**
* true = 跳过项目级查询,只落用户级/全局级。
- * SSH 远端会话的 workingDir 是远端机器上的路径,拿它在**执行查询的那台机器**的 fs 上
- * 找项目配置既无意义又会误判(命中同路径的本地目录会误开,查不到又会误拒);远端项目级
- * collab 配置机制尚未存在(main 侧 assertCollabProjectEnabled 的 remote 分支同口径)。
+ * 尚未分配运行目录的 dialogue 草稿自然只读用户级开关;已有 workingDir 的本地 dialogue
+ * 则把 kind 与目录交给 Main 的可信判据(托管 dialogue 强制只读全局,显式真实目录尊重项目覆盖)。
+ * SSH 远端会话的 workingDir 属于远端机器,拿它在**执行查询的那台机器**的 fs 上找项目
+ * 配置既无意义又会误判。远端项目级 collab 配置机制尚未存在(main 侧 remote 分支同口径)。
*/
skipProjectQuery: boolean;
}
@@ -60,7 +61,8 @@ function nonEmpty(value: string | null | undefined): string | null {
* | 本地项目 | ✅ | 本机项目级 |
* | SSH 远端项目(remoteHostId) | ✅ | skipProjectQuery(仅用户/全局级) |
* | device-link 项目(deviceLinkDeviceId) | ✅ | 隧道到该被控设备查项目级 |
- * | dialogue(无项目目录) | ❌ | — |
+ * | dialogue 草稿(尚无运行目录) | ✅ | skipProjectQuery(仅用户/全局级) |
+ * | 本地 dialogue(已有运行目录) | ✅ | 查询目录;Main 区分托管/显式目录 |
* | Orca Worker 子会话 | ❌ | — |
*
* 两个远端维度**可以同时成立**(在被控设备上打开的 SSH 远端项目):此时既要隧道到被控端,
@@ -68,13 +70,20 @@ function nonEmpty(value: string | null | undefined): string | null {
*/
export function resolveCollabEntryPolicy(target: CollabEntryTarget): CollabEntryPolicyScope {
if (target.orcaRole === 'worker') return NOT_ELIGIBLE;
- if (target.workspaceKind !== 'project') return NOT_ELIGIBLE;
- if (nonEmpty(target.workingDir) === null) return NOT_ELIGIBLE;
+ if (target.workspaceKind !== 'project' && target.workspaceKind !== 'dialogue') {
+ return NOT_ELIGIBLE;
+ }
+ const workingDir = nonEmpty(target.workingDir);
+ if (target.workspaceKind === 'project' && workingDir === null) {
+ return NOT_ELIGIBLE;
+ }
const deviceId = nonEmpty(target.deviceLinkDeviceId);
return {
eligible: true,
...(deviceId ? { policyDeviceId: deviceId } : {}),
- skipProjectQuery: nonEmpty(target.remoteHostId) !== null,
+ skipProjectQuery:
+ nonEmpty(target.remoteHostId) !== null ||
+ (target.workspaceKind === 'dialogue' && workingDir === null),
};
}
diff --git a/apps/desktop/src/renderer/features/cc-agent/hooks/__tests__/useCollabProjectPolicy.test.ts b/apps/desktop/src/renderer/features/cc-agent/hooks/__tests__/useCollabProjectPolicy.test.ts
index 5f6b962d5c..63850dcda3 100644
--- a/apps/desktop/src/renderer/features/cc-agent/hooks/__tests__/useCollabProjectPolicy.test.ts
+++ b/apps/desktop/src/renderer/features/cc-agent/hooks/__tests__/useCollabProjectPolicy.test.ts
@@ -262,6 +262,57 @@ describe('useCollabProjectPolicy', () => {
expect(getState).toHaveBeenCalledWith('collab', undefined);
});
+ it('skipQuery lets a dialogue draft without a workingDir read the user/global setting', async () => {
+ const getState = vi.fn().mockResolvedValue({ effectiveEnabled: true });
+ (window as unknown as { electronAPI: { maker: { plugins: { getState: typeof getState } } } }).electronAPI = {
+ maker: { plugins: { getState } },
+ };
+
+ const { result } = renderHook(() =>
+ useCollabProjectPolicy(null, true, { skipQuery: true }),
+ );
+
+ await waitFor(() => expect(result.current.enabled).toBe(true));
+ expect(getState).toHaveBeenCalledWith('collab', undefined);
+ });
+
+ it('passes dialogue kind to Main so it can recognize an app-managed cwd', async () => {
+ const getState = vi.fn().mockResolvedValue({ effectiveEnabled: true });
+ (window as unknown as { electronAPI: { maker: { plugins: { getState: typeof getState } } } }).electronAPI = {
+ maker: { plugins: { getState } },
+ };
+ const workingDir = '/app-managed/dialogues/2026-08-02/session-1';
+
+ const { result } = renderHook(() =>
+ useCollabProjectPolicy(workingDir, true, { workspaceKind: 'dialogue' }),
+ );
+
+ await waitFor(() => expect(result.current.enabled).toBe(true));
+ expect(getState).toHaveBeenCalledWith('collab', workingDir, 'dialogue');
+ });
+
+ it('includes workspace kind in the query key', async () => {
+ const getState = vi
+ .fn()
+ .mockResolvedValueOnce({ effectiveEnabled: true })
+ .mockResolvedValueOnce({ effectiveEnabled: false });
+ (window as unknown as { electronAPI: { maker: { plugins: { getState: typeof getState } } } }).electronAPI = {
+ maker: { plugins: { getState } },
+ };
+ const workingDir = '/app-managed/dialogues/2026-08-02/session-1';
+ const { result, rerender } = renderHook(
+ ({ workspaceKind }: { workspaceKind: 'dialogue' | 'project' }) =>
+ useCollabProjectPolicy(workingDir, true, { workspaceKind }),
+ { initialProps: { workspaceKind: 'dialogue' as 'dialogue' | 'project' } },
+ );
+
+ await waitFor(() => expect(result.current.enabled).toBe(true));
+ rerender({ workspaceKind: 'project' });
+ await waitFor(() => expect(result.current.enabled).toBe(false));
+ expect(getState).toHaveBeenNthCalledWith(1, 'collab', workingDir, 'dialogue');
+ expect(getState).toHaveBeenNthCalledWith(2, 'collab', workingDir, 'project');
+ });
+
// ── device-link:项目级开关的真相在被控端(issue #1170)────────────────────────
// 此前一律查控制端本机:拿被控端的路径在自己的 fs 上找 `.cindy/plugins.json` 必然落空,
// 于是读到的是控制端自己的用户级开关,与被控端 main 的 assertCollabProjectEnabled 可能
@@ -280,17 +331,66 @@ describe('useCollabProjectPolicy', () => {
const { getState } = stubDeviceLink(invoke);
const { result } = renderHook(() =>
- useCollabProjectPolicy('/host/proj', true, { deviceId: 'dev-1' }),
+ useCollabProjectPolicy('/host/proj', true, {
+ deviceId: 'dev-1',
+ workspaceKind: 'project',
+ }),
);
await waitFor(() => expect(result.current.loading).toBe(false));
expect(invoke).toHaveBeenCalledWith('dev-1', 'maker:plugins:get-state', [
'collab',
'/host/proj',
+ 'project',
]);
expect(getState).not.toHaveBeenCalled();
// 被控端说这个项目关了协同 → 入口置灰,而不是照控制端自己的开关放行。
expect(result.current.enabled).toBe(false);
+ // 旧项目入口在 get-state channel 已存在时仍保持原行为;新握手只约束 dialogue。
+ expect(result.current.unsupported).toBe(false);
+ });
+
+ it('device-link 对话草稿:无 workingDir 也会隧道查询被控端用户/全局级', async () => {
+ const invoke = vi.fn().mockResolvedValue({
+ effectiveEnabled: true,
+ collabWorkspaceKind: 'dialogue',
+ });
+ const { getState } = stubDeviceLink(invoke);
+
+ const { result } = renderHook(() =>
+ useCollabProjectPolicy(null, true, {
+ skipQuery: true,
+ deviceId: 'dev-1',
+ workspaceKind: 'dialogue',
+ }),
+ );
+
+ await waitFor(() => expect(result.current.enabled).toBe(true));
+ expect(invoke).toHaveBeenCalledWith('dev-1', 'maker:plugins:get-state', [
+ 'collab',
+ undefined,
+ 'dialogue',
+ ]);
+ expect(getState).not.toHaveBeenCalled();
+ });
+
+ it('device-link 对话:旧被控端未确认 workspaceKind 时 fail-closed 为 unsupported', async () => {
+ // 旧端已有 get-state channel,所以调用成功;但它忽略第三参且不支持 dialogue 最终授权。
+ const invoke = vi.fn().mockResolvedValue({ effectiveEnabled: true });
+ stubDeviceLink(invoke);
+
+ const { result } = renderHook(() =>
+ useCollabProjectPolicy(null, true, {
+ skipQuery: true,
+ deviceId: 'dev-old',
+ workspaceKind: 'dialogue',
+ }),
+ );
+
+ await waitFor(() => expect(result.current.unsupported).toBe(true));
+ expect(result.current.enabled).toBe(false);
+ expect(result.current.unavailable).toBe(false);
+ expect(result.current.loading).toBe(false);
});
it('同一路径串在两台设备上不串台(查询键含 deviceId)', async () => {
diff --git a/apps/desktop/src/renderer/features/cc-agent/hooks/useCollabProjectPolicy.ts b/apps/desktop/src/renderer/features/cc-agent/hooks/useCollabProjectPolicy.ts
index 541ad88c80..73f4b3dc48 100644
--- a/apps/desktop/src/renderer/features/cc-agent/hooks/useCollabProjectPolicy.ts
+++ b/apps/desktop/src/renderer/features/cc-agent/hooks/useCollabProjectPolicy.ts
@@ -46,32 +46,41 @@ type ProjectRefreshTracker = {
* 只会读到自己的用户级开关,可能与被控端 main 的 assertCollabProjectEnabled 相反 ——
* 那正是 #1170 里「草稿没入口 / 会话有入口但走不完」的第二层来源。
*
- * `skipQuery`(SSH 远端):workingDir 是远端主机上的路径, 在执行查询的那台机器的 fs 上查
- * 项目级既无意义又会误判 — 跳过项目级覆盖, 但仍查用户级/全局级 collab 开关
- * (与 main 侧 assertCollabProjectEnabled 的 remote 分支同口径): 用户全局禁用 Collab 时
- * UI toggle 同样置灰, 而不是放行到 enableOrca 才撞 PRECONDITION_FAILED。
+ * `skipQuery`(尚无运行目录的 dialogue 草稿 / SSH 远端):草稿没有可查目录,远端 workingDir
+ * 则不属于执行查询的本机 fs;两者都跳过项目级覆盖,但仍查用户级/全局级 collab 开关。
+ * 已创建的本地 dialogue 把 workspaceKind + workingDir 交给查询:Main 会用与最终授权相同
+ * 的可信判据把 app 托管 dialogue 目录强制收敛到全局级,显式真实目录继续尊重项目覆盖。
+ * 即使托管 cwd 里意外出现 `.cindy/plugins.json`,入口状态也不会与 mutation 判定漂移。
*/
export function useCollabProjectPolicy(
workingDir: string | null | undefined,
eligible: boolean,
- opts?: { skipQuery?: boolean; deviceId?: string | null },
+ opts?: { skipQuery?: boolean; deviceId?: string | null; workspaceKind?: string | null },
): CollabProjectPolicy {
const skipQuery = opts?.skipQuery === true;
// skipQuery 用 '' 作查询参数:'' 占位表示 "跳过项目级、只查用户级" 那一档。
const requestedWorkingDir =
- eligible && typeof workingDir === 'string'
- ? skipQuery
+ !eligible
+ ? null
+ : skipQuery
? ''
- : normalizeWorkingDirForProjectSettings(workingDir)
- : null;
+ : typeof workingDir === 'string'
+ ? normalizeWorkingDirForProjectSettings(workingDir)
+ : null;
const requestedDeviceId =
eligible && typeof opts?.deviceId === 'string' && opts.deviceId.trim() !== ''
? opts.deviceId
: null;
+ const requestedWorkspaceKind =
+ eligible && (opts?.workspaceKind === 'project' || opts?.workspaceKind === 'dialogue')
+ ? opts.workspaceKind
+ : undefined;
// 键含 deviceId:两台被控设备完全可能出现同一个路径串(`/Users/me/proj`),只按路径
// 做键会让 A 设备的答案被当成 B 设备的,入口据此置灰/放行都是错的。
const requestKey =
- requestedWorkingDir == null ? null : `${requestedDeviceId ?? ''}\u0000${requestedWorkingDir}`;
+ requestedWorkingDir == null
+ ? null
+ : `${requestedDeviceId ?? ''}\u0000${requestedWorkspaceKind ?? ''}\u0000${requestedWorkingDir}`;
const [state, setState] = useState<PolicyState>({
queryKey: null,
enabled: requestKey == null ? false : null,
@@ -104,17 +113,33 @@ export function useCollabProjectPolicy(
requestedDeviceId,
'collab',
requestedWorkingDir === '' ? undefined : requestedWorkingDir,
+ requestedWorkspaceKind,
);
- const result = { enabled: next.effectiveEnabled, unavailable: false, unsupported: false };
+ // 旧被控端虽然已有 get-state channel,却会忽略 workspaceKind,最终授权也不接受
+ // dialogue。只有被控端显式回显已接受 dialogue,远端 dialogue 入口才可放行。
+ const unsupported =
+ requestedDeviceId !== null &&
+ requestedWorkspaceKind === 'dialogue' &&
+ next.collabWorkspaceKind !== 'dialogue';
+ if (unsupported) {
+ log.info('remote device does not support dialogue collaboration policy', {
+ deviceId: requestedDeviceId,
+ });
+ }
+ const result = {
+ enabled: unsupported ? false : next.effectiveEnabled,
+ unavailable: false,
+ unsupported,
+ };
if (requestId !== requestIdRef.current) {
const latest = refreshTrackersByKeyRef.current.get(requestKey)?.latestPromise;
return latest && latest !== requestPromise ? latest : result;
}
setState({
queryKey: requestKey,
- enabled: result.enabled,
+ enabled: unsupported ? null : result.enabled,
unavailable: false,
- unsupported: false,
+ unsupported,
});
return result;
} catch (err) {
@@ -156,7 +181,7 @@ export function useCollabProjectPolicy(
}
});
return requestPromise;
- }, [requestKey, requestedDeviceId, requestedWorkingDir]);
+ }, [requestKey, requestedDeviceId, requestedWorkingDir, requestedWorkspaceKind]);
useEffect(() => {
if (!eligible) return;
diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionStatusIcon.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionStatusIcon.tsx
index 2f359c993f..966af012bb 100644
--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionStatusIcon.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionStatusIcon.tsx
@@ -5,7 +5,7 @@
* (SessionCard card 变体)」共用同一份逻辑,确保两处**完全一致**:
* - archived → Archive 图标(vendor 已不重要)
* - attached(/ctr 接管中)→ RadioTower,优先级高于 running(接管期桌面被动观察)
- * - orca-lead(协同) → UsersRound(与右侧栏「协同」pill 同款)
+ * - orca-lead(协同) → UsersRound(与「+」菜单协同项同款)
* - 其余 → VendorIcon(Claude Code 像素脸 / Codex CLI 花形+`>_`)
* running:图标切 Thinking Orange + 呼吸;需关注:右上叠状态点(全端统一色表:
* error 红 / awaiting TapTap 蓝 / 完成未读绿,tone 按行精准订阅 attention store);
diff --git a/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx b/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx
index 4eaf0f2642..354831c94e 100644
--- a/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx
+++ b/apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx
@@ -31,7 +31,7 @@ import {
plainTextToTiptapDoc,
saveDraft as saveComposerDraft,
} from '@/lib/composerDraftStore';
-import { patchDraft } from '@/state/newMakerDraft';
+import { resetDraftWorkspaceTargets } from '@/state/newMakerDraft';
import { ghostInstallErrorKey } from '@/cindy-brain/installErrorKey';
import { confirmAndInstallGhost, pickAndUpdateGhost } from '@/cindy-brain/installFlow';
import { GhostPermissionList, GhostUpdateReview } from '@/cindy-brain/GhostPermissionList';
@@ -599,12 +599,7 @@ export function GhostPluginPage() {
attachments: [],
focusAtEnd: true,
});
- patchDraft({
- workingDir: null,
- remoteHostId: null,
- deviceLinkDeviceId: null,
- deviceLinkDeviceName: null,
- });
+ resetDraftWorkspaceTargets();
navigate('/cc-agent/new');
}, [navigate, t]);
@@ -655,12 +650,7 @@ export function GhostPluginPage() {
browserComments: existing?.browserComments ?? [],
pendingGhostId: ghost.manifest.id,
});
- patchDraft({
- workingDir: null,
- remoteHostId: null,
- deviceLinkDeviceId: null,
- deviceLinkDeviceName: null,
- });
+ resetDraftWorkspaceTargets();
navigate('/cc-agent/new');
},
[confirm, ghosts, navigate, openGhostConfiguration, t],
diff --git a/apps/desktop/src/renderer/features/skillhub/SkillhubMarketPreviewPanel.tsx b/apps/desktop/src/renderer/features/skillhub/SkillhubMarketPreviewPanel.tsx
index 6b7efbb9fd..e6f40ad63e 100644
--- a/apps/desktop/src/renderer/features/skillhub/SkillhubMarketPreviewPanel.tsx
+++ b/apps/desktop/src/renderer/features/skillhub/SkillhubMarketPreviewPanel.tsx
@@ -9,7 +9,7 @@ import { useNavigate } from 'react-router-dom';
import { cn } from '@/lib/utils';
import { plainTextToTiptapDoc, saveDraft as saveComposerDraft } from '@/lib/composerDraftStore';
import { NEW_MAKER_DRAFT_KEY } from '@/features/cc-agent/NewMakerDraftRoute';
-import { patchDraft } from '@/state/newMakerDraft';
+import { resetDraftWorkspaceTargets } from '@/state/newMakerDraft';
import type { MarketSkill } from './hooks/useMarketList';
import {
buildPreviewTree,
@@ -242,13 +242,8 @@ export function SkillhubMarketPreviewPanel({
// 草稿目标重置为本地对话:残留的 device-link 远程草稿
// (workingDir/deviceId)会让 /learn 发进远程会话 —— 那里
// 该命令被剔除,会退化成普通消息(Codex review)。
- // workingDir 置 null 同时会自动关 collab(见 patchDraft)。
- patchDraft({
- workingDir: null,
- remoteHostId: null,
- deviceLinkDeviceId: null,
- deviceLinkDeviceName: null,
- });
+ // /learn 是一份新草稿,统一复位工作区、远程目标和一次性协同选择。
+ resetDraftWorkspaceTargets();
onClose();
navigate('/cc-agent/new');
}}
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index 47d7a8e844..afcdf5123b 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -5108,13 +5108,13 @@
"startFailedContinue": "Failed to start collaboration. Continuing as a single session.",
"createWorkerRefreshFailed": "Unable to refresh Worker status. Please try again.",
"openHint": "Bring in a Worker to help",
- "disabledHint": "Collaboration is disabled for this project. Enable it in project settings.",
- "unavailableHint": "Unable to verify this project's collaboration setting. Try again shortly.",
+ "disabledHint": "Collaboration is disabled. Enable it in settings.",
+ "unavailableHint": "Unable to verify the collaboration setting. Try again shortly.",
"unsupportedRemoteHint": "The controlled device is too old to support collaboration.",
"remoteContinueNotice": " This message is still being sent as a single session.",
"handoffRecoveredMessage": "Collaboration startup was interrupted last time. Your unsent message has been restored to the composer.",
"handoffRecoveredGoal": "Collaboration startup was interrupted last time. The goal was not started; its text has been restored to the composer.",
- "loadingHint": "Still checking this project's collaboration setting. Try again shortly.",
+ "loadingHint": "Still checking the collaboration setting. Try again shortly.",
"stopHint": "Stop collaboration",
"stopAria": "Stop collaboration",
"toggleOnAria": "Collaboration on — click to stop",
@@ -5141,8 +5141,8 @@
"BUDGET_MODEL_REQUIRES_API_MODE": "This Codex model requires an API key. Configure it in Settings, then try again.",
"BUDGET_MODEL_REQUIRES_API_MODE_CONTINUE": "This Codex model requires an API key. Collaboration was not started, and this message is continuing as a single session. Configure it in Settings, then try again.",
"BUDGET_MODEL_REQUIRES_API_MODE_REMOTE": "The controlled device does not have the API key required for this Codex model. Configure it on that device, then retry.",
- "PRECONDITION_FAILED": "Collaboration is disabled for this project or the session is not eligible.",
- "PRECONDITION_FAILED_CONTINUE": "Collaboration is disabled for this project. Continuing as a single session.",
+ "PRECONDITION_FAILED": "Collaboration is disabled or the session is not eligible.",
+ "PRECONDITION_FAILED_CONTINUE": "Collaboration was not started. Continuing as a single session.",
"PRECONDITION_FAILED_REMOTE": "The controlled session is not eligible for collaboration."
}
},
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index 372107f674..8f04ecf29b 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -5106,13 +5106,13 @@
"startFailedContinue": "協同の開始に失敗しました。単一セッションとして続行します。",
"createWorkerRefreshFailed": "Worker の状態を更新できませんでした。もう一度お試しください。",
"openHint": "Worker を呼んで協同する",
- "disabledHint": "このプロジェクトでは協同モードが無効です。プロジェクト設定で有効にしてください。",
- "unavailableHint": "このプロジェクトの協同設定を確認できません。しばらくしてから再試行してください。",
+ "disabledHint": "協同モードは無効です。設定で有効にしてください。",
+ "unavailableHint": "協同設定を確認できません。しばらくしてから再試行してください。",
"unsupportedRemoteHint": "被操作デバイスのバージョンが古いため、協同を利用できません。",
"remoteContinueNotice": "このメッセージは単一セッションとして送信されます。",
"handoffRecoveredMessage": "前回は協同の開始が中断されました。送信されなかったメッセージを入力欄に復元しました。",
"handoffRecoveredGoal": "前回は協同の開始が中断されました。ゴールは開始されておらず、その内容を入力欄に復元しました。",
- "loadingHint": "このプロジェクトの協同設定を確認中です。しばらくしてから再試行してください。",
+ "loadingHint": "協同設定を確認中です。しばらくしてから再試行してください。",
"stopHint": "協同を停止",
"stopAria": "協同を停止",
"toggleOnAria": "協同モード中、クリックで停止",
@@ -5139,8 +5139,8 @@
"BUDGET_MODEL_REQUIRES_API_MODE": "この Codex モデルを使うには API key が必要です。設定で構成してから再試行してください。",
"BUDGET_MODEL_REQUIRES_API_MODE_CONTINUE": "この Codex モデルを使うには API key が必要です。協同は開始されず、このメッセージは単一セッションとして続行します。設定で構成してから再試行してください。",
"BUDGET_MODEL_REQUIRES_API_MODE_REMOTE": "被操作デバイスにこの Codex モデル用の API key が設定されていません。被操作デバイスで設定してから再試行してください。",
- "PRECONDITION_FAILED": "このプロジェクトでは協同モードが無効か、このセッションは協同に対応していません。",
- "PRECONDITION_FAILED_CONTINUE": "このプロジェクトでは協同モードが無効です。単一セッションとして続行します。",
+ "PRECONDITION_FAILED": "協同モードが無効か、このセッションは協同に対応していません。",
+ "PRECONDITION_FAILED_CONTINUE": "協同は開始されませんでした。単一セッションとして続行します。",
"PRECONDITION_FAILED_REMOTE": "制御中のセッションは協同に対応していません。"
}
},
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index 961dfe8236..626c038d6a 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -5106,13 +5106,13 @@
"startFailedContinue": "협업을 시작하지 못했습니다. 단일 세션으로 계속합니다.",
"createWorkerRefreshFailed": "Worker 상태를 새로 고칠 수 없습니다. 다시 시도해 주세요.",
"openHint": "Worker 를 불러 함께 작업",
- "disabledHint": "이 프로젝트에서는 협업 모드가 비활성화되어 있습니다. 프로젝트 설정에서 활성화하세요.",
- "unavailableHint": "이 프로젝트의 협업 설정을 확인할 수 없습니다. 잠시 후 다시 시도하세요.",
+ "disabledHint": "협업 모드가 비활성화되어 있습니다. 설정에서 활성화하세요.",
+ "unavailableHint": "협업 설정을 확인할 수 없습니다. 잠시 후 다시 시도하세요.",
"unsupportedRemoteHint": "제어 대상 기기의 버전이 오래되어 협업을 사용할 수 없습니다.",
"remoteContinueNotice": " 이 메시지는 단일 세션으로 계속 전송됩니다.",
"handoffRecoveredMessage": "지난번 협업 시작이 중단되었습니다. 전송되지 않은 메시지를 입력창에 복원했습니다.",
"handoffRecoveredGoal": "지난번 협업 시작이 중단되었습니다. 목표가 시작되지 않아 내용을 입력창에 복원했습니다.",
- "loadingHint": "이 프로젝트의 협업 설정을 확인하는 중입니다. 잠시 후 다시 시도하세요.",
+ "loadingHint": "협업 설정을 확인하는 중입니다. 잠시 후 다시 시도하세요.",
"stopHint": "협업 중지",
"stopAria": "협업 중지",
"toggleOnAria": "협업 켜짐 — 클릭하여 중지",
@@ -5139,8 +5139,8 @@
"BUDGET_MODEL_REQUIRES_API_MODE": "이 Codex 모델을 사용하려면 API key가 필요합니다. 설정에서 구성한 뒤 다시 시도하세요.",
"BUDGET_MODEL_REQUIRES_API_MODE_CONTINUE": "이 Codex 모델을 사용하려면 API key가 필요합니다. 협업은 시작되지 않았고 이 메시지는 단일 세션으로 계속됩니다. 설정에서 구성한 뒤 다시 시도하세요.",
"BUDGET_MODEL_REQUIRES_API_MODE_REMOTE": "제어 대상 기기에 이 Codex 모델에 필요한 API key가 설정되어 있지 않습니다. 제어 대상 기기에서 설정한 후 재시도하세요.",
- "PRECONDITION_FAILED": "이 프로젝트에서 협업 모드가 비활성화되어 있거나 현재 세션에서 협업을 지원하지 않습니다.",
- "PRECONDITION_FAILED_CONTINUE": "이 프로젝트에서는 협업 모드가 비활성화되어 있습니다. 단일 세션으로 계속합니다.",
+ "PRECONDITION_FAILED": "협업 모드가 비활성화되어 있거나 현재 세션에서 협업을 지원하지 않습니다.",
+ "PRECONDITION_FAILED_CONTINUE": "협업이 시작되지 않았습니다. 단일 세션으로 계속합니다.",
"PRECONDITION_FAILED_REMOTE": "제어 중인 세션에서는 협업을 지원하지 않습니다."
}
},
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index 1f8e96759f..3656a75d3d 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -5106,13 +5106,13 @@
"startFailedContinue": "开启协同失败,已改为单任务继续",
"createWorkerRefreshFailed": "Worker 状态刷新失败,请稍后重试",
"openHint": "召集 Worker 协作",
- "disabledHint": "当前项目已关闭协同模式,请在项目设置中重新启用",
- "unavailableHint": "暂时无法确认当前项目的协同设置,请稍后重试",
+ "disabledHint": "协同模式已关闭,请在设置中重新启用",
+ "unavailableHint": "暂时无法确认协同设置,请稍后重试",
"unsupportedRemoteHint": "被控设备的版本过旧,暂不支持协同",
"remoteContinueNotice": "本条消息仍会以单任务继续发送。",
"handoffRecoveredMessage": "上次开启协同时被中断,未发出的消息已恢复到输入框",
"handoffRecoveredGoal": "上次开启协同时被中断,目标未启动,内容已恢复到输入框",
- "loadingHint": "正在确认当前项目的协同设置,请稍后重试",
+ "loadingHint": "正在确认协同设置,请稍后重试",
"stopHint": "停止协同",
"stopAria": "停止协同",
"toggleOnAria": "协同模式已开启,点击停止",
@@ -5139,8 +5139,8 @@
"BUDGET_MODEL_REQUIRES_API_MODE": "此 Codex 模型需要先在设置中配置 API key 才能使用。请配置后重试。",
"BUDGET_MODEL_REQUIRES_API_MODE_CONTINUE": "此 Codex 模型需要先在设置中配置 API key;协同未开启,已改为单任务继续。请配置 API key 后重试。",
"BUDGET_MODEL_REQUIRES_API_MODE_REMOTE": "被控设备尚未配置此 Codex 模型所需的 API key。请在被控设备上配置后重试。",
- "PRECONDITION_FAILED": "当前项目已关闭协同模式,或当前任务不支持协同。",
- "PRECONDITION_FAILED_CONTINUE": "当前项目已关闭协同模式,已改为单任务继续。",
+ "PRECONDITION_FAILED": "协同模式已关闭,或当前任务暂不支持协同。",
+ "PRECONDITION_FAILED_CONTINUE": "协同模式未开启,已改为单任务继续。",
"PRECONDITION_FAILED_REMOTE": "被控任务不支持协同。"
}
},
diff --git a/apps/desktop/src/renderer/lib/makerTransport.ts b/apps/desktop/src/renderer/lib/makerTransport.ts
index aa51964d24..dcc735b910 100644
--- a/apps/desktop/src/renderer/lib/makerTransport.ts
+++ b/apps/desktop/src/renderer/lib/makerTransport.ts
@@ -371,9 +371,18 @@ export function pluginEnableStateFor(
deviceId: string | null | undefined,
pluginId: string,
workingDir?: string,
+ workspaceKind?: string | null,
): ReturnType<typeof window.electronAPI.maker.plugins.getState> {
- if (!deviceId) return window.electronAPI.maker.plugins.getState(pluginId, workingDir);
- return invokeRemote(deviceId, 'maker:plugins:get-state', [pluginId, workingDir]) as ReturnType<
+ if (!deviceId) {
+ return workspaceKind === undefined
+ ? window.electronAPI.maker.plugins.getState(pluginId, workingDir)
+ : window.electronAPI.maker.plugins.getState(pluginId, workingDir, workspaceKind);
+ }
+ const args =
+ workspaceKind === undefined
+ ? [pluginId, workingDir]
+ : [pluginId, workingDir, workspaceKind];
+ return invokeRemote(deviceId, 'maker:plugins:get-state', args) as ReturnType<
typeof window.electronAPI.maker.plugins.getState
>;
}
diff --git a/apps/desktop/src/renderer/state/newMakerDraft.ts b/apps/desktop/src/renderer/state/newMakerDraft.ts
index 18b0d55e75..24e04ca0ae 100644
--- a/apps/desktop/src/renderer/state/newMakerDraft.ts
+++ b/apps/desktop/src/renderer/state/newMakerDraft.ts
@@ -59,9 +59,8 @@ export interface VendorPrefs {
* 现在并入 draft store: 协同 + workdir 都从 newMakerDraft 这一个 store 读写,
* 行为统一,重启也能恢复上次选择。
*
- * 互斥约束(由 NewMakerDraftRoute 强制,不在 store 层校验):
- * - workingDir == null 时 collab 入口被隐藏,enabled 应保持 false
- * - collab.enabled = true 时 picker 隐藏"对话"入口,workingDir 不会变 null
+ * 协同与工作区形态正交:项目和对话草稿都能开启;只有真正开始一次新草稿时才把
+ * enabled 复位为 false,避免把上一次发送的协同选择静默带到下一次。
*/
/**
* 「开启协同」弹窗(CreateWorkerPopover)收集的 Worker 详细配置。
@@ -282,8 +281,6 @@ function sanitize(raw: unknown): NewMakerDraft {
// NewMakerDraftRoute mount 时也会清空(同一决定的双保险)。
const extraDirs: string[] = [];
// collab 校验: 老版本无此字段 → 默认 OFF + codex worker。
- // 防御性互斥: workingDir==null 时 enabled 应该为 false (隐藏入口的兜底,
- // 防止历史脏数据让用户看到协同 ON 但 workdir 为空的不可达状态)。
const collabRaw = (r as { collab?: Partial<CollabDraft> }).collab;
const collabWorker: CollabDraft['worker'] =
collabRaw?.worker === 'cc' ? 'cc' : collabRaw?.worker === 'pi' ? 'pi' : 'codex';
@@ -291,8 +288,7 @@ function sanitize(raw: unknown): NewMakerDraft {
// (在同一台远端主机 spawn,见 OrcaLeadSessionSnapshot.remoteHostId),两端
// 远端 MCP 注入均已落地 (codex daemon config + cc per-query http 注入)。
// 本地项目(remoteHostId==null)不受影响。
- const collabEnabled =
- collabRaw?.enabled === true && workingDir != null;
+ const collabEnabled = collabRaw?.enabled === true;
// workerConfig 防御性解析:model 缺失/为空则整块丢弃(不存半截配置),createSession 回退默认。
const workerConfig: CollabWorkerConfig | undefined = (() => {
const wc = collabRaw?.workerConfig;
@@ -636,13 +632,6 @@ export function patchDraft(patch: Partial<NewMakerDraft>): void {
: null;
}
const next: NewMakerDraft = { ...currentDraft, ...normalizedPatch };
- // 互斥兜底: 任何把 workingDir 改成 null 的路径,都把 collab 关掉。
- // UI 已经在 collab.enabled 时隐藏"对话"入口,正常路径走不到这里;
- // 这条只是防御性,避免外部调用者(将来的代码 / 测试)把 workingDir 清成 null
- // 后留下 collab.enabled=true 的不可达状态。
- if ('workingDir' in patch && next.workingDir == null && next.collab.enabled) {
- next.collab = { ...next.collab, enabled: false };
- }
if ('workingDir' in patch && next.workingDir == null) {
next.remoteHostId = null;
} else if ('workingDir' in patch && !('remoteHostId' in patch)) {
@@ -675,10 +664,8 @@ export function patchDraft(patch: Partial<NewMakerDraft>): void {
if (currentDraft.deviceLinkDeviceId !== next.deviceLinkDeviceId && next.collab.workerConfig) {
next.collab = { ...next.collab, workerConfig: undefined };
}
- // device-link 与 SSH remote 项目 draft 的协同都已接通(device-link 的 enableOrca /
- // worker 创建 / 团队读写经隧道在被控端执行;SSH 的 worker 创建继承 remoteHostId、
- // 远端 MCP 注入两端落地),不再按目标或 vendor 强制关闭。仍然关闭的只有「对话模式」
- // (workingDir == null,见上方级联)与 Orca Worker 子会话(会话侧判定)。
+ // 协同与项目/对话形态正交,切 workingDir 不再改 enabled。device-link 与 SSH 的 Worker
+ // 创建和团队读写都在对应执行端完成;Worker 子会话不能嵌套协同,由会话侧入口判定兜住。
currentDraft = next;
scheduleWrite({
preserveStoredWorktreePreference:
@@ -691,9 +678,9 @@ export function patchDraft(patch: Partial<NewMakerDraft>): void {
/**
* 把草稿的「这次要跑在哪」复位成干净的本机对话态。
*
- * 只需这两个字段:workingDir=null 经上面的兜底级联同时清掉 remoteHostId /
- * deviceLink* / collab.enabled。vendor / lastByVendor / fastModeByModel 等模型偏好
- * 保持不变(那是「我常用哪个」的记忆,与「这次跑在哪」正交)。
+ * workingDir=null 经 patchDraft 级联清掉 remoteHostId / deviceLink*;extraDirs 与
+ * collab.enabled 是本次草稿的一次性选择,这里显式清掉。vendor / lastByVendor /
+ * fastModeByModel 等模型偏好保持不变(那是「我常用哪个」的记忆,与「这次跑在哪」正交)。
*
* **任何「另起一段干净对话」的入口都必须走这里,不要各自手写字段清单。**
* extraDirs 是单次草稿的**目录读取授权**,漏掉它会让新会话悄悄继承对无关本地目录的
@@ -701,7 +688,11 @@ export function patchDraft(patch: Partial<NewMakerDraft>): void {
* 抄了一遍,却都漏了真正需要清的这一个)。新增工作区字段时只改这一处。
*/
export function resetDraftWorkspaceTargets(): void {
- patchDraft({ workingDir: null, extraDirs: [] });
+ patchDraft({
+ workingDir: null,
+ extraDirs: [],
+ collab: { ...currentDraft.collab, enabled: false },
+ });
}
/** 单字段写入 collab(便捷 setter,语义比 patchDraft({ collab: ... }) 更直接)。 */
diff --git a/apps/desktop/src/renderer/themes/builtin/solarized-light.ts b/apps/desktop/src/renderer/themes/builtin/solarized-light.ts
index e8d243e6e0..3d95e9899a 100644
--- a/apps/desktop/src/renderer/themes/builtin/solarized-light.ts
+++ b/apps/desktop/src/renderer/themes/builtin/solarized-light.ts
@@ -103,7 +103,7 @@ const singletonOverrides = {
// base3、圆底由模板规则落回 base2(CHIP),两态均可分(codex P1 3671457570)。
'create-agent-quick-card-icon-bg': SURFACE_BG,
// send 不用 accent(green) 底:共享 send token 还渲染 10-12px 文本
- // (VoiceInputOverlay / CollaborationModeToggle / SessionHandoffCard),白字仅
+ // (VoiceInputOverlay / SessionHandoffCard),白字仅
// 3.20:1,不达 DESIGN.md §10 小字 4.5:1;回退 registry 反相中性(codex P1
// 3671457561),故本主题不覆盖 send-btn-*。
'create-agent-quick-card-text': TEXT_PRIMARY,
diff --git a/apps/desktop/src/renderer/vite-env.d.ts b/apps/desktop/src/renderer/vite-env.d.ts
index 4be24b55a0..6f66fec03a 100644
--- a/apps/desktop/src/renderer/vite-env.d.ts
+++ b/apps/desktop/src/renderer/vite-env.d.ts
@@ -873,6 +873,7 @@ interface PluginEnableState {
projectOverride?: { enabled: boolean; workingDir: string } | null;
userOverride?: { enabled: boolean } | null;
globalOverride?: { enabled: boolean } | null;
+ collabWorkspaceKind?: 'project' | 'dialogue';
}
interface PluginEnableUpdateResult {
@@ -5047,7 +5048,11 @@ interface ElectronAPI {
plugins: {
list: (workingDir?: string) => Promise<PluginListItem[]>;
- getState: (id: string, workingDir?: string) => Promise<PluginEnableState>;
+ getState: (
+ id: string,
+ workingDir?: string,
+ workspaceKind?: string | null,
+ ) => Promise<PluginEnableState>;
setEnabled: (id: string, enabled: boolean) => Promise<PluginEnableUpdateResult>;
clearEnabled: (id: string) => Promise<PluginEnableUpdateResult>;
setProjectEnabled: (workingDir: string, id: string, enabled: boolean) => Promise<void>;
diff --git a/apps/desktop/src/shared/theme-import/palette.ts b/apps/desktop/src/shared/theme-import/palette.ts
index 4268362401..a4d233dbe5 100644
--- a/apps/desktop/src/shared/theme-import/palette.ts
+++ b/apps/desktop/src/shared/theme-import/palette.ts
@@ -359,7 +359,7 @@ export function buildThemeColorsFromPalette(
'search-match-fg': textPrimaryHsl,
secondary: pick(elevatedHsl, chipHsl),
// send 底用反相中性而非 accent:共享 send token 还渲染 10-12px 文本
- // (VoiceInputOverlay / CollaborationModeToggle / SessionHandoffCard),accent 底
+ // (VoiceInputOverlay / SessionHandoffCard),accent 底
// 配白/黑字难稳定过 4.5:1 小字线,反相中性双模式均满足。
'send-btn-bg': pick(textPrimary, surface),
'send-btn-icon': pick(surface, textPrimary),
diff --git a/apps/mobile/docs/desktop-interaction-audit.md b/apps/mobile/docs/desktop-interaction-audit.md
index bfdb081375..1e027ac181 100644
--- a/apps/mobile/docs/desktop-interaction-audit.md
+++ b/apps/mobile/docs/desktop-interaction-audit.md
@@ -24,7 +24,7 @@
| Pending interactions | `PermissionPrompt.tsx`, `AskUserQuestionPrompt.tsx`, `PlanViewerCard.tsx`, `PlanActionCard.tsx`;`IssueConfirmCard.tsx` 仅作为桌面 `/issue` 反馈链路参考 |
| 自动化 / 计划 | `features/scheduler/SchedulerPage.tsx`, `TaskListPane.tsx`, `RunHistoryPane.tsx`, `ScheduleFormDialog.tsx`, `TemplateGallery.tsx` |
| 文件页 / 选项卡 | `features/cc-agent/workdir-browse/WorkdirBrowseRoute.tsx`, `FileBodyView.tsx`, `SessionTabsBar.tsx`, `FileTabsBar.tsx` |
-| 协作模式 / Orca | `CollaborationModeToggle.tsx`, `OrcaWorkflowRoute.tsx`, `OrcaSplitView.tsx`, `CreateWorkerPopover.tsx`, `WorkerListToolbar.tsx` |
+| 协作模式 / Orca | `ExtraDirsButton.tsx`(「+」菜单协同项), `OrcaWorkflowRoute.tsx`, `OrcaSplitView.tsx`, `CreateWorkerPopover.tsx`, `WorkerListToolbar.tsx` |
## 2. 产品边界
@@ -726,7 +726,7 @@ V1B 不做完整编辑器,但需要支持:
协作模式不是一个简单开关。桌面 Orca 由这些部分组成:
-- `CollaborationModeToggle`: 在输入器里开启协作模式偏好。
+- `ExtraDirsButton` 的协同模式项:在输入器「+」菜单里开启协作模式偏好。
- `OrcaWorkflowRoute`: lead session 的协作路由。
- `OrcaSplitView`: Lead + Worker 双 pane。
- `WorkerListToolbar`: worker 列表、focus、active count。
diff --git a/apps/mobile/docs/mobile-desktop-source-inventory.md b/apps/mobile/docs/mobile-desktop-source-inventory.md
index 5b70781715..6b77799974 100644
--- a/apps/mobile/docs/mobile-desktop-source-inventory.md
+++ b/apps/mobile/docs/mobile-desktop-source-inventory.md
@@ -37,7 +37,7 @@ V1 的判断标准:
| Pending interactions | `PermissionPrompt.tsx`, `AskUserQuestionPrompt.tsx`, `PlanViewerCard.tsx`, `PlanActionCard.tsx`;`IssueConfirmCard.tsx` 仅作桌面反馈链路参考 | 定义权限、提问、计划确认的决策 shape;Issue 确认在 mobile V1 只做 desktop-only 降级识别。 |
| 自动化计划 | `SchedulerPage.tsx`, `TaskListPane.tsx`, `RunHistoryPane.tsx`, `ScheduleFormDialog.tsx`, `TemplateGallery.tsx` | 定义 schedules 列表、运行历史、运行/暂停/恢复/删除、创建/编辑。 |
| 文件和选项卡 | `WorkdirBrowseRoute.tsx`, `FileBodyView.tsx`, `WorkdirBrowseSidebar.tsx`, `FileTabsBar.tsx`, `SessionTabsBar.tsx` | 定义文件树、文件预览、文件 tab、同目录 session tab、chat rail。 |
-| 协作 / Orca | `CollaborationModeToggle.tsx`, `OrcaWorkflowRoute.tsx`, `OrcaSplitView.tsx`, `CreateWorkerPopover.tsx`, `useWorkers.ts` | 定义 lead + worker + focus + split/toggle 的真实协作模型。 |
+| 协作 / Orca | `ExtraDirsButton.tsx`(「+」菜单协同项), `OrcaWorkflowRoute.tsx`, `OrcaSplitView.tsx`, `CreateWorkerPopover.tsx`, `useWorkers.ts` | 定义 lead + worker + focus + split/toggle 的真实协作模型。 |
## 3. V1/V1B/V2 分层
@@ -573,7 +573,7 @@ V1B:
桌面源码说明协作不是一个开关:
-- `CollaborationModeToggle` 只是 controlled pill。
+- `ExtraDirsButton` 中的协同模式项只是 controlled 入口。
- `OrcaSplitView` 承载 lead + worker 双会话。
- workerRatio 持久化。
- split/toggle layout。
diff --git a/apps/mobile/docs/mobile-v1-source-plan.md b/apps/mobile/docs/mobile-v1-source-plan.md
index 72c5abc1cc..4f83013610 100644
--- a/apps/mobile/docs/mobile-v1-source-plan.md
+++ b/apps/mobile/docs/mobile-v1-source-plan.md
@@ -480,7 +480,7 @@ P2 继续后移:
| Pending interactions | `PermissionPrompt.tsx`, `AskUserQuestionPrompt.tsx`, `PlanViewerCard.tsx`, `PlanActionCard.tsx`;`IssueConfirmCard.tsx` 仅作为桌面反馈链路参考 | 定义权限、提问、计划评审的决策 shape 和 UI 优先级;Issue 确认在 mobile V1 只做 unsupported 兜底。 |
| 自动化计划 | `SchedulerPage.tsx`, `TaskListPane.tsx`, `RunHistoryPane.tsx`, `ScheduleFormDialog.tsx`, `RunHistoryCard.tsx`, `schedulesStore.ts` | 定义自动化任务列表、运行历史、运行/暂停/恢复/删除、模板、fresh/persistent/bound。 |
| 文件页和选项卡 | `workdir-browse/WorkdirBrowseRoute.tsx`, `FileBodyView.tsx`, `WorkdirBrowseSidebar.tsx`, `FileTreeView.tsx`, `FileTabsBar.tsx`, `SessionTabsBar.tsx` | 定义文件树、文件内容、打开文件 tabs、session tabs、chat rail、search、dirty/edit。 |
-| 协作 / Orca | `CollaborationModeToggle.tsx`, `OrcaWorkflowRoute.tsx`, `OrcaSplitView.tsx`, `CreateWorkerPopover.tsx`, `useWorkers.ts`, `useStopOrcaCollab.ts` | 定义协作不是单开关,而是 lead + worker + focus + split/toggle 的多会话系统。 |
+| 协作 / Orca | `ExtraDirsButton.tsx`(「+」菜单协同项), `OrcaWorkflowRoute.tsx`, `OrcaSplitView.tsx`, `CreateWorkerPopover.tsx`, `useWorkers.ts`, `useStopOrcaCollab.ts` | 定义协作不是单开关,而是 lead + worker + focus + split/toggle 的多会话系统。 |
## 3. V1 总体信息架构
@@ -1176,7 +1176,7 @@ V2 再做:
协作模式由多个模块组成:
-- `CollaborationModeToggle`: 输入器中的入口和关闭入口。
+- `ExtraDirsButton` 的协同模式项:输入器「+」菜单中的入口和关闭入口。
- `CreateWorkerPopover`: 创建 worker,角色、agent、model、effort、fast、initial task。
- `OrcaWorkflowRoute`: `/cc-agent/orca/:sessionId` 路由薄壳。
- `OrcaSplitView`: lead + worker split/toggle。
diff --git a/apps/mobile/docs/remote-control-plan.md b/apps/mobile/docs/remote-control-plan.md
index 92a2a05b57..cc1a532a48 100644
--- a/apps/mobile/docs/remote-control-plan.md
+++ b/apps/mobile/docs/remote-control-plan.md
@@ -243,7 +243,7 @@
- `apps/desktop/src/renderer/features/scheduler/components/TaskListPane.tsx`
- `apps/desktop/src/renderer/features/scheduler/components/ScheduleFormDialog.tsx`
- 协作模式:
- - `apps/desktop/src/renderer/components/new-chat/CollaborationModeToggle.tsx`
+ - `apps/desktop/src/renderer/components/new-chat/ExtraDirsButton.tsx`
- `apps/desktop/src/renderer/features/cc-agent/OrcaSplitView.tsx`
- `apps/desktop/src/renderer/features/cc-agent/OrcaWorkflowRoute.tsx`
- `apps/desktop/src/renderer/features/cc-agent/CreateWorkerPopover.tsx`
@@ -281,7 +281,7 @@
| Fork / Rewind | `MessageActionBar` + `useForkAtMessage` + `RewindPreviewDialog`;首条 user 不显示 rewind;commit 后用被控端快照替换。 | 消息动作行;fork 成功 upsert 并跳转;rewind preview 显示风险,commit 后替换消息并回填 composer draft。`rewindPreviewLayout.ts` 按屏宽控制 preview 面板 padding、可见文件行数和 40px action 触控高度,`RewindActionButton` 统一取消/确认/关闭反馈。 | fork/rewind 单测和 smoke;`rewindPreviewLayout.test` 覆盖 320/393/未就绪宽度。 |
| 自动化 | `SchedulerPage` 是 master-detail;`TaskListPane` 按 workingDir/dialogue 分组;active 包含 expired;`RunHistoryPane` 折叠同 session runs;`ScheduleFormDialog` 包含模板、fresh/persistent/bound、project automation。 | V1B 已做任务列表/详情/runs/run now/pause/resume/delete/mark read/open session、新建/编辑普通 schedule、模板创建、生成会话删除三选项;fresh/persistent/bound 运行会话编辑第一刀已对齐桌面状态机;project automation 完整编辑后续继续对齐桌面。 | scheduleModel/remote event/form 单测;Maestro run now/pause/open session/create-edit flow。 |
| 远程设置 | `ControlThisMacPanel` / `ControllableDevicesPanel` / `RemoteControlSection` 管本机允许被控、可控设备、撤销/重命名。 | 手机 Settings 显示登录、当前手机设备名、relay 状态、调试和退出;被控端允许开关仍在电脑端。 | `settings.yaml` + settings model 单测。 |
-| 协作 / Orca | `CollaborationModeToggle`、`OrcaSplitView`、`CreateWorkerPopover` 支持 lead/worker split/toggle、worker focus、attention、create/archive/stop;远程 Orca 合并 local + remote sessions。 | V1 只识别 lead/worker 和 worker 通信,只读安全显示,不提供创建/切 focus/停止协作;V2 做手机专属 lead/worker toggle pane。 | V1 Orca fixture 不崩;V2 另建 E2E。 |
+| 协作 / Orca | `ExtraDirsButton` 的协同模式项、`OrcaSplitView`、`CreateWorkerPopover` 支持 lead/worker split/toggle、worker focus、attention、create/archive/stop;远程 Orca 合并 local + remote sessions。 | V1 只识别 lead/worker 和 worker 通信,只读安全显示,不提供创建/切 focus/停止协作;V2 做手机专属 lead/worker toggle pane。 | V1 Orca fixture 不崩;V2 另建 E2E。 |
Worktree 补充:
@@ -933,7 +933,7 @@ V1A 可以先只有 `Devices/Sessions/Settings`,但路由结构要给 `Automatio
桌面协作能力:
-- `CollaborationModeToggle`: off/on,选择 Worker agent。
+- `ExtraDirsButton` 的协同模式项:off/on,并打开 Worker 配置。
- Lead session + Worker session。
- `OrcaSplitView`: split 或 toggle layout。
- Worker toolbar:
diff --git a/docs/design-rules/DESIGN.md b/docs/design-rules/DESIGN.md
index 5f5fd14091..f13fee504e 100644
--- a/docs/design-rules/DESIGN.md
+++ b/docs/design-rules/DESIGN.md
@@ -73,7 +73,7 @@ Small interactive chips (button backgrounds, tag pills, avatar fills, selected-n
The grayscale rule is near-absolute. The following are the **only** sanctioned non-gray colors in the system — each tightly scoped to a specific surface. New semantic colors must not be introduced without being recorded here first.
- **Focus Blue** (`#417CDD` at 50%; tokens `--focus-ring` / `--focus-ring-soft`): the keyboard-accessibility focus ring, finalized 2026-07-17 (replaces Tailwind's default `#3b82f6`). Never visible in normal interaction flow.
-- **Thinking / Warning Orange** (`#EA6B17`, finalized 2026-07-17, replaces the frozen `#FF6600`): the shared warning-accent family, identical in both modes. Sanctioned consumers only — the ChatView Running Status Bar (sparkles icon + status text, e.g. `Spelunking...`, no background fill), running-state breathing icons in the sidebar, the collaboration toggle ON state, the plan-approve icon, the Full Access permission highlight, the settings integration warning, and the workflow agent status strip's running cells (8×8px filled squares in the background-tasks panel detail and the workflow chat card, registered 2026-07-28 — running-state semantics, same family as the sidebar breathing icons; the done/failed/queued cells stay on their own semantic tokens: `--card-status-done` / `--error-fg` / `--surface-chip`) (see the §10 exemption table and §15 for the full token list: `--warning-accent` and its follower tokens). A consumer that introduces no new token — one that reads `--warning-accent` or an existing follower directly, like this strip — is registered by this list alone; a consumer needing a NEW token must be registered in the §10 exemption table first.
+- **Thinking / Warning Orange** (`#EA6B17`, finalized 2026-07-17, replaces the frozen `#FF6600`): the shared warning-accent family, identical in both modes. Sanctioned consumers only — the ChatView Running Status Bar (sparkles icon + status text, e.g. `Spelunking...`, no background fill), running-state breathing icons in the sidebar, the collaboration-mode menu row's ON state, the plan-approve icon, the Full Access permission highlight, the settings integration warning, and the workflow agent status strip's running cells (8×8px filled squares in the background-tasks panel detail and the workflow chat card, registered 2026-07-28 — running-state semantics, same family as the sidebar breathing icons; the done/failed/queued cells stay on their own semantic tokens: `--card-status-done` / `--error-fg` / `--surface-chip`) (see the §10 exemption table and §15 for the full token list: `--warning-accent` and its follower tokens). A consumer that introduces no new token — one that reads `--warning-accent` or an existing follower directly, like this strip — is registered by this list alone; a consumer needing a NEW token must be registered in the §10 exemption table first.
> **Additional narrowly-scoped exceptions** (documented in their respective component specs, do NOT generalize as system semantic colors):
>
@@ -1106,7 +1106,7 @@ The execution rulebook for subsequent desktop / mobile UI updates. Sources: the
### 15.14 Running / Collaboration Orange (finalized 2026-07-20)
- **Running breathing icons are always Thinking Orange** (`--warning-accent` `#EA6B17`, all themes): VendorIcon, SessionStatusIcon (Puzzle/RadioTower), AutomationSessionGroupItem (Clock); the selected state stays orange — priority: running > selected inverse foreground > rest. Mobile `statusAccent` mirrors value and priority (glyphColor same).
-- **Collaboration toggle ON state is orange**: CollaborationModeToggle's active text + Puzzle icon use `warning-accent` (an explicit carve-out from the 2026-07-17 "composer pills go neutral" rule — ON state only; the OFF entry state stays neutral).
+- **Collaboration menu row ON state is orange**: the collaboration item inside the composer「+」menu sits beside Goal and Plan. Its active text + UsersRound icon use `warning-accent`; the row background remains the standard `--model-item-hover`, and the OFF state stays neutral. This is an explicit carve-out from the 2026-07-17 neutral composer-menu rule for the ON state only.
- **SVG persistent-animation red line**: breathing-type persistent animation sits on an HTML wrapper (span); SVG stays static.
### 15.15 Create-Page Content Position + Titlebar Hover Discipline (finalized 2026-07-21)
diff --git a/docs/dev-rules/orca-team-architecture.md b/docs/dev-rules/orca-team-architecture.md
index 9ccfa5784b..912f9ac92e 100644
--- a/docs/dev-rules/orca-team-architecture.md
+++ b/docs/dev-rules/orca-team-architecture.md
@@ -38,7 +38,7 @@ Orca 是 Cindy Desktop 内的多 agent 协同能力:一个 **Lead session**
- 多 worker:同一个 active team 下可创建多个 worker,支持 role、label、focused worker 切换、soft/hard limit 与归档。
- Split view:Lead 与 focused Worker 共用 `OrcaSplitView` pane 外壳,宽屏为左右 split,doc rail 为 Lead/Worker toggle。见 `apps/desktop/src/renderer/features/cc-agent/OrcaSplitView.tsx` 的 `OrcaSplitView`、`OrcaPaneShell`。
-- Claude Code 与 Codex 都可作为本地项目 Lead;SSH 远端会话两端均可作 Lead(远端 agent 经 SSH remote-forward 直连本机 HTTP MCP bridge,`cindy_orca` 在两端都可用:codex 走 daemon config 注入,cc 走 per-query http 注入);device-link 被控端项目同样可作 Lead(Lead / Worker / team 的真身都在被控端,控制端只是镜像)。renderer 的入口判定收敛在 `apps/desktop/src/renderer/features/cc-agent/collabEntryPolicy.ts` 的 `resolveCollabEntryPolicy`,新建草稿(`NewMakerDraftRoute`)与会话视图(`CCAgentSessionView` 的 `allowCollabToggle`)共用同一份:排除 Orca Worker 子会话与对话模式(无项目目录),本地 / SSH / device-link 三类项目都显示入口。
+- Claude Code 与 Codex 的普通 Lead 无论是项目还是对话都可开启协同;SSH 远端会话两端均可作 Lead(远端 agent 经 SSH remote-forward 直连本机 HTTP MCP bridge,`cindy_orca` 在两端都可用:codex 走 daemon config 注入,cc 走 per-query http 注入);device-link 被控端的项目与对话同样可作 Lead(Lead / Worker / team 的真身都在被控端,控制端只是镜像)。renderer 的入口判定收敛在 `apps/desktop/src/renderer/features/cc-agent/collabEntryPolicy.ts` 的 `resolveCollabEntryPolicy`,新建草稿(`NewMakerDraftRoute`)与会话视图(`CCAgentSessionView` 的 `allowCollabToggle`)共用同一份:普通 Lead 都显示入口,只排除不能嵌套协同的 Orca Worker 子会话。项目按项目级策略查询;Main 的 `resolveLocalCollabPolicyWorkingDir` 同时服务入口状态查询与最终授权,只有 workspace kind 为 dialogue 且 Main 确认目录位于 app 托管 dialogue root 时才只查用户级/全局级策略(即使 cwd 内出现 `.cindy/plugins.json`),显式绑定真实目录的对话仍按该目录的项目级策略查询,不能靠自报 `workspaceKind` 绕过项目禁用。
- Codex Lead 使用全局注册的 `cindy_orca`,调用时通过 context 恢复身份并在 handler 内拒绝越权。远端 Codex 同样走 `params._meta.threadId` 路由——remote thread 与本地 thread 一样注册进 `CodexMcpThreadContextStore`(`packages/maker-core/src/agents/codex/index.ts` 的 `registerCodexMcpContext` 不再跳过 remoteHostId)。远端 cc 没有 threadId,身份走持久 bearer token + URL `?session=<id>` 路由(`codexHttpBridge.registerSessionCtx`),审批归属快照在 `remoteCcQueryFactory` 注入后按 `startParams.mcpServers` 最终清单定稿。
- SSH 远端 Codex 的 MCP 桥接:本机 `codexHttpBridge` 在原有 per-run 主 token 之外接受一个 persistent bearer token(safeStorage);`remote-ssh/codex-remote-mcp.ts` 在 session start/resume 前置完成 per-host 固定端口 remote-forward(`RemoteHost.openRemoteForward`,重连自动 rebind)、远端 `$CODEX_HOME/config.toml` 的 `mcp_servers` 管理段漂移检测(行级 marker + 剥离用户同名 table)与 daemon 幂等 bootstrap(token 只经 stdin 的 KEY=value 块注入,不进 argv);config 漂移需要重启 daemon 时若同 host 有 live turn 则本次降级(留待下次 ensure)。worker 创建经 `OrcaLeadSessionSnapshot.remoteHostId` 继承在同一台远端主机 spawn,创建前走 `ensureRemoteReadyForSessionStart`(SSH 重连 / agent 安装 / MCP 注入);lazy resume 与 Orca worker 唤醒路径同样先 ensure 再 bootstrap。
- PR #107 提供 side_chat 的底层 fork 数据动作:user/assistant 消息都能 fork,assistant 按 turn 粒度复制,Claude 用 uuid 锚点,Codex 用 ThreadFork + ThreadRollback。当前作为普通 session 跳转;未来要登记为 side activity 并挂入统一 pane。
@@ -50,8 +50,8 @@ Orca 是 Cindy Desktop 内的多 agent 协同能力:一个 **Lead session**
- Worker archive 后 UI 内没有 unarchive 入口;DB 记录保留,用户需要新建 worker 继续。
- workflow_run / CC Workflow 编排还未纳入当前实现。
- side_chat 尚未登记为 side activity 对象,也未挂进 pane;PR #107 只是 fork 数据动作。
-- device-link 协同的 Lead / Worker / team 全部在被控端进程内编排,控制端只按 session 来源经隧道路由(`makerTransport` 的 `makerApiFor` / `orcaWorkflowsFor` / `subscribeOrcaWorkerChanged`,channel 见 `packages/device-link/src/allowlist.ts` 的 Orca 段)。项目级 collab 开关同样查被控端(`maker:plugins:get-state` 经 `pluginEnableStateFor`)——控制端拿被控端的路径查自己本机只会读到自己的用户级开关,判定可能与被控端 main 的 `assertCollabProjectEnabled` 相反。老被控端没有该 channel 时回 `CHANNEL_NOT_ALLOWED`,控制端 fail-closed 置灰入口并提示设备版本过旧,而不是放行到 `enableOrca` 才撞错。
-- SSH 远端协同支持 codex 与 claude-code 两类 lead + 远端 worker(继承 remoteHostId)。cc 远端经 `cc-remote-mcp.ts` 把 `cindy_orca` / `orca_worker_bridge` 以 http 形态追加进 `startParams.mcpServers`(persistent token + `?session=` 路由,白名单仅此两个 server)。远端 worker 手动 `send_to_lead` 依赖 daemon 侧 `orca_worker_bridge` 经同一 bridge 可达;auto-bridge 回报不依赖 worker 侧 MCP,天然可用。共享 userData 多实例连同一远端 host 时,只有先建立 SSH 转发的实例能持有该 host 的 MCP bridge 端口,其余实例按“远端无 MCP”降级(与历史行为一致)。远端会话的项目级 collab 开关不查本机 fs(`assertCollabProjectEnabled` 对 remote 跳过 `isPluginEnabled`;远端项目级配置机制是 follow-up)。
+- device-link 协同的 Lead / Worker / team 全部在被控端进程内编排,控制端只按 session 来源经隧道路由(`makerTransport` 的 `makerApiFor` / `orcaWorkflowsFor` / `subscribeOrcaWorkerChanged`,channel 见 `packages/device-link/src/allowlist.ts` 的 Orca 段)。collab 开关同样查被控端(`maker:plugins:get-state` 经 `pluginEnableStateFor`):项目读取被控端项目级策略,对话读取被控端用户级/全局级策略。控制端本机状态不能代表被控端真相。老被控端没有该 channel 时回 `CHANNEL_NOT_ALLOWED`,控制端 fail-closed 置灰入口并提示设备版本过旧,而不是放行到 `enableOrca` 才撞错。
+- SSH 远端协同支持 codex 与 claude-code 两类 lead + 远端 worker(继承 remoteHostId)。cc 远端经 `cc-remote-mcp.ts` 把 `cindy_orca` / `orca_worker_bridge` 以 http 形态追加进 `startParams.mcpServers`(persistent token + `?session=` 路由,白名单仅此两个 server)。远端 worker 手动 `send_to_lead` 依赖 daemon 侧 `orca_worker_bridge` 经同一 bridge 可达;auto-bridge 回报不依赖 worker 侧 MCP,天然可用。共享 userData 多实例连同一远端 host 时,只有先建立 SSH 转发的实例能持有该 host 的 MCP bridge 端口,其余实例按“远端无 MCP”降级(与历史行为一致)。远端会话的项目级 collab 开关不查本机 fs;`assertCollabProjectEnabled` 对 remote 只查用户级/全局级开关,远端项目级配置机制是 follow-up。
### 核心概念与数据模型
diff --git a/docs/dev-rules/pi-harness.md b/docs/dev-rules/pi-harness.md
index 1df458f43d..753d1f908a 100644
--- a/docs/dev-rules/pi-harness.md
+++ b/docs/dev-rules/pi-harness.md
@@ -119,7 +119,7 @@ Cindy 显式设置:models.json、`--append-system-prompt`、`--session-dir`、
注:pi 斜杠转义后用户无法手输 `/compact`,此菜单是 pi 会话手动压缩的唯一入口。
- ✅ **subagent 接 pi 轻量引擎**(已交付):Orca worker 可选 `pi` 引擎。核心链路(MCP
schema / worker 创建服务 / 默认模型 claude-sonnet-4-6 / PiAgent 注册)本已按 AgentKind
- 接通;本次补齐 UI(CreateWorkerPopover / CollaborationModeToggle / draft 映射)、两个
+ 接通;本次补齐 UI(CreateWorkerPopover / composer「+」菜单协同项 / draft 映射)、两个
main IPC coercion(WORKER_CREATE / SESSION_ENABLE_ORCA)、worker 展示(π 而非 Claude 脸)。
注:pi 二进制缺失时 buildPiAgent 返回 null,pi 不进 agents map,建 pi worker 会抛错。
- ✅ **压缩即记忆**(已交付):新增 `digest` 记忆类型(与 curated 解耦)。pi `compaction_end`
diff --git a/packages/lizi-mcps/src/xdt-helper/capabilities.ts b/packages/lizi-mcps/src/xdt-helper/capabilities.ts
index 409c875923..576e4fc4cb 100644
--- a/packages/lizi-mcps/src/xdt-helper/capabilities.ts
+++ b/packages/lizi-mcps/src/xdt-helper/capabilities.ts
@@ -70,7 +70,7 @@ export const CAPABILITIES: readonly CapabilityEntry[] = [
'【硬边界】Worker session 不能再开 team(嵌套禁止, 返 WORKER_CANNOT_NEST);Claude Code / Codex 本地项目 session 都可以作为 Lead 调 start_team;Worker 不能结束自己所在 team(返 WORKER_CANNOT_DISABLE);要求 Lead session 有 workingDir。',
'【工具归属】13 个 team 工具(start_team / create_worker / create_workers / send_to_worker / list_worker_queue / update_queued_message / cancel_queued_message / list_workers / switch_focus / idle_worker / end_team / archive_worker / list_available_models)在独立的 cindy_orca server 直接顶层注册, 对应"协同模式"可关插件(Settings → Connections → Built-in Tools)。通用 session handoff 原语 send_to_session 在 essential 的 cindy_helper 的 handoff 类目下(走 call_tool, 常开, 供 skill 路由用)。',
`【与 Claude Code Task tool / Codex subagent 的区别】Task / subagent 是 agent 框架内的子任务派发机制(子 agent 跑在同一 SDK 进程内、有限工具集、生命周期短、对话历史归属父 turn);${BRAND_NAME} 协同模式是业务层的 session 级编排(Lead/Worker 都是完整独立的 ${BRAND_NAME} session, 独立进程、UI 栏位、完整工具、独立对话历史, 长生命周期, 通过 main 进程 IPC + MCP bridge 通信)。两者不互斥, Worker 内部仍可用 Task/subagent 派子任务。`,
- '【手动入口】ChatInput 工具行的橙色 puzzle pill(CollaborationModeToggle), 用户也能手动开/关, 与本工具走同一份业务代码。',
+ '【手动入口】ChatInput「+」菜单里的「协同模式」项,开启态用橙色 UsersRound 图标与文字标识;用户也能在这里手动开/关,与本工具走同一份业务代码。',
].join(' '),
},
{