Skip to content

feat: add support for @ to do file search #1401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 28, 2025
Merged

feat: add support for @ to do file search #1401

merged 1 commit into from
Jun 28, 2025

Conversation

bolinfest
Copy link
Collaborator

@bolinfest bolinfest commented Jun 27, 2025

Introduces support for @ to trigger a fuzzy-filename search in the composer. Under the hood, this leverages https://crates.io/crates/nucleo-matcher to do the fuzzy matching and https://crates.io/crates/ignore to build up the list of file candidates (so that it respects .gitignore).

For simplicity (at least for now), we do not do any caching between searches like VS Code does for its file search:

https://github.com/microsoft/vscode/blob/1d89ed699b2e924d418c856318a3e12bca67ff3a/src/vs/workbench/services/search/node/rawSearchService.ts#L212-L218

Because we do not do any caching, I saw queries take up to three seconds on large repositories with hundreds of thousands of files. To that end, we do not perform searches synchronously on each keystroke, but instead dispatch an event to do the search on a background thread that asynchronously reports back to the UI when the results are available. This is largely handled by the FileSearchManager introduced in this PR, which also has logic for debouncing requests so there is at most one search in flight at a time.

While we could potentially polish and tune this feature further, it may already be overengineered for how it will be used, in practice, so we can improve things going forward if it turns out that this is not "good enough" in the wild.

Note this feature does not work like @ in the TypeScript CLI, which was more like directory-based tab completion. In the Rust CLI, @ triggers a full-repo fuzzy-filename search.

Fixes #1261.

bolinfest added a commit that referenced this pull request Jun 27, 2025
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/1400).
* #1401
* __->__ #1400
Base automatically changed from pr1400 to main June 27, 2025 06:05
@bolinfest bolinfest force-pushed the pr1401 branch 4 times, most recently from 6d4b3ef to 54af601 Compare June 27, 2025 23:02
@bolinfest bolinfest changed the base branch from main to pr1409 June 27, 2025 23:02
Base automatically changed from pr1409 to main June 27, 2025 23:24
@bolinfest bolinfest force-pushed the pr1401 branch 3 times, most recently from bd92cc3 to f5fc218 Compare June 28, 2025 01:27
@bolinfest
Copy link
Collaborator Author

Currently, this feels good for small repos, but is jarring for large repos because the user cannot type while task::block_in_place(|| handle.block_on(future)) is running.

@bolinfest bolinfest force-pushed the pr1401 branch 3 times, most recently from d8c08fe to a5d84ca Compare June 28, 2025 02:53
@bolinfest bolinfest changed the base branch from main to pr1414 June 28, 2025 02:53
Base automatically changed from pr1414 to main June 28, 2025 03:01
@bolinfest bolinfest force-pushed the pr1401 branch 6 times, most recently from dd425f4 to 1c1fe12 Compare June 28, 2025 16:33
@bolinfest bolinfest force-pushed the pr1401 branch 2 times, most recently from e93781c to de04095 Compare June 28, 2025 20:24
Copy link

Summary

Adds @-triggered file-search to the TUI: the composer detects @token, shows a live popup with matching paths, and lets users insert a selection. Implementation introduces FileSearchManager, FileSearchPopup, new AppEvents, and wires them through ChatComposer, BottomPane, and App.

Review

Great UX improvement and the code plugs into existing architecture cleanly. A few small thoughts:

  • Concurrency: FileSearchManager spins a new thread (plus a 20 ms busy-poll) per search; consider a channel/worker to avoid potential thread growth and polling.
  • current_at_token/insert_selected_path index by byte; non-ASCII filenames might misbehave—worth documenting or switching to char_indices.
  • Might be nice to unit-test the debounce/cancel logic and token parsing.
  • Nit: MAX_RESULTS/NUM_FILE_SEARCH_THREADS could live in Config for tunability.

Overall, solid feature—just minor polish opportunities.


View workflow run

@bolinfest bolinfest merged commit 5a0f236 into main Jun 28, 2025
23 checks passed
@bolinfest bolinfest deleted the pr1401 branch June 28, 2025 20:47
@github-actions github-actions bot locked and limited conversation to collaborators Jun 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support @ for fuzzy file search
1 participant