You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AI code review — automated review for reference, author can ignore or act on any point.
Right fix for a real trap: a repo accidentally initialized at $HOME made every subdirectory pass the old !isHome(location.directory) check while persistent indexing silently swept the whole home tree. Keying eligibility off the worktree root with a proper containment test closes that, and keeping nested worktrees below home eligible preserves normal usage. I verified containsHome's path.relative idiom against the four cases — self (""), descendant, ancestor (".."-prefixed), and unrelated-on-another-drive (absolute result) — and it behaves correctly in all of them; the tests covering child/self/parent boundaries are well chosen.
Two refinements:
Lexical-only comparison.path.relative does no filesystem resolution, so aliasing defeats it: macOS /tmp vs /private/tmp, /home/user vs an autofs/symlinked spelling, or Windows casing differences (C:\Users vs c:\users) would all slip past containment. Since both inputs ultimately come from real directories, normalizing through something like fs.realpathSync.native (with a try/fallback to the raw string) before comparing would make the guard hold under aliases too. Not blocking, but this is protection code — the failure mode is quiet and high-blast-radius.
Windows case-insensitivity: same category, cheaper fix — on win32, compare against a lowercased home (or lowercase both sides of relative) so C:\Users\Admin vs C:\users\admin isn't treated as unrelated.
Minor: isHome stays behind for its remaining callers — worth a follow-up glance that none of them are also making a "does this scope include home?" decision with equality-only semantics, since that's precisely the bug class fixed here.
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
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.
Summary
Fixes #44266.
Tests
bun test test/filesystem/search.test.tsbun typecheckbun x prettier --check src/filesystem/protected.ts src/filesystem/search.ts test/filesystem/search.test.tsRequested by: @kitlangton (Kit via Slack)