fix(core): scope React subproject discovery to skip app-data dirs and bound depth#557
Merged
Merged
Conversation
This was referenced May 29, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #545.
Root cause
Running
npx react-doctorfrom a home directory (nopackage.json/ workspace manifest in cwd) falls through todiscoverReactSubprojectsByFilesystem, which recursively walks the entire home tree with no depth bound and only prunes dotfiles + build artifacts (IGNORED_DIRECTORIES). It therefore descends ~9 levels into editor internals likeAppData\Local\Programs\Microsoft VS Code\…\extensions\copilot, whosepackage.jsondeclares a React dependency (hasReactDependencymatches any ofreact/react-native/next/preact). Combined with the user's realDownloadsprojects, that yielded 4 candidates, andresolveDiagnoseTargetthrowsAmbiguousProjectError— aborting the run withMultiple React projects found.Fix
In the filesystem-fallback crawl (
packages/core/src/project-info/discover-react-subprojects.ts):AppData,Application Data,Library. This prunes the VS Code extension branch (and similar vendored installs) at the top level. The reported false positive lived underAppData.MAX_SCAN_DEPTH = 6) as a backstop against pathological vendored trees that escape the name list. Projects discovered via the filesystem fallback realistically sit only a few levels down.Both guards apply only to the filesystem fallback (used when the scan root has no manifest); manifest/workspace resolution is unchanged, and the shared
IGNORED_DIRECTORIESset is untouched so in-project source scans are unaffected.Tests
Added two cases to
discover-project.test.ts:AppData/.../extensions/copilotplus a realDownloads/.../frontend— only the real project is returned (direct CLI error: Multiple React projects found under C:\Users\Admin (4 candidates): AppData\Local\Programs\Microsoft VS Code\f6cfa2ea24\resources\app\extensions\copilot, Downloads\Agna_Resumo_Clickup\frontend, Downloads\BuildScraper\docs-portal, Downloads\BuildS #545 repro).MAX_SCAN_DEPTHis not discovered.All 73 tests in
discover-project.test.tspass;typecheckclean.Note
Low Risk
Discovery-only change in the filesystem fallback path; workspace/manifest resolution is untouched, with targeted tests for the new guards.
Overview
Fixes #545 by tightening the filesystem-only React subproject crawl used when the scan root has no
package.jsonor workspace manifest.The recursive walk now skips OS/editor app-data directory names (
AppData,Application Data,Library) so vendored React packages inside editor installs are not counted as user projects. It also caps descent at depth 6 so deeply nested vendored trees are not discovered. Manifest-based workspace discovery is unchanged.Tests cover a home-directory layout with a fake VS Code extension under
AppDataplus a real app underDownloads, and a React package beyond the depth limit.Reviewed by Cursor Bugbot for commit a417849. Bugbot is set up for automated code reviews on this repo. Configure here.