The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): skip macOS TCC-protected media dirs in git repo scan
miha1bd5da3ac644
diff --git a/apps/desktop/electron/git-repo-scan.test.ts b/apps/desktop/electron/git-repo-scan.test.tsindex 1ad00357637..2347e0de744 100644--- a/apps/desktop/electron/git-repo-scan.test.ts+++ b/apps/desktop/electron/git-repo-scan.test.ts@@ -23,6 +23,17 @@ function makeRepo(root: string, valid = true): void {}}+function makeRepoAt(root: string, ...segments: string[]): string {+ const repo = path.join(root, ...segments)+ makeRepo(repo)++ return repo+}++function foundRoots(results: { root: string }[]): string[] {+ return results.map(entry => entry.root).sort()+}+afterEach(() => {vi.restoreAllMocks()@@ -63,6 +74,55 @@ describe('scanGitRepos', () => {})})+describe('macOS TCC-protected media exclusions (issue #57611 salvage)', () => {+ it('finds a normal repo but skips root-level media folders on darwin', async () => {+ const root = tempDir()+ const dev = makeRepoAt(root, 'dev', 'proj')+ makeRepoAt(root, 'Pictures', 'wallpapers')+ makeRepoAt(root, 'Music', 'samples')+ makeRepoAt(root, 'Movies', 'clips')+ makeRepoAt(root, 'Public', 'shared')++ expect(foundRoots(await scanGitRepos([root], { enabled: true, platform: 'darwin' }))).toEqual([dev])+ })++ it('still scans a media-named directory below the search root on darwin', async () => {+ const root = tempDir()+ const nested = makeRepoAt(root, 'dev', 'Music', 'app')++ expect(foundRoots(await scanGitRepos([root], { enabled: true, platform: 'darwin' }))).toEqual([nested])+ })++ it('skips Apple media-library packages at any depth on darwin', async () => {+ const root = tempDir()+ const keeper = makeRepoAt(root, 'code', 'site')+ makeRepoAt(root, 'code', 'Photos Library.photoslibrary', 'inner')+ makeRepoAt(root, 'backups', 'Music Library.MUSICLIBRARY', 'inner')+ makeRepoAt(root, 'backups', 'TV Library.tvlibrary', 'inner')+ makeRepoAt(root, 'backups', 'Old.aplibrary', 'inner')++ expect(foundRoots(await scanGitRepos([root], { enabled: true, platform: 'darwin' }))).toEqual([keeper])+ })++ it('walks an explicitly passed media root on darwin', async () => {+ const root = tempDir()+ const musicRoot = path.join(root, 'Music')+ const repo = makeRepoAt(musicRoot, 'samples')++ expect(foundRoots(await scanGitRepos([musicRoot], { enabled: true, platform: 'darwin' }))).toEqual([repo])+ })++ it('does not exclude media-named folders on linux', async () => {+ const root = tempDir()+ const dev = makeRepoAt(root, 'dev', 'proj')+ const music = makeRepoAt(root, 'Music', 'samples')++ expect(foundRoots(await scanGitRepos([root], { enabled: true, platform: 'linux' }))).toEqual(+ [dev, music].sort()+ )+ })+})+describe('repository scan path normalization', () => {it('expands tilde and resolves relative paths from home', () => {expect(normalizeRepoScanPath('~/src', { homeDir: '/Users/rudi', platform: 'darwin' })?.value).toBe(diff --git a/apps/desktop/electron/git-repo-scan.ts b/apps/desktop/electron/git-repo-scan.tsindex ce5b60368c8..265d97bdc63 100644--- a/apps/desktop/electron/git-repo-scan.ts+++ b/apps/desktop/electron/git-repo-scan.ts@@ -15,6 +15,9 @@ export interface RepoScanOptions {maxDepth?: numberenabled?: booleanexcludePaths?: string[]+ // Platform override for the darwin-only TCC media-dir skip (tests force+ // 'darwin' on Linux CI; production omits it).+ platform?: NodeJS.Platform}export interface RepoScanPathOptions {@@ -22,6 +25,19 @@ export interface RepoScanPathOptions {platform?: NodeJS.Platform}+// Avoid macOS TCC prompts when the default home scan reaches protected media+// folders. Nested names and explicitly supplied media roots remain scannable.+const MEDIA_ROOT_DIRS = new Set(['Movies', 'Music', 'Pictures', 'Public'])++// These packages look like directories but are TCC-protected and cannot contain+// user repositories, including when stored outside the default media folders.+const LIBRARY_PACKAGE_SUFFIXES = ['.photoslibrary', '.musiclibrary', '.tvlibrary', '.aplibrary']++function isLibraryPackage(name: string): boolean {+ const lower = String(name).toLowerCase()+ return LIBRARY_PACKAGE_SUFFIXES.some(suffix => lower.endsWith(suffix))+}+interface NormalizedScanPath {key: stringvalue: string@@ -99,7 +115,7 @@ export async function scanGitRepos(roots: string[], options: RepoScanOptions = {const maxDepthValue = Number(options.maxDepth)const maxDepth = Number.isFinite(maxDepthValue) && maxDepthValue >= 0 ? maxDepthValue : DEFAULT_MAX_DEPTH- const pathOptions: RepoScanPathOptions = {}+ const pathOptions: RepoScanPathOptions = options.platform ? { platform: options.platform } : {}const requestedRoots = Array.isArray(roots) && roots.length > 0 ? roots : [os.homedir()]const searchRoots = [@@ -155,8 +171,21 @@ export async function scanGitRepos(roots: string[], options: RepoScanOptions = {return}+ const skipTccProtectedPaths = (pathOptions.platform ?? process.platform) === 'darwin'const subdirs = entries.filter(entry => entry.isDirectory() && !entry.name.startsWith('.') && !JUNK_DIRS.has(entry.name))+ .filter(entry => {+ if (!skipTccProtectedPaths) {+ return true+ }+ // Depth-0 children of a scan root only: a nested dir named "Music"+ // inside a project is fine, and an explicitly supplied media root+ // arrives AS a root (never as a depth-0 child), so it still scans.+ if (depth === 0 && MEDIA_ROOT_DIRS.has(entry.name)) {+ return false+ }+ return !isLibraryPackage(entry.name)+ }).map(entry => path.join(dir, entry.name))await mapLimit(subdirs, MAX_CONCURRENCY, subdir => walk(subdir, depth + 1))