Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 归一化 Windows 文件捕获键
DavidShend0bae701c2b9
diff --git a/apps/desktop/src/main/turn-change-set/__tests__/store.git-integration.test.ts b/apps/desktop/src/main/turn-change-set/__tests__/store.git-integration.test.tsindex 73367d3e4d..8f7d87f08d 100644--- a/apps/desktop/src/main/turn-change-set/__tests__/store.git-integration.test.ts+++ b/apps/desktop/src/main/turn-change-set/__tests__/store.git-integration.test.ts@@ -707,6 +707,43 @@ describe('turn change-set sidecar store', () => {expect(summary?.files[0]).toMatchObject({ path: 'a.ts', additions: 1, deletions: 1 });});+ it.runIf(process.platform === 'win32')(+ 'deduplicates case-insensitive Windows paths before building an exact patch',+ async () => {+ const target = path.join(workdir, 'Foo.ts');+ await fs.writeFile(target, 'old\n', 'utf8');+ await beginTurnChangeSet({+ sessionId: 'session-1',+ anchorClientId: 'user-1',+ provider: 'claude-code',+ cwd: workdir,+ });+ await captureKnownFileBefore({+ sessionId: 'session-1',+ provider: 'claude-code',+ cwd: workdir,+ targetPath: 'Foo.ts',+ });+ await fs.writeFile(target, 'middle\n', 'utf8');+ await captureKnownFileBefore({+ sessionId: 'session-1',+ provider: 'claude-code',+ cwd: workdir,+ targetPath: 'foo.ts',+ });+ await fs.writeFile(target, 'new\n', 'utf8');+ await finalizeTurnChangeSet('session-1', null, 'complete');++ const [recorded] = await listTurnChangeSets('session-1');+ expect(recorded).toMatchObject({ fileCount: 1, isReversible: true });++ await applyTurnChangeSetAction('session-1', recorded!.id, 'undo');+ expect(await fs.readFile(target, 'utf8')).toBe('old\n');+ await applyTurnChangeSetAction('session-1', recorded!.id, 'reapply');+ expect(await fs.readFile(target, 'utf8')).toBe('new\n');+ },+ );+it('filters sensitive files from a native Codex patch', async () => {await beginTurnChangeSet({sessionId: 'session-1',diff --git a/apps/desktop/src/main/turn-change-set/store.ts b/apps/desktop/src/main/turn-change-set/store.tsindex b4f4315d6d..3b204b1e13 100644--- a/apps/desktop/src/main/turn-change-set/store.ts+++ b/apps/desktop/src/main/turn-change-set/store.ts@@ -874,6 +874,12 @@ function safeRelativeTarget(cwd: string, targetPath: string): { absolutePath: streturn { absolutePath, relativePath: relativePath.split(path.sep).join('/') };}+function captureFileKey(absolutePath: string): string {+ return process.platform === 'win32'+ ? absolutePath.toLocaleLowerCase('en-US')+ : absolutePath;+}+function isInsideRoot(root: string, candidate: string): boolean {const relative = path.relative(root, candidate);return relative === '' || (!relative.startsWith(`..${path.sep}`) && relative !== '..' && !path.isAbsolute(relative));@@ -939,8 +945,9 @@ export async function captureKnownFileBefore(input: KnownFileWriteCapture): PromaddIncompleteReason(pending, 'sensitive-file');return;}- if (pending.capturedFiles.has(target.absolutePath)) return;- const inFlight = pending.captureTasks.get(target.absolutePath);+ const captureKey = captureFileKey(target.absolutePath);+ if (pending.capturedFiles.has(captureKey)) return;+ const inFlight = pending.captureTasks.get(captureKey);if (inFlight) return inFlight;const captureTask = (async () => {if (!await isRealTargetInsideWorkspace(input.cwd, target.absolutePath)) {@@ -961,15 +968,15 @@ export async function captureKnownFileBefore(input: KnownFileWriteCapture): PromaddIncompleteReason(pending, 'diff-too-large');return;}- pending.capturedFiles.set(target.absolutePath, {+ pending.capturedFiles.set(captureKey, {...target,beforeExists: before.exists,beforeText: before.text,beforeMode: before.mode,});pending.capturedBytes += captureBytes;- })().finally(() => pending.captureTasks.delete(target.absolutePath));- pending.captureTasks.set(target.absolutePath, captureTask);+ })().finally(() => pending.captureTasks.delete(captureKey));+ pending.captureTasks.set(captureKey, captureTask);return captureTask;}