Skip to content

Add git worktree name autocomplete suggestions - #302

Merged
acarl005 merged 2 commits into
mainfrom
factory/git-worktree-completions
Aug 6, 2026
Merged

Add git worktree name autocomplete suggestions#302
acarl005 merged 2 commits into
mainfrom
factory/git-worktree-completions

Conversation

@warp-agent-staging

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

Copy link
Copy Markdown
Contributor

Summary

Adds git-worktree-aware autocomplete so Warp suggests a repo's known linked working trees while typing git worktree lock, move, remove, and unlock.

  • New worktrees generator in command-signatures/src/generators/git.rs, sourced from git --no-optional-locks worktree list --porcelain. It parses the porcelain records and emits one suggestion per linked working tree, mirroring the neighbouring git generators (--no-optional-locks, filter_messages/fatal: short-circuit, IconType, descriptions).
  • Wires "generatorName": "worktrees" into the worktree arg of git worktree lock, move, remove, and unlock in command-signatures/json/git.json (the previously empty arg slots).

Design decision: insert the path, not the name

Each suggestion inserts the worktree's path, not a derived short name. Git identifies a working tree by its path — the worktree arg in git.json documents "Working trees can be identified by path, either relative or absolute", and git worktree lock/move/remove/unlock all operate on a path. git worktree list --porcelain reports absolute paths, so the inserted value always resolves. The checked-out branch (stripped of refs/heads/), or the bare/detached HEAD state, is surfaced as the suggestion description so the user can tell worktrees apart.

Design decision: exclude the main working tree, single generator

The main working tree is an invalid target for all four consuming subcommands — git worktree lock/unlock reject it outright and remove/move refuse it — so suggesting it would only ever produce a command that fails. git worktree list --porcelain always lists the main worktree first, so it is skipped. Because the four git worktree subcommands are the only consumers and all reject the main worktree, a single worktrees generator that excludes it is sufficient; a second "all worktrees" generator would be unreferenced dead code, so it was not added.

Verification

This is a spec/generator change validated by deterministic unit tests; there is no runnable UI in this repo, so no computer-use visual proof is applicable (the client that renders these suggestions lives elsewhere).

  • Regression tests in git.rs over real git worktree list --porcelain output: test_post_process_worktrees (branch + detached linked worktrees, and an explicit assertion that the main worktree is absent), test_post_process_worktrees_bare (bare main excluded, linked kept), test_post_process_worktrees_only_main (main-only repo → no suggestions), test_post_process_worktrees_fatal_error (fatal short-circuit), test_worktrees_generator_command (asserts the porcelain command).
  • The repo invariant test all_referenced_generators_exist confirms the new generatorName: "worktrees" references in git.json resolve to a defined generator, and all_command_specs_succeed_deserialization confirms the JSON still parses.
  • ./script/presubmit passes end to end: npm run format:check, cargo fmt --check, cargo clippy … -D warnings, and cargo test (87 tests, 0 failures).

Context

Rework changes

  • Dropped the cd scope (requester objected): reverted command-signatures/json/cd.json, deleted command-signatures/src/generators/cd.rs, and removed its registration from generators/mod.rs. Attaching worktrees to the universal cd builtin would have shelled out to git worktree list on every cd completion anywhere, well beyond the issue's scope.
  • Excluded the main working tree (fixes the oz-for-oss review finding): the generator no longer suggests the main worktree, which the four git worktree subcommands all reject. Added test_post_process_worktrees_only_main and an in-test assertion that the main worktree is absent.

Originating thread: https://warpdev.slack.com/archives/C0BDQDW8V5E/p1785969286177199

Conversation: https://staging.warp.dev/conversation/b894be3e-b473-41a9-b2c9-b972048c4fa9
Run: https://oz.staging.warp.dev/runs/019fd491-856f-7b3b-bc44-504490833074

This PR was generated with Oz.

Add a `worktrees` generator sourced from `git worktree list --porcelain`
that surfaces the repo's known working trees, inserting each worktree's
path (git identifies a working tree by its path) with the checked-out
branch or bare/detached state as the description.

Wire it into the `worktree` args of `git worktree lock/move/remove/unlock`
and into `cd` so worktree dirs surface alongside folder completion.

Closes GH-11542.

Co-Authored-By: Warp <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 Opened by the Warp factory agents label Aug 6, 2026
@warp-agent-staging
warp-agent-staging Bot marked this pull request as ready for review August 6, 2026 01:04
@warp-agent-staging
warp-agent-staging Bot requested a review from acarl005 August 6, 2026 01:04
@oz-for-oss

oz-for-oss Bot commented Aug 6, 2026

Copy link
Copy Markdown

@warp-agent-staging[bot]

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

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

Choose a reason for hiding this comment

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

Overview

Adds dynamic git worktree completions for git worktree subcommands and cd, backed by git worktree list --porcelain, with unit coverage for parsing and command construction.

Concerns

  • The shared worktree generator emits the main worktree, but the newly wired git worktree lock, move, remove, and unlock arguments cannot operate on the main worktree path, so the first suggested completion is invalid for those commands.

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

Comment thread command-signatures/src/generators/git.rs Outdated
Scope trim + review fix on the same PR:
- Revert cd.json and delete the cd generator (src/generators/cd.rs + its
  mod.rs registration). The worktrees suggestions were being bolted onto
  the universal `cd` builtin, shelling out to git on every cd completion.
- Exclude the main working tree from the worktrees generator. The main
  worktree is an invalid target for git worktree lock/unlock/move/remove
  (the only consumers), so suggesting it always produced a failing command.
  git worktree list --porcelain lists the main worktree first, so it is
  skipped. Added a regression test asserting its absence.

The git worktree lock/move/remove/unlock wiring in json/git.json is
unchanged.

Co-Authored-By: Warp <agent@warp.dev>
@acarl005
acarl005 merged commit a520a43 into main Aug 6, 2026
8 checks passed
@acarl005
acarl005 deleted the factory/git-worktree-completions branch August 6, 2026 01:22
acarl005 pushed a commit to warpdotdev/warp that referenced this pull request Aug 6, 2026
## Summary

Bumps the `warp-command-signatures` git dependency in `warpdotdev/warp`
from `4990fa1d` to `4094b657` (current
`warpdotdev/command-signatures:main`), so the client picks up
newly-merged completion specs.

Merged completion PRs now included:
- Add completion spec: Yandex Cloud CLI (`yc`) —
warpdotdev/command-signatures#303
- Add git worktree name autocomplete suggestions —
warpdotdev/command-signatures#302

This is the app-side half of APP-5201: the `yc` completion spec merged
upstream in command-signatures#303, and this PR wires that spec into the
app by advancing the embedded-signatures dependency. Only `Cargo.toml`
(the `rev`) and `Cargo.lock` (the two git-source lines for
`warp-command-signatures` / `warp-completion-metadata`) change.

The bump was produced by following the command-signatures repo's own
`update-command-spec-version` skill (update the `rev`, sync
`Cargo.lock`).

## Verification

Testing-exempt category: **dependency/version bump**. Per
factory-verification, a data-only dependency bump adds no regression
test (a test would only assert data presence, not detect a logic
defect); the `yc` spec itself is validated by command-signatures#303's
own CI, which passed before merge.

App-side checks (run against the new rev, `CARGO_TARGET_DIR` redirected
in the sandbox):
- `cargo check --locked -p warp_completer` → success. `--locked` proves
`Cargo.lock` is in sync with the new rev; the consuming crate compiles
against the updated specs.
- `cargo test --locked -p warp_completer -- signatures::` → 12 passed /
0 failed. These load and validate the embedded command signatures
(including the new `yc` spec).
- Full `cargo test --locked -p warp_completer` → 138 passed / 25 failed.
All 25 failures are a pre-existing, environmental test-harness issue
unrelated to this change — `Tried to check
FeatureFlag::CloudEnvironments before feature flags were initialized`
(`crates/warp_features/src/lib.rs`) — not caused by the dependency bump.

No Rust source files change in this PR, so there is nothing for
`./script/format` or `clippy` to act on beyond the compile above.

User-facing note: the `yc` completion menu rendering from this exact
spec was already demonstrated in a prior local GUI build against the
spec branch; because this PR is a data-only dependency bump (no client
code change), the GUI was not rebuilt for it. The rendering behavior is
governed entirely by the upstream spec, which is validated by
command-signatures#303.

CHANGELOG-IMPROVEMENT: Added inline command completions for the Yandex
Cloud CLI (`yc`) and git worktree name suggestions.

Originating thread:
https://warpdev.slack.com/archives/C0BDQDW8V5E/p1785974187380919
<!-- factory-agent:
{"source":"factory-agent","task_id":"APP-5201","task_source":"linear","task_url":"https://linear.app/warpdotdev/issue/APP-5201/add-yc-yandex-cloud-cli-command-completions","linear_issue_id":"APP-5201","oz_run_id":"019fd4c1-7a3e-70e0-bcec-c9f12606fd8a","repo":"warpdotdev/warp"}
-->

Co-authored-by: Oz <oz-agent@warp.dev>
Co-authored-by: Warp <agent@warp.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed warpy-factory Opened by the Warp factory agents

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants