fix(pi-fff): preserve path/exclude in fuzzy grep fallback (#697) - #699
Merged
Conversation
…back (#697) The automatic fuzzy fallback in the pi-fff `grep` tool passed the raw `pattern` to `picker.grep`, discarding the constrained `query` built via `buildQuery`. As a result, the fallback ignored the caller's `path` and `exclude` constraints and could return matches from explicitly excluded directories or files outside the requested path. Pass the constrained `query` to the fallback instead, so it only broadens matching (fuzzy vs. plain) without broadening scope. Closes #697
Owner
|
@gustav-fff update the pr to preserve it ONLY if there is no extension (I mean when there is path like /some/file/path.ts INSIDE the cwd or any aux pickers we use the whole picker fuzzy match) but if there is a directory we use the standard aux picker finding and preserver the queries |
When the caller pinned a specific file (path has an extension), the fuzzy fallback broadens across the whole picker so a mistyped filename can still surface matches. For directory constraints (or no path), keep the constrained query so the fallback does not leak matches from excluded / out-of-scope directories.
Collaborator
Author
|
[triage-bot] DIRECTED: pushed d500af2. Behavior split by the last segment of
Extension detection uses the same regex as Tests: Honk-Honk 🪿 |
dmtrKovalenko
approved these changes
Jul 23, 2026
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.
Closes #697
Root cause
packages/pi-fff/src/index.ts:727invoked the fuzzy fallback with the rawpattern, discarding the constrainedquerybuilt atsrc/index.ts:665-667viabuildQuery(src/query.ts:80). Sincequeryis the only carrier of the normalizedpathinclude and!<exclude>clauses, the fallback searched the entire index — leaking matches from excluded directories or files outside the requested path.Fix
Pass the constrained
queryto the fallbackpicker.grepcall instead ofpattern. The fallback still broadens matching (fuzzy vs. plain) but no longer broadens scope.Steps to reproduce
Setup on
origin/main(pre-fix):git checkout 05a35c6d4856455393a2dc8aadaeae4b2823ddf6 cd packages/pi-fffFixture:
Call
ffgrepvia pi-fff with:{ "pattern": "needle", "path": "/tmp/fff-repro/target.json", "exclude": "sessions/", "context": 0, "limit": 5 }Actual (pre-fix):
Expected:
The
sessions/directory is explicitly excluded AND is outside the requestedpath(a specific file). The fuzzy fallback discarded both constraints because it re-ran withpattern(needle) rather than the constrainedquery(target.json !sessions/ needle).How verified
bun testinpackages/pi-fff/— 44 pass, 0 fail.querystring as the primary search; the only difference between the twopicker.grepcalls ismode: "fuzzy"vs. the auto-detected mode.path/excludeis set) is preserved becausebuildQueryreturns justpatternwhen no constraints are supplied.Automated triage via Gustav. Honk-Honk 🪿