Skip to content

The agent that grows with you

fix(desktop): stop home-directory repo scans when no roots are configured

Hermes Agent67c6fdc09233
diff --git a/apps/desktop/electron/git-repo-scan.test.ts b/apps/desktop/electron/git-repo-scan.test.ts
index c519f7c6739..2195b66cc6e 100644
--- a/apps/desktop/electron/git-repo-scan.test.ts
+++ b/apps/desktop/electron/git-repo-scan.test.ts
@@ -50,6 +50,13 @@ describe('scanGitRepos', () => {
expect(read).not.toHaveBeenCalled()
})
+ it('does not fall back to scanning the home directory when roots are empty (#53328)', async () => {
+ const read = vi.spyOn(fs.promises, 'readdir')
+
+ await expect(scanGitRepos([], { enabled: true })).resolves.toEqual([])
+ expect(read).not.toHaveBeenCalled()
+ })
+
it('scans only configured roots and excludes complete subtrees', async () => {
const root = tempDir()
const included = path.join(root, 'included')
diff --git a/apps/desktop/electron/git-repo-scan.ts b/apps/desktop/electron/git-repo-scan.ts
index ccad0333b3a..fd33fe67f76 100644
--- a/apps/desktop/electron/git-repo-scan.ts
+++ b/apps/desktop/electron/git-repo-scan.ts
@@ -105,12 +105,14 @@ async function mapLimit<T>(items: T[], limit: number, fn: (item: T) => Promise<v
}
/**
- * Scan roots for Git repositories. An empty root list preserves the historical
- * home-directory scan. Disabled discovery returns before resolving home or
- * reading the filesystem.
+ * Scan explicitly configured roots for Git repositories. An empty root list is
+ * intentionally a no-op: silently expanding it to the user's home directory
+ * traverses the whole home (and, on macOS, can reach TCC-protected locations)
+ * during ordinary Desktop startup (#53328). Disabled discovery returns before
+ * resolving home or reading the filesystem.
*/
export async function scanGitRepos(roots: string[], options: RepoScanOptions = {}) {
- if (options.enabled === false) {
+ if (options.enabled === false || !Array.isArray(roots) || roots.length === 0) {
return []
}
diff --git a/hermes_cli/config_defaults.py b/hermes_cli/config_defaults.py
index 345ebe13291..fd3e9180c36 100644
--- a/hermes_cli/config_defaults.py
+++ b/hermes_cli/config_defaults.py
@@ -2569,7 +2569,9 @@ DEFAULT_CONFIG = {
# of the active theme's own sans stack so missing glyphs still fall through. Empty = the
# theme's face. The terminal pane is terminal.font_family.
"font_family": "",
- # Git repo discovery for the Projects sidebar; empty roots = bounded scan of $HOME.
+ # Git repo discovery for the Projects sidebar. Empty roots are a safe
+ # no-op; users must explicitly configure roots for filesystem scanning.
+ # Session-derived projects remain available.
"repo_scan_enabled": True,
"repo_scan_roots": [],
"repo_scan_exclude_paths": [],
diff --git a/tests/hermes_cli/test_desktop_repo_discovery_config.py b/tests/hermes_cli/test_desktop_repo_discovery_config.py
new file mode 100644
index 00000000000..2f24a8ce28a
--- /dev/null
+++ b/tests/hermes_cli/test_desktop_repo_discovery_config.py
@@ -0,0 +1,18 @@
+from hermes_cli.config import DEFAULT_CONFIG
+from hermes_cli.web_server import CONFIG_SCHEMA
+
+
+def test_desktop_repo_discovery_defaults_are_opt_in_by_root():
+ desktop = DEFAULT_CONFIG["desktop"]
+
+ assert desktop["repo_scan_enabled"] is True
+ # Empty roots are deliberately safe: Desktop does not infer a home-wide
+ # search. Users must explicitly configure roots or use session projects.
+ assert desktop["repo_scan_roots"] == []
+ assert desktop["repo_scan_exclude_paths"] == []
+
+
+def test_desktop_repo_discovery_keys_are_in_generated_schema():
+ assert CONFIG_SCHEMA["desktop.repo_scan_enabled"]["type"] == "boolean"
+ assert CONFIG_SCHEMA["desktop.repo_scan_roots"]["type"] == "list"
+ assert CONFIG_SCHEMA["desktop.repo_scan_exclude_paths"]["type"] == "list"