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(task-copy): 未选项目时按任务类型复制到对话或新建项目

Dash90ac8a5fe061
diff --git a/apps/desktop/src/main/task-migration/__tests__/service.test.ts b/apps/desktop/src/main/task-migration/__tests__/service.test.ts
index 826f0e4832..e1f4fc91cc 100644
--- a/apps/desktop/src/main/task-migration/__tests__/service.test.ts
+++ b/apps/desktop/src/main/task-migration/__tests__/service.test.ts
@@ -62,6 +62,8 @@ const state = vi.hoisted(() => ({
/** Target without the `externalTranscripts` capability. */
oldTarget: false,
importedTranscripts: [] as Array<{ path: string; content: string }>,
+ recentProjects: [] as string[],
+ archiveDownloadFails: false,
}));
vi.mock('../../logger', async (original) => {
const actual = await original<typeof import('../../logger')>();
@@ -77,6 +79,15 @@ vi.mock('../../localDb/ipc/sessionCreatedBroadcast', () => ({
emitSessionCreated: (id: string) => state.created(id),
}));
vi.mock('electron', () => ({ app: { getPath: () => state.root }, ipcMain: { handle: vi.fn() } }));
+vi.mock('../../dialogue-workspace-settings', () => ({
+ readDialogueWorkspaceSettings: () => ({
+ directory: path.join(state.root, 'dialogues'),
+ isCustomized: false,
+ }),
+}));
+vi.mock('../../localDb/ipc/recentWorkdirs', () => ({
+ upsertRecentWorkdir: (dir: string) => state.recentProjects.push(dir),
+}));
vi.mock('../resources', async (original) => {
const actual = await original<typeof import('../resources')>();
return {
@@ -164,8 +175,13 @@ vi.mock('../../device-link/mediaTransfer', () => ({
}));
vi.mock('../../device-link/remoteAttachment', () => ({
parseRemoteAttachmentRef: (ref: string) => parseAttachmentOssRef(ref),
- materializeRemoteAttachment: (ref: { ossKey: string }, destination: string) =>
- fs.copyFile(state.files.get(ref.ossKey)!, destination),
+ materializeRemoteAttachment: async (ref: { ossKey: string }, destination: string) => {
+ if (state.archiveDownloadFails && destination.endsWith('.tar.gz.enc')) {
+ state.archiveDownloadFails = false;
+ throw new Error('download interrupted');
+ }
+ await fs.copyFile(state.files.get(ref.ossKey)!, destination);
+ },
}));
vi.mock('../../security/trustedAppRenderer', () => ({ assertTrustedAppRendererEvent() {} }));
vi.mock('../../cindy-media/refCompensationJournal', () => ({
@@ -354,6 +370,8 @@ describe('resumable cross-computer copy', () => {
state.exportOversize = null;
state.oldTarget = false;
state.importedTranscripts = [];
+ state.recentProjects = [];
+ state.archiveDownloadFails = false;
state.migrationWarn.mockClear();
const cwd = path.join(state.root, 'shared');
await fs.mkdir(cwd);
@@ -858,6 +876,49 @@ describe('resumable cross-computer copy', () => {
expect(db.queryOne.mock.calls.some(([sql]) => sql.includes('schedules'))).toBe(false);
expect(await fs.readFile(path.join(state.root, 'shared', 'draft'), 'utf8')).toBe('original');
});
+ it('copies a project task into a new project at the same home-relative path without overwriting', async () => {
+ await start();
+ const result = await settled();
+ expect(result.stage).toBe('complete');
+ const receipt = state.context.run({ device: 'B' }, () =>
+ migrationScope().readIncoming(result.targetSessionId!)!,
+ );
+ // Both test computers share one home, where the source folder already exists.
+ expect(receipt.workingDir).toBe(path.join(state.root, 'shared 2'));
+ expect(state.recentProjects).toEqual([receipt.workingDir]);
+ expect(await fs.readFile(path.join(state.root, 'shared', 'draft'), 'utf8')).toBe('original');
+ });
+ it('reuses its own empty folder on retry instead of leaving a numbered copy behind', async () => {
+ state.archiveDownloadFails = true;
+ await start();
+ expect((await settled()).stage).toBe('transferring');
+ expect(await fs.readdir(path.join(state.root, 'shared 2'))).toEqual([]);
+ await requestTaskMigration({ action: 'retry', sessionId: 'fork' });
+ const result = await settled();
+ expect(result.stage).toBe('complete');
+ const receipt = state.context.run({ device: 'B' }, () =>
+ migrationScope().readIncoming(result.targetSessionId!)!,
+ );
+ expect(receipt.workingDir).toBe(path.join(state.root, 'shared 2'));
+ expect(receipt.retainedWorkingDirs ?? []).toEqual([]);
+ await expect(fs.stat(path.join(state.root, 'shared 3'))).rejects.toMatchObject({
+ code: 'ENOENT',
+ });
+ });
+ it('copies a chat task into the dialogue workspace without adding a project', async () => {
+ state.rows.get('A')!.get('fork')!.workspaceKind = 'dialogue';
+ await start();
+ const result = await settled();
+ expect(result.stage).toBe('complete');
+ const receipt = state.context.run({ device: 'B' }, () =>
+ migrationScope().readIncoming(result.targetSessionId!)!,
+ );
+ const day = path.dirname(receipt.workingDir);
+ expect(path.dirname(day)).toBe(path.join(state.root, 'dialogues'));
+ expect(path.basename(day)).toMatch(/^\d{4}-\d{2}-\d{2}$/);
+ expect(path.basename(receipt.workingDir)).toBe(result.targetSessionId);
+ expect(state.recentProjects).toEqual([]);
+ });
it('copies the complete team and keeps independent target directories', async () => {
const separate = await team();
const before = structuredClone([...state.rows.get('A')!]);
diff --git a/apps/desktop/src/main/task-migration/service.ts b/apps/desktop/src/main/task-migration/service.ts
index a612620680..d477b699db 100644
--- a/apps/desktop/src/main/task-migration/service.ts
+++ b/apps/desktop/src/main/task-migration/service.ts
@@ -22,6 +22,9 @@ import {
type TaskMigrationView,
} from '@cindy/device-link';
import { getDbClient, tryGetDbClient } from '../localDb/client/current';
+import { dialogueWorkspaceDayKey } from '../localDb/dialogueWorkspace';
+import { upsertRecentWorkdir } from '../localDb/ipc/recentWorkdirs';
+import { readDialogueWorkspaceSettings } from '../dialogue-workspace-settings';
import { emitSessionCreated } from '../localDb/ipc/sessionCreatedBroadcast';
import { withSessionRouteLocks } from '../localDb/sessionRouteLock';
import { getActiveTeamByLead } from '../localDb/orcaTeamStore';
@@ -230,6 +233,7 @@ function view(scope: Scope, record: MigrationRecord | null): TaskMigrationView {
interface SourceSession {
id: string;
workingDir: string;
+ workspaceKind: string;
remoteHostId: string | null;
status: string;
source: string;
@@ -243,7 +247,7 @@ async function assertSource(
worker = false,
): Promise<SourceSession> {
const row = await scope.db.queryOne<SourceSession>(
- 'SELECT id, working_dir AS workingDir, remote_host_id AS remoteHostId, status, source, orca_role AS orcaRole, agent_kind AS agentKind, updated_at AS updatedAt FROM sessions WHERE id = ?',
+ 'SELECT id, working_dir AS workingDir, workspace_kind AS workspaceKind, remote_host_id AS remoteHostId, status, source, orca_role AS orcaRole, agent_kind AS agentKind, updated_at AS updatedAt FROM sessions WHERE id = ?',
[sessionId],
);
scope.assertCurrent();
@@ -306,6 +310,80 @@ interface WorkspaceBundle extends PortableWorkspace {
* transcript ref they stand for, `file` the staged name in the outgoing directory.
*/
transcripts?: Array<{ path: string; file: string; bytes: number }>;
+ /**
+ * Where a copy lands when no target project is chosen: the dialogue workspace, or a new project
+ * at the source folder's path under the home directory. Older sources omit it.
+ */
+ destination?: { kind: 'dialogue' } | { kind: 'project'; path: string[] };
+}
+function copyDestination(lead: SourceSession): NonNullable<WorkspaceBundle['destination']> {
+ if (lead.workspaceKind === 'dialogue') return { kind: 'dialogue' };
+ const relative = path.relative(app.getPath('home'), lead.workingDir);
+ const segments = relative ? relative.split(path.sep) : [];
+ return {
+ kind: 'project',
+ path:
+ segments.length && segments[0] !== '..' && !path.isAbsolute(relative)
+ ? segments
+ : [path.basename(lead.workingDir)],
+ };
+}
+const folderName = (name: unknown): name is string =>
+ typeof name === 'string' &&
+ name.length > 0 &&
+ name.length <= 255 &&
+ name !== '.' &&
+ name !== '..' &&
+ !/[\\/\0]/.test(name) &&
+ (process.platform !== 'win32' || !/[<>:"|?*\x00-\x1f]|[. ]$/.test(name));
+/**
+ * Parent folder and name for a copy without a chosen project. A new project mirrors the source
+ * path under home; names this computer cannot create fall back to the source folder name alone.
+ */
+async function defaultDestination(
+ scope: Scope,
+ id: string,
+ destination: WorkspaceBundle['destination'],
+): Promise<{ parent: string; name: string; project?: true }> {
+ if (destination?.kind === 'dialogue') {
+ const { directory, isCustomized } = readDialogueWorkspaceSettings();
+ const parent = path.join(directory, dialogueWorkspaceDayKey(Date.now()));
+ // A custom root is never recreated: an unmounted volume may leave a writable mount point.
+ await fs
+ .mkdir(parent, { recursive: !isCustomized })
+ .catch(async (error: NodeJS.ErrnoException) => {
+ if (error.code !== 'EEXIST' || !(await fs.stat(parent)).isDirectory()) throw error;
+ });
+ return { parent, name: id };
+ }
+ if (destination?.kind === 'project' && Array.isArray(destination.path)) {
+ const segments = destination.path;
+ const valid =
+ segments.length <= 32 && segments.every(folderName)
+ ? segments
+ : segments.slice(-1).filter(folderName);
+ if (valid.length) {
+ const parent = path.join(app.getPath('home'), ...valid.slice(0, -1));
+ await fs.mkdir(parent, { recursive: true });
+ return { parent, name: valid[valid.length - 1], project: true };
+ }
+ }
+ // Older sources: an app-managed folder, as before.
+ const parent = path.join(scope.root, 'projects');
+ await fs.mkdir(parent, { recursive: true, mode: 0o700 });
+ return { parent, name: `cindy-${id.slice(0, 8)}-${randomUUID()}` };
+}
+/** Never reuses an existing entry: `name`, then `name 2`, `name 3`… */
+async function unusedPath(parent: string, name: string): Promise<string> {
+ for (let n = 1; n <= 100; n++) {
+ const candidate = path.join(parent, n === 1 ? name : `${name} ${n}`);
+ const taken = await fs.lstat(candidate).then(
+ () => true,
+ () => false,
+ );
+ if (!taken) return candidate;
+ }
+ throw new Error('MIGRATION_TARGET_UNKNOWN');
}
const workspaces = (workspace: WorkspaceBundle) => [
workspace,
@@ -451,6 +529,7 @@ async function prepare(scope: Scope, record: MigrationHandoff) {
throw new Error('MIGRATION_SOURCE_CHANGED');
const workspace: WorkspaceBundle = {
...snapshots[0],
+ destination: copyDestination(members[0]),
...(result.externalTranscripts?.length
? {
transcripts: result.externalTranscripts.map(({ path: ref, file, bytes }) => ({
@@ -607,6 +686,7 @@ async function preflight(
async function checkTargetResources(
scope: Scope,
targetProject: string | null,
+ destination: string,
resources: MigrationResources,
) {
if (targetProject && !(await projects(scope)).includes(targetProject))
@@ -616,7 +696,7 @@ async function checkTargetResources(
await assertDiskCapacity([
{ path: scope.root, bytes: resources.transferBytes * 2 + resources.contextBytes * 2 },
{
- path: targetProject ?? scope.root,
+ path: destination,
bytes: resources.unpackedBytes + resources.repositoryBytes * 3 + resources.entries * 4096,
},
{
@@ -893,34 +973,11 @@ async function receive(
const knownProjects = await projects(scope);
if (request.targetProject && !knownProjects.includes(request.targetProject))
throw new Error('MIGRATION_TARGET_UNKNOWN');
- const parent = request.targetProject ?? path.join(scope.root, 'projects');
- if (request.targetProject) {
- if (!(await fs.stat(parent)).isDirectory()) throw new Error('MIGRATION_TARGET_UNKNOWN');
- } else await fs.mkdir(parent, { recursive: true, mode: 0o700 });
+ if (request.targetProject && !(await fs.stat(request.targetProject)).isDirectory())
+ throw new Error('MIGRATION_TARGET_UNKNOWN');
scope.assertCurrent();
- // Each failed attempt owns only its new directory. It never replaces a user's existing folder.
- const workingDir = path.join(parent, `cindy-${request.id.slice(0, 8)}-${randomUUID()}`);
- const retainedWorkingDirs = record
- ? [
- ...new Set([
- ...(record.retainedWorkingDirs ?? []),
- record.workingDir,
- ...(record.workers ?? []).map((worker) => worker.workingDir),
- ]),
- ]
- : [];
- record = {
- kind: 'incoming',
- id: request.id,
- sessionId: request.id,
- sourceDeviceId: peer,
- sourceSessionId: request.sourceSessionId,
- stage: 'receiving',
- workingDir,
- ...(retainedWorkingDirs.length ? { retainedWorkingDirs } : {}),
- };
- scope.save(record);
- await fs.mkdir(workingDir);
+ const previous = record;
+ let newProject = false;
try {
await fs.mkdir(directory, { recursive: true, mode: 0o700 });
assertMemoryCapacity(request.files.manifest.size);
@@ -989,7 +1046,14 @@ async function receive(
)
)
throw new Error('MIGRATION_INVALID_MANIFEST');
- await checkTargetResources(scope, request.targetProject, {
+ const target = request.targetProject
+ ? {
+ parent: request.targetProject,
+ name: `cindy-${request.id.slice(0, 8)}-${randomUUID()}`,
+ }
+ : await defaultDestination(scope, request.id, workspace.destination);
+ scope.assertCurrent();
+ await checkTargetResources(scope, request.targetProject, target.parent, {
...(transcriptFiles.length
? { transcriptBytes: transcriptFiles.reduce((sum, file) => sum + file.size, 0) }
: {}),
@@ -1009,17 +1073,54 @@ async function receive(
0,
),
});
+ // Each failed attempt owns only its new directory. It never replaces a user's existing folder.
+ // A retry reuses this copy's own still-empty folder rather than leaving `name 2` behind.
+ const reusable =
+ previous?.workingDir !== undefined &&
+ path.dirname(previous.workingDir) === target.parent &&
+ (await fs.readdir(previous.workingDir).then(
+ (entries) => entries.length === 0,
+ () => false,
+ ));
+ const workingDir = reusable
+ ? previous.workingDir
+ : await unusedPath(target.parent, target.name);
+ const retainedWorkingDirs = previous
+ ? [
+ ...new Set([
+ ...(previous.retainedWorkingDirs ?? []),
+ previous.workingDir,
+ ...(previous.workers ?? []).map((worker) => worker.workingDir),
+ ]),
+ ].filter((dir) => dir !== workingDir)
+ : [];
+ record = {
+ kind: 'incoming',
+ id: request.id,
+ sessionId: request.id,
+ sourceDeviceId: peer,
+ sourceSessionId: request.sourceSessionId,
+ stage: 'receiving',
+ workingDir,
+ ...(retainedWorkingDirs.length ? { retainedWorkingDirs } : {}),
+ };
+ scope.save(record);
+ if (!reusable) await fs.mkdir(workingDir);
+ newProject = target.project === true;
const targetDirs = [workingDir];
+ // Worker folders stay app-managed unless the user chose a project for the copy.
+ const workerParent = request.targetProject ?? path.join(scope.root, 'projects');
+ if (snapshots.length > 1) await fs.mkdir(workerParent, { recursive: true, mode: 0o700 });
for (let index = 1; index < snapshots.length; index++) {
- const target = path.join(parent, `cindy-${request.id.slice(0, 8)}-${randomUUID()}`);
+ const dir = path.join(workerParent, `cindy-${request.id.slice(0, 8)}-${randomUUID()}`);
// Persist intent before allocation: even a process exit cannot orphan a directory.
record = {
...record,
- retainedWorkingDirs: [...(record.retainedWorkingDirs ?? []), target],
+ retainedWorkingDirs: [...(record.retainedWorkingDirs ?? []), dir],
};
scope.save(record);
- await fs.mkdir(target);
- targetDirs.push(target);
+ await fs.mkdir(dir);
+ targetDirs.push(dir);
}
record = {
...record,
@@ -1128,6 +1229,8 @@ async function receive(
scope.assertCurrent();
record = { ...record, stage: 'active' } as IncomingMigration;
scope.save(record);
+ // A new project joins the recent projects, like a task started in a chosen folder.
+ if (newProject) await upsertRecentWorkdir(record.workingDir, Date.now(), undefined, scope.db);
for (const id of [record.sessionId, ...(record.workers ?? []).map((w) => w.sessionId)])
emitSessionCreated(id);
return view(scope, record);
@@ -1182,9 +1285,12 @@ export async function requestTaskMigration(raw: unknown): Promise<TaskMigrationV
return { ...view(scope, null), estimate };
}
if (request.action === 'preflight') {
- await checkTargetResources(scope, request.targetProject, request.resources).catch(
- logTargetFailure('preflight', null),
- );
+ await checkTargetResources(
+ scope,
+ request.targetProject,
+ request.targetProject ?? scope.root,
+ request.resources,
+ ).catch(logTargetFailure('preflight', null));
return view(scope, null);
}
if (request.action === 'caps') {
diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/TaskMigrationDialog.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/TaskMigrationDialog.tsx
index f304c05a58..44f4c7ce47 100644
--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/TaskMigrationDialog.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/TaskMigrationDialog.tsx
@@ -8,7 +8,7 @@ import {
type TaskMigrationView,
} from '@cindy/device-link';
import type { Session } from '@/lib/ccAgent.types';
-import type { TaskMoveDestination } from './TaskMoveSubmenu';
+import { copyDefaultLabelKey, type TaskMoveDestination } from './TaskMoveSubmenu';
import { Button } from '@/components/ui/button';
import { Spinner } from '@/components/ui/spinner';
import { Select } from '@/components/ui/select';
@@ -375,7 +375,7 @@ export function TaskMigrationDialog({
<div className="mt-4 space-y-2 text-sm text-[var(--confirm-title)]">
<p className="break-all">
{t('taskMigration.project')}:{' '}
- {destination.project ?? t('taskMigration.defaultFolder')}
+ {destination.project ?? t(copyDefaultLabelKey(session))}
</p>
<p className="text-[var(--confirm-desc)]">{t('taskMigration.newFolder')}</p>
</div>
@@ -412,7 +412,7 @@ export function TaskMigrationDialog({
value={project || '__default__'}
disabled={busy || !target || readyTarget !== target}
options={[
- { value: '__default__', label: t('taskMigration.defaultFolder') },
+ { value: '__default__', label: t(copyDefaultLabelKey(session)) },
...projects.map((p) => ({ value: p, label: p })),
]}
onValueChange={(value) => setProject(value === '__default__' ? '' : value)}
diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/TaskMoveSubmenu.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/TaskMoveSubmenu.tsx
index 9a4f03dd3c..b01500255f 100644
--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/TaskMoveSubmenu.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/TaskMoveSubmenu.tsx
@@ -33,6 +33,10 @@ export interface TaskMoveDestination {
project: string | null;
}
+/** Without a chosen project, a chat copy stays a chat and a project copy becomes a new project. */
+export const copyDefaultLabelKey = (session: Pick<Session, 'workspaceKind'>) =>
+ session.workspaceKind === 'dialogue' ? 'taskMigration.dialogue' : 'taskMigration.newProject';
+
/** Same source-host business operation for recent projects, dialogue, and the folder picker. */
export async function moveRemoteTaskProject(session: Session, workingDir: string | null) {
const device = session.deviceLinkDeviceId;
@@ -207,6 +211,7 @@ export function TaskMoveSubmenu({
key={device.deviceId}
device={device}
team={session.orcaRole === 'lead'}
+ defaultLabelKey={copyDefaultLabelKey(session)}
onSelect={onMigration}
/>
))
@@ -226,10 +231,12 @@ export function TaskMoveSubmenu({
function DeviceProjects({
device,
team,
+ defaultLabelKey,
onSelect,
}: {
device: DeviceLinkDeviceView;
team: boolean;
+ defaultLabelKey: string;
onSelect(value: TaskMoveDestination): void;
}) {
const { t } = useTranslation();
@@ -306,7 +313,7 @@ function DeviceProjects({
) : projects ? (
<>
<DropdownMenuItem className={MENU_ITEM_CLASS} onSelect={() => choose(null)}>
- {t('taskMigration.defaultFolder')}
+ {t(defaultLabelKey)}
</DropdownMenuItem>
<SessionProjectMoveSubmenu
heading={t('taskMigration.project')}
diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/TaskMoveSubmenu.test.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/TaskMoveSubmenu.test.tsx
index 917ddba718..e3c4670a3b 100644
--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/TaskMoveSubmenu.test.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/__tests__/TaskMoveSubmenu.test.tsx
@@ -177,14 +177,14 @@ it('explains missing migration support without offering a misleading load retry'
fireEvent.keyDown(screen.getByRole('menuitem', { name: 'B' }), { key: 'ArrowRight' });
expect(await screen.findByText('taskMove.upgradeComputer')).toBeTruthy();
expect(screen.queryByRole('menuitem', { name: 'taskMove.retry' })).toBeNull();
- expect(screen.queryByRole('menuitem', { name: 'taskMigration.defaultFolder' })).toBeNull();
+ expect(screen.queryByRole('menuitem', { name: 'taskMigration.newProject' })).toBeNull();
});
it('keeps transient connection failures retryable without claiming an old version', async () => {
h.request.mockRejectedValueOnce(new Error('MIGRATION_FAILED'));
await mount();
fireEvent.keyDown(screen.getByRole('menuitem', { name: 'B' }), { key: 'ArrowRight' });
fireEvent.click(await screen.findByRole('menuitem', { name: 'taskMove.retry' }));
- expect(await screen.findByRole('menuitem', { name: 'taskMigration.defaultFolder' })).toBeTruthy();
+ expect(await screen.findByRole('menuitem', { name: 'taskMigration.newProject' })).toBeTruthy();
expect(screen.queryByText('taskMove.upgradeComputer')).toBeNull();
});
@@ -201,8 +201,23 @@ it.each([false, true])(
fireEvent.keyDown(screen.getByRole('menuitem', { name: 'B' }), { key: 'ArrowRight' });
if (supported)
expect(
- await screen.findByRole('menuitem', { name: 'taskMigration.defaultFolder' }),
+ await screen.findByRole('menuitem', { name: 'taskMigration.newProject' }),
).toBeTruthy();
else expect(await screen.findByText('taskMove.upgradeComputer')).toBeTruthy();
},
);
+
+it.each([
+ ['dialogue', 'taskMigration.dialogue'],
+ ['project', 'taskMigration.newProject'],
+] as const)('labels the no-project copy of a %s task as %s', async (workspaceKind, label) => {
+ await mount({ ...session, workspaceKind });
+ fireEvent.keyDown(screen.getByRole('menuitem', { name: 'B' }), { key: 'ArrowRight' });
+ fireEvent.click(await screen.findByRole('menuitem', { name: label }));
+ expect(h.destination).toHaveBeenCalledWith({
+ deviceId: 'B',
+ deviceName: 'B',
+ isSelf: false,
+ project: null,
+ });
+});
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index 70ae377f0a..b79e8b3d11 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -17,7 +17,8 @@
"device": "Copy to",
"project": "Save location",
"newFolder": "Creates a new folder without overwriting existing files.",
- "defaultFolder": "Cindy’s default location",
+ "dialogue": "Chat",
+ "newProject": "New Project",
"noDevices": "No available computers. Connect another computer and enable remote control on both computers.",
"openTarget": "Open newly copied task",
"close": "Close",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index 1b2a482d9c..a13c206ab7 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -17,7 +17,8 @@
"device": "コピー先",
"project": "保存先",
"newFolder": "新しいフォルダーを作成し、既存ファイルは上書きしません。",
- "defaultFolder": "Cindy の既定の場所",
+ "dialogue": "会話",
+ "newProject": "新規プロジェクト",
"noDevices": "利用可能なコンピューターがありません。別のコンピューターに接続し、両方でリモート操作を有効にしてください。",
"openTarget": "新しくコピーしたタスクを開く",
"close": "閉じる",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index 25fa485c13..49f7064897 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -17,7 +17,8 @@
"device": "복사 위치",
"project": "저장 위치",
"newFolder": "새 폴더를 만들며 기존 파일은 덮어쓰지 않습니다.",
- "defaultFolder": "Cindy 기본 위치",
+ "dialogue": "대화",
+ "newProject": "새 프로젝트",
"noDevices": "사용 가능한 컴퓨터가 없습니다. 다른 컴퓨터를 연결하고 두 컴퓨터 모두 원격 제어를 켜세요.",
"openTarget": "새로 복사한 작업 열기",
"close": "닫기",
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 8eefede6e7..7ca400ab8c 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -17,7 +17,8 @@
"device": "复制到",
"project": "保存位置",
"newFolder": "新建文件夹,不覆盖已有文件。",
- "defaultFolder": "Cindy 默认位置",
+ "dialogue": "对话",
+ "newProject": "新建项目",
"noDevices": "暂无可用电脑。请连接另一台电脑,并在两台电脑上开启远程控制。",
"openTarget": "打开新复制的任务",
"close": "关闭",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
index 01e1ccc02a..11cc1b5a13 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -17,7 +17,8 @@
"device": "複製到",
"project": "儲存位置",
"newFolder": "建立新資料夾,不覆寫現有檔案。",
- "defaultFolder": "Cindy 預設位置",
+ "dialogue": "對話",
+ "newProject": "新建專案",
"noDevices": "目前沒有可用電腦。請連接另一台電腦,並在兩台電腦上開啟遠端控制。",
"openTarget": "開啟新複製的任務",
"close": "關閉",
diff --git a/docs/dev-rules/protocol-compatibility.md b/docs/dev-rules/protocol-compatibility.md
index 2b1c42c56c..5d71a84808 100644
--- a/docs/dev-rules/protocol-compatibility.md
+++ b/docs/dev-rules/protocol-compatibility.md
@@ -70,6 +70,8 @@ warn/warning 状态检查项、等待或处理中的检查项和 warning issue
运行中取消由源端状态的可选 `cancellable` / `cancelling` 声明,旧源端缺省时控制端不提供取消。
源端状态的可选 `skipped: { total, entries[{ path, code }] }` 列出本次复制跳过的条目,旧源端缺省、旧控制端忽略;
新源端会发送项目内链接链与断开链接,旧目标仍按旧规则拒收(`MIGRATION_EXTERNAL_LINK`),需更新目标。
+manifest 的可选 `destination`(`{ kind: 'dialogue' }` 或 `{ kind: 'project', path }`,`path` 为相对用户目录的
+文件夹名数组)只在未选目标项目时决定落点;旧目标忽略该字段,旧源端缺省时新目标仍用 `task-copies/projects`。
范围、恢复与源目录保护见 [同机移动与跨电脑复制任务](../product-rules/task-device-migration.md)。
设备互联生成文件沿用远端文件服务的 stat 与修改时间,控制端按被控端消息时间窗校验命令产物;
diff --git a/docs/product-rules/task-device-migration.md b/docs/product-rules/task-device-migration.md
index faaf101880..edfa8d1abe 100644
--- a/docs/product-rules/task-device-migration.md
+++ b/docs/product-rules/task-device-migration.md
@@ -22,6 +22,12 @@
也不计入统计;在这些 worktree 里运行的任务不阻止复制。这些文件夹里的其它内容、非 Git 目录照常复制。
Git 保留 HEAD、暂存区和工作文件差别,不复制本机 Git 配置、hooks 或凭证。
目标始终创建独立目录,不覆盖已有项目。整组共享物理目录只复制一份,独立目录分别创建。
+ 保存位置可选目标电脑的已有项目;不选项目时按任务类型只给一个选项:对话任务显示「对话」,
+ 副本放进目标的对话工作区、仍归在「对话」;项目任务显示「新建项目」,按源项目相对用户目录的
+ 路径在目标用户目录下新建(如 `~/Code/app`),同名已存在时依次加「 2」「 3」,并登记为最近项目。
+ 源项目不在用户目录下或路径在目标系统无法创建时,只用项目文件夹名放在用户目录下。
+ Worker 的独立目录在未选项目时放在 Cindy 管理的 `task-copies/projects` 下,不进用户目录。
+ 旧版源端不提供任务类型、或文件夹名本身无法创建时,目标仍放在 `task-copies/projects` 下。
3. 复用 peer 直传及 OSS 回退、冷却。按实时磁盘和可用内存预算准备、发送、接收及解包,
不设任务总大小上限;大文件按现有单对象传输容量分段,校验大小及 SHA-256 后解包。
目标声明 `externalTranscripts` 时,32 MiB 以上的原生会话记录(Codex rollout、Claude、Pi,含 Worker)