Exclude directories from Command Palette file search so files aren't starved from the result cap#13433
Conversation
Command Palette file search could return no files when the query matched many directories: directory entries consumed the repo-metadata result cap in the traversal before any files were reached, so the file the user was searching for never appeared. Add FileSearchModel::get_repo_file_contents (include_folders = false) as a sibling of get_repo_contents, sharing get_repo_contents_with_options, and route the Command Palette file data_source query path through it. Folders are now excluded during traversal (via GetContentsArgs::exclude_folders), so the result cap is spent on file matches. Callers that legitimately show directories (AI context menu, zero-state git-status listing) keep using get_repo_contents unchanged. Closes warpdotdev#12391
|
I'm starting a first review of this pull request. You can view the conversation on Warp. I reviewed this pull request and requested human review from: Comment Powered by Oz |
There was a problem hiding this comment.
Overview
This PR routes non-empty Command Palette file search through a file-only repo-metadata traversal so matching directories no longer consume the traversal result cap before files are reached. The existing directory-inclusive path remains available for callers that can surface directories, and the PR includes targeted tests plus before/after visual evidence.
Concerns
- None.
Verdict
Found: 0 critical, 0 important, 0 suggestions
Approve
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
acarl005
left a comment
There was a problem hiding this comment.
Thanks for the fix. Requesting cleanup of unnecessary comments with inline suggestions. Once those are addressed I'll approve.
|
@oz-agent Please apply the suggested edits in my PR review |
|
I'm working on changes requested in this PR (responding to a PR conversation comment). You can view the conversation on Warp. I pushed changes to this PR based on the comment. Replied to and attempted to resolve 3 review comments that this run addressed. Next steps:
Powered by Oz |
Co-Authored-By: Oz <oz-agent@warp.dev> Co-Authored-By: Andy <acarl005@users.noreply.github.com>
|
@oz-agent Perform the edit I requested in my most recent review |
|
I'm working on changes requested in this PR (responding to a PR conversation comment). You can view the conversation on Warp. I pushed changes to this PR based on the comment. Replied to and attempted to resolve 1 review comment that this run addressed. Next steps:
Powered by Oz |
Co-Authored-By: Andy <acarl005@users.noreply.github.com> Co-Authored-By: Oz <oz-agent@warp.dev>
|
@oz-agent I only asked you to delete the last 2 lines of the doc comment but you deleted the entire doc comment. |
|
I'm working on changes requested in this PR (responding to a PR conversation comment). You can view the conversation on Warp. I pushed changes to this PR based on the comment. Replied to and attempted to resolve 1 review comment that this run addressed. Next steps:
Powered by Oz |
Co-Authored-By: Oz <oz-agent@warp.dev> Co-Authored-By: Andy <acarl005@users.noreply.github.com>
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
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 ofget_repo_contents()that traverses withinclude_folders = false. Both delegate to a sharedget_repo_contents_with_options(query, include_folders, app).contents_args()appliesGetContentsArgs::exclude_folders()wheninclude_foldersis false, so folders are dropped during traversal (before the cap), not filtered out afterward.data_sourcequery path is rerouted toget_repo_file_contents(). Callers that legitimately surface directories (e.g. the AI context menu, and the zero-state git-status listing) keep usingget_repo_contents()unchanged — a blanket.exclude_folders()would have regressed them.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
mainand adds the before/after recording that was the one outstanding review request.Linked Issue
ready-to-specorready-to-implement.Closes #12391
Testing
cargo fmt -- --checkcargo check -p warpcargo clippy -p warp --tests -- -D warnings(clean)cargo nextest run -p warp file_search_model_tests— 16 passed./script/runNote:
--all-featuresclippy surfaces some pre-existingdead_code/unused_importswarnings in unrelated SSH/session-sharing modules that are present onmainindependent of this change; the changed files are clippy-clean.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). Searchingwidgetin 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:
before.mov
After — directories are excluded from the file-search traversal, so it descends to the files and all three are returned:
after.mov
Agent Mode