Skip to content

fix(desktop): discover nested local repositories - #6645

Open
BradGroux wants to merge 1 commit into
block:mainfrom
BradGroux:agent/project-discovery-subdirectories
Open

fix(desktop): discover nested local repositories#6645
BradGroux wants to merge 1 commit into
block:mainfrom
BradGroux:agent/project-discovery-subdirectories

Conversation

@BradGroux

Copy link
Copy Markdown
Contributor

Note: This is a replacement for PR #4035, which was accidentally closed when branches were force-pushed after a commit identity rewrite. The changes are identical, rebased onto the latest main.

Summary

Buzz currently treats each configured repositories directory as a flat list. That misses projects organized under common grouping folders such as ~/code/client/web-app or ~/code/projects/buzz-tools, even though those paths are still inside the configured root.

This change adds one shared, bounded repository-discovery path and uses it for both local repository listing and project checkout resolution.

Problem

Two code paths assumed repositories were direct children of the configured root:

  • list_project_local_repositories read only the root's immediate entries.
  • find_local_repo_dir checked only <repos_root>/<candidate>.

As a result, nested repositories were absent from the Desktop repository list and could not be resolved for project operations. Users had to create direct-child symlinks as a workaround.

Approach

The new project_repo_discovery helper applies the same traversal contract everywhere:

  • Search at most four directory levels below each configured root. This covers common organization, team, and project groupings while keeping traversal bounded.
  • Canonicalize the root and every candidate directory before evaluating it.
  • Follow a symlink only when its canonical target remains inside the configured root.
  • Track canonical paths so symlink aliases and cycles are visited once and repositories are not duplicated.
  • Treat a directory containing .git as a terminal repository boundary. Discovery does not descend into a checkout and surface its submodules or nested repositories separately.
  • Surface an inaccessible configured root as an error, but skip individual nested directories that become unreadable during traversal.
  • Sort discovered paths for deterministic results.

list_project_local_repositories now consumes the helper and retains its existing cross-root path deduplication.

find_local_repo_dir preserves the existing direct-child fast path. If that misses, it searches discovered repositories by candidate name and retains the existing clone-origin check when a clone URL is available.

Discovery behavior

Layout Result
<root>/repo/.git Discovered through the existing direct path and recursive listing
<root>/client/web-app/.git Discovered
Repository at depth four Discovered
Repository below depth four Not scanned
Symlink to a directory inside the root Followed and deduplicated by canonical path
Symlink escaping the root Ignored
Repository nested inside another repository Not scanned past the outer repository boundary

Related issue

Fixes #4013

Duplicate search: no overlapping open pull request found before implementation or publication.

Testing

Focused coverage verifies:

  • A repository at the depth-four boundary is discovered while one beyond it is not.
  • A symlink escaping the configured root is rejected.
  • An in-root symlink alias resolves to one canonical repository result.
  • A repository nested under a grouping directory is listed and resolved by find_local_repo_dir.

Commands run:

  • cargo test --manifest-path desktop/src-tauri/Cargo.toml --lib commands::project_repo -- --nocapture (4 passed)
  • cargo check --manifest-path desktop/src-tauri/Cargo.toml --lib
  • just ci: all workspace, Desktop, web, Tauri, build, lint, and analysis gates passed. The final mobile suite remains blocked by the reproducible current-main failure ChannelDetailPage keeps follow mode off while a tall newest message stays visible at mobile/test/features/channels/channel_detail_page_test.dart:1053; 1,021 mobile tests passed and 1 was skipped before the suite reported that single failure. This PR does not change mobile sources.
  • Screenshot: not applicable; this changes local repository discovery without changing rendered UI.

Scope and tradeoffs

  • The four-level limit is intentional. This is repository discovery under an explicitly configured root, not an unbounded filesystem crawl.
  • Repository boundaries are terminal by design, so submodules and repositories nested inside another checkout are not presented as independent top-level projects.
  • No settings, stored configuration, dependencies, or rendered UI are changed.

@BradGroux

Copy link
Copy Markdown
Contributor Author

This is a replacement for #4035, which was accidentally closed when branches were force-pushed after a commit identity rewrite. Prior review comments and feedback are preserved on the old PR:

#4035

Signed-off-by: Brad Groux <3053586+BradGroux@users.noreply.github.com>
Co-authored-by: Brad Groux <bradgroux@hotmail.com>
Signed-off-by: Brad Groux <bradgroux@hotmail.com>
@BradGroux
BradGroux force-pushed the agent/project-discovery-subdirectories branch from 0ec31fa to 28a2472 Compare August 25, 2026 19:16
@BradGroux

Copy link
Copy Markdown
Contributor Author

Rebased onto the latest main (was 36 commits behind). The branch applied cleanly. Local repository discovery still treats configured directories as flat lists on current main, so nested repositories are still invisible, and this fix is still needed.

No review comments on this PR. CI will verify the build and test gate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Buzz cannot discover projects in subfolders of the configured code directory

1 participant