Skip to content

fix: strip linked-worktree '+' marker from branch picker (#9170)#9560

Open
lonexreb wants to merge 2 commits intowarpdotdev:masterfrom
lonexreb:fix/9170-strip-worktree-marker-from-branch-picker
Open

fix: strip linked-worktree '+' marker from branch picker (#9170)#9560
lonexreb wants to merge 2 commits intowarpdotdev:masterfrom
lonexreb:fix/9170-strip-worktree-marker-from-branch-picker

Conversation

@lonexreb
Copy link
Copy Markdown
Contributor

@lonexreb lonexreb commented Apr 30, 2026

Description

Fixes #9170.

The shell git-branch chip in the prompt input shows a list of branches that the user can click to run git checkout <branch>. The chip's data source is the porcelain output of:

git --no-optional-locks branch --no-color --sort=-committerdate

git branch prefixes each line with one of three markers:

Marker Meaning
* Branch checked out in this worktree
+ Branch checked out in another linked worktree
(space) Every other branch

filter_git_branch_on_click_values in app/src/context_chips/current_prompt.rs was stripping only the * marker. When a user clicked a +-prefixed entry, the value (still containing the +) was passed straight into format!("git checkout {branch_name}"), producing:

git checkout + 273-improvement-suggestion-agent

which fails:

error: pathspec '+' did not match any file(s) known to git
error: pathspec '273-improvement-suggestion-agent' did not match any file(s) known to git

(matching the screenshots in the bug report exactly).

Change

Single-line behavioral fix:

- .map(|s| s.trim_start_matches('*').trim().to_string())
+ .map(|s| s.trim_start_matches(['*', '+']).trim().to_string())

The function is also converted from &self to an associated fn (it never used self) so it can be tested directly without spinning up a full CurrentPrompt model. The single caller is updated from self. to Self::.

A +-marked branch is one that's already checked out in another worktree; running git checkout on it from the current worktree will still surface git's own (more meaningful) error. This change just stops Warp from generating a malformed command before git ever sees it.

Testing

Added five unit tests in app/src/context_chips/current_prompt_test.rs:

  • filter_git_branch_strips_star_marker — pre-existing behavior is preserved.
  • filter_git_branch_strips_plus_marker_for_linked_worktrees — explicit regression for Branch picker includes linked-worktree '+' marker in git checkout #9170, with a final assert that no value retains a leading + or *.
  • filter_git_branch_handles_mixed_marker_set — full git branch sample (*, +, space) verified end-to-end including sort order.
  • filter_git_branch_passes_through_noneNone input returns None.
  • filter_git_branch_drops_blank_lines — pre-existing behavior is preserved.

cargo fmt -- --check clean. (Local clippy/nextest were not run — repo's script/presubmit requires the full Xcode metal compiler for the warpui build, which the local sandbox blocks. Relying on CI for full presubmit verification.)

Server API dependencies

  • Is this change necessary to make the client compatible with a desired server API breaking change? — No, client-only.

Agent Mode

  • Warp Agent Mode

Changelog Entries for Stable

CHANGELOG-BUG-FIX: Fixed branch picker generating an invalid git checkout + <branch> command for branches checked out in another linked git worktree. Thanks @lonexreb and @tkshsbcue!

The shell git-branch chip's data source is `git --no-optional-locks
branch --no-color --sort=-committerdate`, whose porcelain output marks
each branch with one of three leading characters:

  *  the branch checked out in this worktree
  +  a branch checked out in another linked worktree
  (space) every other branch

`filter_git_branch_on_click_values` only stripped the `*` marker. When a
user clicked a `+`-prefixed entry, the value `"+ 273-improvement-suggestion-agent"`
was passed verbatim into `format!("git checkout {branch_name}")`, producing:

    git checkout + 273-improvement-suggestion-agent

…which fails with `pathspec '+' did not match any file(s) known to git`.

This change extends the marker-stripping to also drop `+`, so users with
linked-worktree repos can pick those branches from the chip. A `+`-marked
branch is one that's already checked out in another worktree; `git checkout`
on it from this worktree will still produce its own (more meaningful) error,
which preserves the existing UX surface for that case while unblocking the
common scenario of selecting any other `+`-prefixed branch.

Also makes `filter_git_branch_on_click_values` an associated function — it
never used `self` — to allow direct unit testing without spinning up a full
`CurrentPrompt` model. Adds tests covering the `*` and `+` markers, mixed
sorting/ordering, blank-line filtering, and the `None` pass-through.

Closes warpdotdev#9170
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 30, 2026

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @lonexreb on file. In order for us to review and merge your code, each contributor must visit https://cla.warp.dev to read and agree to our CLA. Once you have done so, please comment @cla-bot check to trigger another check.

@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented Apr 30, 2026

@lonexreb

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

You can view the conversation on Warp.

I reviewed this pull request and requested human review from: @moirahuang.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

Overview

This PR updates git branch chip normalization so linked-worktree entries prefixed by Git's + marker are passed through as raw branch names instead of producing malformed git checkout + <branch> commands. It also adds focused unit coverage for *, +, mixed marker sets, blank lines, and None input.

Concerns

  • No blocking correctness or security concerns found in the changed lines.

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

@oz-for-oss oz-for-oss Bot requested a review from moirahuang April 30, 2026 07:33
@lonexreb
Copy link
Copy Markdown
Contributor Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed label Apr 30, 2026
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Apr 30, 2026

The cla-bot has been summoned, and re-checked this pull request!

@captainsafia captainsafia added the external-contributor Indicates that a PR has been opened by someone outside the Warp team. label Apr 30, 2026 — with Warp Dev Github Integration
fn update_on_click_value(&mut self, chip_kind: &ContextChipKind, value: Option<Vec<String>>) {
log::debug!("Updating prompt on_click value of {chip_kind:?} to {value:?}");
let filter_values = match chip_kind {
ContextChipKind::ShellGitBranch => self.filter_git_branch_on_click_values(value),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: i think we don't need to make this change + don't need to change the function signature below on line 618

@moirahuang
Copy link
Copy Markdown
Contributor

thank you for making this PR! mind updating the changelog to give yourself and also @tkshsbcue attribution? they had also made a PR for this issue but i prefer your implementation. more context:
#9440 (comment)

@lonexreb
Copy link
Copy Markdown
Contributor Author

Thanks @moirahuang! Updated the CHANGELOG-BUG-FIX line to credit both myself and @tkshsbcue:

CHANGELOG-BUG-FIX: Fixed branch picker generating an invalid git checkout + <branch> command for branches checked out in another linked git worktree. Thanks @lonexreb and @tkshsbcue!

Happy to adjust the wording if you'd prefer a different attribution format.

@moirahuang
Copy link
Copy Markdown
Contributor

Thanks @moirahuang! Updated the CHANGELOG-BUG-FIX line to credit both myself and @tkshsbcue:

CHANGELOG-BUG-FIX: Fixed branch picker generating an invalid git checkout + <branch> command for branches checked out in another linked git worktree. Thanks @lonexreb and @tkshsbcue!

Happy to adjust the wording if you'd prefer a different attribution format.

Thank you for making the change! Please address this nit and then I will merge the PR in!

moirahuang asked to revert the conversion of
`filter_git_branch_on_click_values` from `&self` instance method to an
associated function (call-site at line 357 plus signature change at
line 618). Restoring the original signature and the original
`self.filter_git_branch_on_click_values(value)` call site.

Drops the five unit tests added in this branch that depended on the
associated-function form (constructing a `CurrentPrompt` purely for a
unit test would require wiring `Sessions`, `ModelContext`, and
`ModelHandle` plumbing — out of scope for this fix). The behavioral
fix is the one-line `trim_start_matches(['*', '+'])` change plus the
comment documenting the three `git branch` marker variants, which is
what the issue actually required.
@lonexreb
Copy link
Copy Markdown
Contributor Author

Pushed 6540f0e addressing the nit on current_prompt.rs:357.

  • Restored the original self.filter_git_branch_on_click_values(value) call site at line 357.
  • Restored the original fn filter_git_branch_on_click_values(&self, ...) signature on the impl.
  • Dropped the five unit tests I had added in this branch — they depended on the associated-function form. Constructing a CurrentPrompt purely for a unit test of this helper would require wiring Sessions / ModelContext / ModelHandle plumbing, which felt out of scope for this fix.

Net diff vs. master is now just the one-line .trim_start_matches(['*', '+']) change plus the explanatory comment about the three git branch markers — the actual behavioral change requested in #9170. Ready when you are.

@moirahuang
Copy link
Copy Markdown
Contributor

@lonexreb Appreciate you updating! Instead of deleting the tests, I think we should be able to follow test_context_menu_items as an example and still construct current_prompt

@unrevised6419
Copy link
Copy Markdown

Heads up: this PR strips the + marker but the underlying checkout will still fail because the branch is already used by a linked worktree (fatal: '<branch>' is already checked out at ...). See #9170 (comment) for details and suggested fixes.

@moirahuang
Copy link
Copy Markdown
Contributor

@lonexreb FYI the PR #9905 (review) is a more complete solution (thanks @unrevised6419 for this comment!). I've asked them to give you attribution in the CHANGELOG

@lonexreb
Copy link
Copy Markdown
Contributor Author

lonexreb commented May 5, 2026

Thanks @moirahuang and @unrevised6419 — totally agree #9905 is the right call. @unrevised6419's point is correct: stripping the marker only fixes the cosmetic side; the underlying git checkout still fails on a branch that's already in a linked worktree. #9905's approach (handling the worktree case proper) is the complete fix.

Happy to close this one in favor of #9905. The CHANGELOG attribution offer is appreciated but absolutely not necessary — go with whatever feels right.

@moirahuang
Copy link
Copy Markdown
Contributor

Thanks @moirahuang and @unrevised6419 — totally agree #9905 is the right call. @unrevised6419's point is correct: stripping the marker only fixes the cosmetic side; the underlying git checkout still fails on a branch that's already in a linked worktree. #9905's approach (handling the worktree case proper) is the complete fix.

Happy to close this one in favor of #9905. The CHANGELOG attribution offer is appreciated but absolutely not necessary — go with whatever feels right.

Thank you going to close this one!

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

Labels

cla-signed external-contributor Indicates that a PR has been opened by someone outside the Warp team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Branch picker includes linked-worktree '+' marker in git checkout

4 participants