fix: strip linked-worktree '+' marker from branch picker (#9170)#9560
fix: strip linked-worktree '+' marker from branch picker (#9170)#9560lonexreb wants to merge 2 commits intowarpdotdev:masterfrom
Conversation
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
|
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 |
|
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 Powered by Oz |
There was a problem hiding this comment.
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
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
| 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), |
There was a problem hiding this comment.
nit: i think we don't need to make this change + don't need to change the function signature below on line 618
|
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: |
|
Thanks @moirahuang! Updated the
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.
|
Pushed 6540f0e addressing the nit on
Net diff vs. master is now just the one-line |
|
@lonexreb Appreciate you updating! Instead of deleting the tests, I think we should be able to follow |
|
Heads up: this PR strips the |
|
@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 |
|
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 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! |
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 branchprefixes each line with one of three markers:*+filter_git_branch_on_click_valuesinapp/src/context_chips/current_prompt.rswas stripping only the*marker. When a user clicked a+-prefixed entry, the value (still containing the+) was passed straight intoformat!("git checkout {branch_name}"), producing:which fails:
(matching the screenshots in the bug report exactly).
Change
Single-line behavioral fix:
The function is also converted from
&selfto an associatedfn(it never usedself) so it can be tested directly without spinning up a fullCurrentPromptmodel. The single caller is updated fromself.toSelf::.A
+-marked branch is one that's already checked out in another worktree; runninggit checkouton 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— fullgit branchsample (*,+, space) verified end-to-end including sort order.filter_git_branch_passes_through_none—Noneinput returnsNone.filter_git_branch_drops_blank_lines— pre-existing behavior is preserved.cargo fmt -- --checkclean. (Local clippy/nextest were not run — repo'sscript/presubmitrequires the full Xcode metal compiler for thewarpuibuild, which the local sandbox blocks. Relying on CI for full presubmit verification.)Server API dependencies
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!