Surface $CDPATH directories in cd argument completion#9444
Surface $CDPATH directories in cd argument completion#9444Faizanq wants to merge 4 commits intowarpdotdev:masterfrom
Conversation
Closes warpdotdev#373. Pipe $CDPATH/$cdpath from the bash and zsh bootstrap payloads through to the path completion engine, then have the cd-argument completer overlay directories under each CDPATH entry on top of the pwd-relative results so suggestions match what `cd` itself would resolve. Behavior is opt-in to the cd command - other Folders templates (e.g. for `tree`, `du`) keep the existing pwd-only completion. Absolute paths, `~`-rooted paths, and explicit `./` / `../` prefixes skip CDPATH to match shell semantics. CHANGELOG-IMPROVEMENT
|
I'm starting a first review of this pull request. I requested changes on this pull request and posted feedback. Comment 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 posted feedback on this pull request. Comment Powered by Oz |
There was a problem hiding this comment.
Overview
This PR threads CDPATH from the shell bootstrap through session context and uses it for cd folder completions in both completer engines.
Concerns
- Relative CDPATH entries are not resolved against the shell's current working directory before directory listing, so valid settings like CDPATH=.. or CDPATH=src won't match shell cd behavior in local sessions.
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
| for entry in cdpath.split(':').filter(|e| !e.is_empty() && *e != ".") { | ||
| let override_ctx = CdpathOverrideContext { | ||
| inner: ctx, | ||
| cdpath_pwd: TypedPathBuf::from(entry), |
There was a problem hiding this comment.
entry directly makes list_directory_entries resolve values like .. or src relative to Warp's process/command context; join non-absolute CDPATH entries to ctx.pwd() before overriding pwd().
Per shell semantics, CDPATH entries that aren't absolute are resolved against the current working directory at cd time, and `~`/`~/...` is expanded to $HOME. Previously each entry was passed straight to TypedPathBuf::from, so settings like `CDPATH=src`, `CDPATH=..`, or `CDPATH=~/code` produced no completions in local sessions. Add resolve_cdpath_entry helper and three regression tests.
|
/oz-review |
There was a problem hiding this comment.
Overview
This PR threads the shell CDPATH value through bootstrap/session state and uses it to add CDPATH-backed directory suggestions for cd arguments.
Concerns
- The cd completer currently seeds current-directory results before CDPATH entries and dedupes by display, but bash/zsh resolve CDPATH-eligible cd targets by checking CDPATH before falling back to the current directory unless . or an empty entry is part of CDPATH. That can make completions come from a different tree than cd will resolve first.
- Security pass: no direct security issue found in the changed code.
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
| matcher: MatchStrategy, | ||
| ctx: &dyn PathCompletionContext, | ||
| ) -> Vec<MatchedSuggestion> { | ||
| let mut results = sorted_directories_relative_to(path, matcher, ctx).await; |
There was a problem hiding this comment.
./empty is in CDPATH; duplicate names and nested completions can therefore be sourced from the wrong tree compared with the cd that will run.
Bash and zsh search each $CDPATH entry in order; an empty or `.` entry stands for the current directory at that position, and pwd is only used as a fallback when no entry matches. The previous version always seeded pwd results first and overlaid CDPATH dirs after, so completions surfaced in a different order than `cd` would actually resolve them. Iterate CDPATH in order, place pwd at the position of the first `.` or empty entry (or append as fallback if absent), and dedupe by display so the first occurrence wins. Update the existing tests to expect the new order and add two more for empty-leading and dot-in-middle layouts.
|
/oz-review |
|
I'm re-reviewing this pull request in response to a review request. You can view the conversation on Warp. I reviewed this pull request and requested human review from: @zachbai. Comment Powered by Oz |
Oz no longer requests changes for this pull request after the latest automated review.
There was a problem hiding this comment.
Overview
This PR wires CDPATH from the bash/zsh bootstrap payload through session state into cd-specific directory completions, and extends the completer to search CDPATH entries in shell resolution order while preserving the existing pwd-only behavior for other folder templates.
Concerns
- No blocking correctness, security, or error-handling concerns found in the inlined diff.
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
Description
Closes #373.
cd <Tab>now completes against directories under$CDPATHin addition to the current working directory, matching what the shell itself resolves when youcdto a relative path.The bash and zsh bootstrap payloads now ship the
CDPATHvalue alongsidehome_dir,path, etc. That value flows throughBootstrappedValue->SessionInfo->Session::cdpath()and is exposed onPathCompletionContext::cdpath(). A newsorted_cd_directorieshelper wrapssorted_directories_relative_to: for each non-.entry in$CDPATH, it lists directory matches under that entry using apwd-overriding context wrapper, deduped against the pwd-relative results.The cd-specific path is opt-in to the
cdcommand. OtherFolderstemplates (tree,du, etc.) keep the existing pwd-only completion. Absolute paths (/foo), home-rooted paths (~/foo), and explicit relative prefixes (./foo,../foo) skip CDPATH to match shell semantics.Testing
Four new unit tests in
crates/warp_completer/src/completer/engine/path_test.rs:test_sorted_cd_directories_no_cdpath_matches_existing_behavior: withoutcdpath, the cd-aware path returns identical results to the currentFolderspathtest_sorted_cd_directories_includes_cdpath_entries: pwd entries first, then unique cdpath entries; duplicates deduped; non-directories filteredtest_sorted_cd_directories_ignores_cdpath_for_absolute_token: absolute path tokens bypass cdpathtest_sorted_cd_directories_skips_dot_entry_in_cdpath:.in cdpath is handled by the pwd-relative pass and not double-listedAll 13 path tests pass; clippy on
warpandwarp_completeris clean. I couldn't run the full warp lib test suite end-to-end locally (ran into a disk-space issue mid-build), relying on CI for the broader pass.Agent Mode
Changelog Entries for Stable
CHANGELOG-IMPROVEMENT:
cd <Tab>now completes against directories listed in$CDPATH, matching the resolution shells already perform.