Repository navigation
feat(review): definition search core (git grep on the side being reviewed) - #169
Merged
Merged
Conversation
…ewed Port the browser app's search-based code navigation (packages/shared/code-nav.ts) to plannotator-tui-review as codenav: whole-word search, the TS/JS, Python, Go and Rust definition patterns with the generic fallback, the path exclusions and the ranking and caps. It searches with git grep against the side of the diff on screen (a commit, the index, or the working tree with untracked files), so it works on old versions and on a pull request fetched into a bare cache repository. No keys or UI yet.
This was referenced Nov 20, 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.
Adds
plannotator_tui_review::codenav, the search core for a later "go to definition" in the review screen. There are no keys or UI in this PR.It ports the browser app's search-based code navigation (
packages/shared/code-nav.ts):node_modulesand the other tool-output names at any depth;vendor,target,build,distandcoverageonly at the root. A directory the origin file is in is never excluded.One difference from the browser: it runs
git grep -n -w -Fagainst the side of the diff the person is looking at, notrgover the working tree:git grep <rev>. This also works in the bare cache repository a pull request review fetches into.git grep --cachedgit grep --untracked. Likerg, this includes untracked files that are not ignored.The API:
search(repo, &SideSource, &Query { file, line, word, changed })returnsFound { definitions, references, capped, complete, elapsed }.search_withtakes its own time limit.Found::best(&query)gives the jump target: the best definition that is not on the current line, else the best reference.identifiers_on_line(line, language)andidentifier_at(line, column, language)find the words on a line. They skip keywords, numbers, strings and comments, as far as a single-line lexer can.changed_paths(&capture.files)lists the changed files, with both paths of a rename.Language::from_pathfollows the browser'sdetectLanguage. The language's files are limited with pathspecs that match ripgrep 15.1's--typeglobs.Where
git grepcannot matchrg, the module docs list the gap:--max-filesize 1Mhas nogit grepequivalent..gitignorealso matches is still searched.-wtreats only ASCII letters, digits and_as word characters.rgskips hidden files. This port does the same, except in the directories the origin file is in.Tests:
code-nav.test.tscases forclassifyMatch(every language and the generic fallback), theclassifyMatchDetailedtable,rankLocations, thebuildRgArgsexclusions (as pathspecs),isCodeNavPathAllowed, and the real-ripgrep vendor/node_modules cases ([Bug] Code navigation excludes Java packages containing vendor, causing empty References backnotprop/plannotator#1558), run throughgit grepon a real repo.Size:
regexwas already compiled only as a proc-macro dependency.regex-automatawithmetaandregex-syntaxwere already in the binary throughdiffs-rs. Release binary on macOS arm64:main(not committed): 10,263,808, so +150 KB once the UI uses it. Of that, theregexcrate is about 17 KB; the rest is the module itself.