Skip to content

Add worktree-aware autocomplete suggestions - #14758

Closed
warp-agent-staging[bot] wants to merge 2 commits into
masterfrom
factory/worktree-completions
Closed

Add worktree-aware autocomplete suggestions#14758
warp-agent-staging[bot] wants to merge 2 commits into
masterfrom
factory/worktree-completions

Conversation

@warp-agent-staging

@warp-agent-staging warp-agent-staging Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

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:

  • Trigger contexts: cd <arg> and the git worktree subcommands that reference an existing worktree (remove, move, lock, unlock, repair). git worktree add is intentionally excluded (it creates a new worktree).
  • Insert value: the worktree's shell-escaped absolute path, displayed under its name — the checked-out branch's basename, falling back to the directory basename. This makes cd <name> resolve from any directory while keeping the list readable.
  • Ranking / merge: worktree suggestions are appended to filesystem completion at default priority and de-duplicated by display name, so they supplement rather than reorder or replace normal completion.
  • Data source & caching: a per-cwd, TTL-cached (5s) git worktree list --porcelain run through the session's existing command executor (works for local and warpified-remote sessions). The cache lives on the shared Session, so git is not spawned per keystroke — satisfying the no-latency-regression criterion.
  • Feature-gated: behind FeatureFlag::WorktreeCompletions (added to DOGFOOD_FLAGS), so the shared completion path is inert until the flag is on.

Where the change lives

  • crates/warp_completer — new engine/worktree.rs suggestion source + is_worktree_completion_context, a worktrees() method on PathCompletionContext, and injection at the end of argument completion (both v2 and legacy).
  • app/src/completer/mod.rsSessionContext::worktrees() (flag-gated) + the git worktree list --porcelain porcelain parser.
  • app/src/terminal/model/session.rs — the per-cwd TTL cache and loader on Session.
  • crates/warp_features/src/lib.rs — the WorktreeCompletions flag.

Verification

Deterministic (all passing):

  • New unit tests for the suggestion source and context detection (crates/warp_completer/.../worktree_tests.rs).
  • New end-to-end test through the public suggestions() API (crates/warp_completer/.../suggest/test.rs::test_worktree_completion_for_cd): proves worktree names surface for cd and git worktree remove, are prefix-filtered, and are excluded for unrelated commands — passing under both default and v2 feature configs.
  • Porcelain parser tests (app/src/completer/test.rs).
  • ./script/format clean; 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 warp parser tests pass.

Running-UI visual proof — outstanding (explicit exception)

This behavior is gated behind the dogfood-only WorktreeCompletions flag 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 per factory-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 deterministic suggestions() pipeline test above (the same code path the UI invokes).

CHANGELOG-NEW-FEATURE: Autocomplete now suggests your repository's git worktrees when typing cd and git worktree commands.

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.

oz-agent and others added 2 commits August 6, 2026 00:43
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>
@cla-bot cla-bot Bot added the cla-signed label Aug 6, 2026
@warp-agent-staging warp-agent-staging Bot added the warpy-factory Label associated to the "Wob the Wuilder" factory on staging, also known as Warpy Factory. label Aug 6, 2026
@warp-agent-staging
warp-agent-staging Bot requested a review from acarl005 August 6, 2026 00:51
@warp-agent-staging
warp-agent-staging Bot marked this pull request as ready for review August 6, 2026 00:51
@warp-agent-staging
warp-agent-staging Bot marked this pull request as draft August 6, 2026 00:55
@warp-agent-staging

Copy link
Copy Markdown
Contributor Author

Superseded / on hold: after review, this worktree-completion should instead be expressed as a dynamic generator in warpdotdev/command-signatures (attach a generatorName to cd.json's folders arg, and fill the worktree arg slot in git.json's worktree subcommands), following the shipped precedent of the git local_branches/tags/commits generators. This client-side approach in warpdotdev/warp is not the chosen path. Left open (not closed) pending the command-signatures implementation — a human decides whether to close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed warpy-factory Label associated to the "Wob the Wuilder" factory on staging, also known as Warpy Factory.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add autocomplete suggestions for git worktree names

2 participants