Skip to content

Exclude directories from Command Palette file search so files aren't starved from the result cap#13433

Merged
acarl005 merged 4 commits into
warpdotdev:masterfrom
maxmilian:maxmilian/fix-12391-file-only-search
Jul 16, 2026
Merged

Exclude directories from Command Palette file search so files aren't starved from the result cap#13433
acarl005 merged 4 commits into
warpdotdev:masterfrom
maxmilian:maxmilian/fix-12391-file-only-search

Conversation

@maxmilian

@maxmilian maxmilian commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

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

  • The linked issue is labeled ready-to-spec or ready-to-implement.
  • Where appropriate, screenshots or a short video of the implementation are included below.

Closes #12391

Testing

  • cargo fmt -- --check
  • cargo check -p warp
  • cargo clippy -p warp --tests -- -D warnings (clean)
  • cargo nextest run -p warp file_search_model_tests — 16 passed
  • I have manually tested my changes locally with ./script/run

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.

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:

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

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

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
@cla-bot cla-bot Bot added the cla-signed label Jul 7, 2026
@github-actions github-actions Bot added the external-contributor Indicates that a PR has been opened by someone outside the Warp team. label Jul 7, 2026
@maxmilian
maxmilian marked this pull request as ready for review July 7, 2026 15:51
@oz-for-oss

oz-for-oss Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

@maxmilian

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: @acarl005.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@oz-for-oss
oz-for-oss Bot requested a review from acarl005 July 7, 2026 15:54

@acarl005 acarl005 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix. Requesting cleanup of unnecessary comments with inline suggestions. Once those are addressed I'll approve.

Comment thread app/src/search/files/model.rs Outdated
Comment thread app/src/search/command_palette/files/data_source.rs Outdated
Comment thread app/src/search/files/model_tests.rs Outdated
@acarl005

Copy link
Copy Markdown
Contributor

@oz-agent Please apply the suggested edits in my PR review

@oz-for-oss

oz-for-oss Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

@acarl005

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:

  • Review the changes pushed to this PR.
  • Follow up with another comment if further adjustments are needed.

Powered by Oz

Co-Authored-By: Oz <oz-agent@warp.dev>

Co-Authored-By: Andy <acarl005@users.noreply.github.com>
Comment thread app/src/search/files/model.rs Outdated
@acarl005

Copy link
Copy Markdown
Contributor

@oz-agent Perform the edit I requested in my most recent review

@oz-for-oss

oz-for-oss Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

@acarl005

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:

  • Review the changes pushed to this PR.
  • Follow up with another comment if further adjustments are needed.

Powered by Oz

Co-Authored-By: Andy <acarl005@users.noreply.github.com>

Co-Authored-By: Oz <oz-agent@warp.dev>
@acarl005

Copy link
Copy Markdown
Contributor

@oz-agent I only asked you to delete the last 2 lines of the doc comment but you deleted the entire doc comment.

@oz-for-oss

oz-for-oss Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

@acarl005

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:

  • Review the changes pushed to this PR.
  • Follow up with another comment if further adjustments are needed.

Powered by Oz

Co-Authored-By: Oz <oz-agent@warp.dev>

Co-Authored-By: Andy <acarl005@users.noreply.github.com>
@acarl005
acarl005 enabled auto-merge (squash) July 16, 2026 00:28
@acarl005 acarl005 self-assigned this Jul 16, 2026
@acarl005

Copy link
Copy Markdown
Contributor

@cla-bot check

@cla-bot

cla-bot Bot commented Jul 16, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

@acarl005
acarl005 merged commit 3bf0899 into warpdotdev:master Jul 16, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed external-contributor Indicates that a PR has been opened by someone outside the Warp team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Files might be missing from command palette when too many directories match the search query

3 participants