Fix file search returning no results when directories fill the result cap#12440
Fix file search returning no results when directories fill the result cap#12440amlndz wants to merge 1 commit into
Conversation
… cap Directories matched the fuzzy query and consumed slots in the 100-entry result cap, but were then discarded in the UI. In repos with many matching directories, all 100 slots could be taken by folders, leaving no room for actual files. Exclude folders from the traversal filter when a query is present so the cap applies only to matching files. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @amlndz on file. In order for us to review and merge your code, each contributor must visit https://cla.warp.dev to read and agree to our CLA. Once you have done so, please comment |
|
Every PR must be linked to a same-repo issue before Oz can review it. This PR is linked to #12391, but no linked issue is marked See the contribution guidelines for the full readiness model. Powered by Oz |
There was a problem hiding this comment.
Every PR must be linked to a same-repo issue before Oz can review it.
This PR is linked to #12391, but no linked issue is marked ready-to-implement yet. Only repository maintainers apply that label, so please wait for a maintainer to mark the issue. Once it is marked, push a new commit or comment /oz-review to re-trigger review.
See the contribution guidelines for the full readiness model.
Powered by Oz
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
|
Hi @amlndz — a reviewer requested changes on this PR and it hasn't had activity from you in 7 days. When you get a chance, please push updates or reply to the review so a reviewer can take another look. Without activity, this PR will be automatically closed after 14 days of inactivity. |
|
/oz-review |
|
I'm re-reviewing this pull request in response to a review request. You can view the conversation on Warp. I completed the review and no human review was requested for this pull request. Comment Powered by Oz |
There was a problem hiding this comment.
Overview
This PR fixes the Command Palette file-search cap issue by excluding folders from non-empty repo-content queries. The behavior change is too broad because the shared helper is also used by search surfaces where directories are valid results.
Concerns
⚠️ contents_argsnow excludes folders for every non-emptyFileSearchModel::get_repo_contentscaller, not just Command Palette file search. The AI context menu repo file source uses that same path and supports inserting directory results, so directory searches there would stop returning matching folders.
Verdict
Found: 0 critical, 1 important, 0 suggestions
Request changes
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
| .is_some_and(|path| FileSearchModel::fuzzy_match_path(&path, &query).is_some()) | ||
| }) | ||
| GetContentsArgs::default() | ||
| .exclude_folders() |
There was a problem hiding this comment.
contents_args is also used by the AI context menu repo file source, where directories are valid insertable results; excluding folders here regresses searching for directory context. Move the folder exclusion to the Command Palette caller or make it caller-configurable.
…starved from the result cap (#13433) ## Description Command Palette file search (the file filter / `Cmd+O`) could return **no files** when the query matched many directories. The repo-metadata traversal caps results at a fixed budget, and directory entries matching the query were consuming those slots before any files were reached — so a query like a common folder name surfaced only directories (or nothing useful), never the files the user was searching for. This routes the Command Palette file filter through a new **file-only** contents path that excludes directories from the traversal, so the result cap is spent on file matches. The fix is deliberately scoped to that one surface: - `FileSearchModel::get_repo_file_contents()` is a new sibling of `get_repo_contents()` that traverses with `include_folders = false`. Both delegate to a shared `get_repo_contents_with_options(query, include_folders, app)`. - `contents_args()` applies `GetContentsArgs::exclude_folders()` when `include_folders` is false, so folders are dropped *during* traversal (before the cap), not filtered out afterward. - Only the Command Palette file `data_source` query path is rerouted to `get_repo_file_contents()`. Callers that legitimately surface directories (e.g. the AI context menu, and the zero-state git-status listing) keep using `get_repo_contents()` unchanged — a blanket `.exclude_folders()` would have regressed them. - The file-only path is uncached (like the existing query path), since the shared per-repo cache holds the directory-inclusive contents. - WASM (`not(feature = "local_fs")`) gets a matching stub. Building on the diagnosis and approach from the earlier PRs #12440 (@amlndz — root cause) and #12894 (@SkyNotSilent — the file-only design), both of which were auto-closed for inactivity; this relands that approach against current `main` and adds the before/after recording that was the one outstanding review request. ## Linked Issue - [x] The linked issue is labeled `ready-to-spec` or `ready-to-implement`. - [x] Where appropriate, screenshots or a short video of the implementation are included below. Closes #12391 ## Testing - [x] `cargo fmt -- --check` - [x] `cargo check -p warp` - [x] `cargo clippy -p warp --tests -- -D warnings` (clean) - [x] `cargo nextest run -p warp file_search_model_tests` — 16 passed - [x] I have manually tested my changes locally with `./script/run` <sub>Note: `--all-features` clippy surfaces some pre-existing `dead_code`/`unused_imports` warnings in unrelated SSH/session-sharing modules that are present on `main` independent of this change; the changed files are clippy-clean.</sub> ### Screenshots / Videos Reproduced in a repo whose matching entries are a deeply-nested chain of directories all named `widget` (every one matches the query), with three files at the bottom of the chain (`widget_alpha_FOUND.txt`, `widget_beta_FOUND.txt`, `widget_gamma_FOUND.txt`). Searching `widget` in the Command Palette file filter: **Before** — the matching directories consume the result cap during traversal, so the three files at the bottom of the chain are never reached and the search returns nothing: https://github.com/user-attachments/assets/e91d2623-35f9-481e-adc6-19cf6e9ca189 **After** — directories are excluded from the file-search traversal, so it descends to the files and all three are returned: https://github.com/user-attachments/assets/c2bd868e-db27-4d77-9333-35488a602212 ## Agent Mode - [ ] Warp Agent Mode - This PR was created via Warp's AI Agent Mode <!-- CHANGELOG-BUG-FIX: Fix Command Palette file search returning no files when the query matched many directories --> ---------
Description
When searching for files by name in the Command Palette, directories that matched the query were consuming slots in the 100-entry result cap (
MAX_REPO_CONTENTS_RESULTS) but then being discarded in the UI. In repositories with many directories whose names match the query (e.g. searching"src"in a large monorepo), all 100 slots could be taken by folders, leaving no room for actual files and returning zero results.The fix is to call
.exclude_folders()onGetContentsArgsincontents_args()when a query is present. This ensures the 100-entry cap applies only to matching files. The directory tree is still fully traversed to find files inside subdirectories — only the directories themselves are excluded from the result set.The zero-state (empty query,
Cmd+Owith no text) is unaffected and continues to include directories.Linked Issue
Closes #12391
ready-to-specorready-to-implement.Testing
./script/runTested by searching for file names in the Warp repository itself (a large repo with many nested directories). Before the fix, queries like
"model"or"view"returned no results due to the cap being filled with matching directories. After the fix, matching files appear correctly.Root cause
In
app/src/search/files/model.rs,contents_args()builtGetContentsArgswithinclude_folders: true(the default). Matching directories filled the 100-entry cap during repo traversal. Inapp/src/search/command_palette/files/data_source.rs, directories are explicitly skipped:So the directories wasted cap slots without contributing any visible results.
Fix