Add worktree-aware autocomplete suggestions - #14758
Closed
warp-agent-staging[bot] wants to merge 2 commits into
Closed
Add worktree-aware autocomplete suggestions#14758warp-agent-staging[bot] wants to merge 2 commits into
warp-agent-staging[bot] wants to merge 2 commits into
Conversation
Surface a repository's git worktrees as command-input completion suggestions in worktree-relevant contexts (cd and git worktree subcommands). Worktree directory names are often short or auto-generated and usually live outside the current directory, so ordinary filesystem completion never surfaces them. - New worktree suggestion source in the completer engine (crates/warp_completer) that matches a worktree's memorable name (branch basename, else dir basename) and inserts its shell-escaped absolute path so it resolves from anywhere. Suggestions augment, and never replace, filesystem completion (deduped by display). - Client wiring reads worktrees from a per-cwd, TTL-cached git worktree list --porcelain on the shared Session, so git is not spawned per keystroke. - Gated behind FeatureFlag::WorktreeCompletions (dogfood-on). Co-Authored-By: Warp Agent <agent@warp.dev>
Exercises the full completion pipeline (parse -> argument complete -> worktree injection -> coalesce) via the public suggestions() API, asserting worktree names surface for cd and git worktree subcommands and are excluded for unrelated commands. Adds worktree support to the shared MockPathCompletionContext test harness. Co-Authored-By: Warp Agent <agent@warp.dev>
Contributor
Author
|
Superseded / on hold: after review, this worktree-completion should instead be expressed as a dynamic generator in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds worktree-aware autocomplete: in a repo with multiple git worktrees, Warp now suggests the repo's known worktrees while typing worktree-relevant commands, so you can jump to a worktree by its (often short/auto-generated) name from anywhere. Resolves #11542.
A worktree suggestion displays the worktree's memorable name and inserts its shell-escaped absolute path, so accepting one works regardless of the current directory. Suggestions augment (never replace) normal filesystem path completion.
Design decisions
Triage flagged product ambiguity; resolved here toward the smallest change that satisfies the issue, since the completion engine is shared and latency-sensitive:
cd <arg>and thegit worktreesubcommands that reference an existing worktree (remove,move,lock,unlock,repair).git worktree addis intentionally excluded (it creates a new worktree).cd <name>resolve from any directory while keeping the list readable.git worktree list --porcelainrun through the session's existing command executor (works for local and warpified-remote sessions). The cache lives on the sharedSession, so git is not spawned per keystroke — satisfying the no-latency-regression criterion.FeatureFlag::WorktreeCompletions(added toDOGFOOD_FLAGS), so the shared completion path is inert until the flag is on.Where the change lives
crates/warp_completer— newengine/worktree.rssuggestion source +is_worktree_completion_context, aworktrees()method onPathCompletionContext, and injection at the end of argument completion (bothv2andlegacy).app/src/completer/mod.rs—SessionContext::worktrees()(flag-gated) + thegit worktree list --porcelainporcelain parser.app/src/terminal/model/session.rs— the per-cwd TTL cache and loader onSession.crates/warp_features/src/lib.rs— theWorktreeCompletionsflag.Verification
Deterministic (all passing):
crates/warp_completer/.../worktree_tests.rs).suggestions()API (crates/warp_completer/.../suggest/test.rs::test_worktree_completion_for_cd): proves worktree names surface forcdandgit worktree remove, are prefix-filtered, and are excluded for unrelated commands — passing under both default andv2feature configs.app/src/completer/test.rs)../script/formatclean;cargo clippy -p warp_completer/-p warp/-p warp_features(--all-targets --tests -D warnings) clean;cargo nextest run -p warp_completer(default +v2) and the-p warpparser tests pass.Running-UI visual proof — outstanding (explicit exception)
This behavior is gated behind the dogfood-only
WorktreeCompletionsflag and exists only on this branch, so it can only be exercised by a from-source build of the GPU-based Warp desktop client with a live shell session and a repo containing multiple worktrees. This headless remote build environment cannot produce that runnable client, so perfactory-ui-verification's explicit-exception path the running-UI capture is deferred to a human/dogfood build. The end-user behavior is otherwise covered end-to-end by the deterministicsuggestions()pipeline test above (the same code path the UI invokes).CHANGELOG-NEW-FEATURE: Autocomplete now suggests your repository's git worktrees when typing
cdandgit worktreecommands.Originating thread: https://warpdev.slack.com/archives/C0BDQDW8V5E/p1785969286177199
Conversation: https://staging.warp.dev/conversation/7d3911cb-16c7-468f-8fb8-8d6c7540a684
Run: https://oz.staging.warp.dev/runs/019fd420-7fa8-7268-b619-36dceccf018a
This PR was generated with Oz.