diff --git a/src/main/agent-launch/trust/agent-trust-presets.test.ts b/src/main/agent-launch/trust/agent-trust-presets.test.ts index 750a1f52ea3..dd8f7c16bfc 100644 --- a/src/main/agent-launch/trust/agent-trust-presets.test.ts +++ b/src/main/agent-launch/trust/agent-trust-presets.test.ts @@ -91,6 +91,16 @@ describe('markCursorWorkspaceTrusted', () => { rmSync(workspace, { recursive: true, force: true }) } }) + + it('uses the project directory cursor-agent reads', () => { + // Names computed by cursor-agent's own rule (2026.09.28 and 2026.11.05) for these paths. + markCursorWorkspaceTrusted('/orca-missing/My Repo_v2/Ünï code--x.1', testState.fakeHomeDir) + markCursorWorkspaceTrusted('C:\\Users\\Jane Doe\\orca\\feat', testState.fakeHomeDir) + expect(readdirSync(join(testState.fakeHomeDir, '.cursor', 'projects')).sort()).toEqual([ + 'C-Users-Jane-Doe-orca-feat', + 'orca-missing-My-Repo-v2-n-code-x-1' + ]) + }) }) describe('markKimiWorkspaceTrusted', () => { diff --git a/src/main/agent-launch/trust/agent-trust-presets.ts b/src/main/agent-launch/trust/agent-trust-presets.ts index 220f9acb8f0..0af5a253bf8 100644 --- a/src/main/agent-launch/trust/agent-trust-presets.ts +++ b/src/main/agent-launch/trust/agent-trust-presets.ts @@ -163,8 +163,9 @@ function canonicalize(p: string): string { } function cursorWorkspaceSlug(absPath: string): string { - const stripped = absPath.replace(/^[\\/]+/, '') - // Windows paths contain characters forbidden in Cursor’s project-directory names. - const slug = stripped.replace(/[\\/:*?"<>|]+/g, '-') - return slug + // Mirrors cursor-agent's project-directory name; any mismatch leaves the trust menu up. + return absPath + .replace(/[^a-zA-Z0-9]/g, '-') + .replace(/-+/g, '-') + .replace(/^-+|-+$/g, '') }