git_ui: Resolve worktree picker remove-from-window clicks by path - #59084
Merged
Conversation
The remove-worktree-from-window button captured the row index at render time and re-resolved it against picker matches at click time. Matches are rebuilt asynchronously, so the index could drift between frames and close the workspace of a different worktree than the one clicked. Capture the worktree's path instead, which stays a valid identity regardless of how matches are reordered, and re-check the deleting set at click time like the neighboring handlers do. Also construct the button only when it will actually be shown.
MartinYe1234
marked this pull request as ready for review
June 11, 2026 00:45
Anthony-Eid
approved these changes
Jun 16, 2026
This was referenced Jun 18, 2026
Closed
This was referenced Jul 1, 2026
This was referenced Jul 10, 2026
jolutz
pushed a commit
to jolutz/zed
that referenced
this pull request
Aug 8, 2026
…d-industries#59084) Follow-up to zed-industries#58996. The "Remove Worktree from Window" button captured the row index at render time and re-resolved it against the picker's matches at click time. Matches are rebuilt asynchronously (initial worktree list load, post-delete refresh, query changes), so the index could drift between the rendered frame and the click being processed, closing the workspace of a different worktree than the one the user clicked. This changes the click handler to capture the worktree's path — a stable identity — instead of its index, adds the same `deleting_worktree_paths` click-time guard the neighboring handlers use, and constructs the button only when it will actually be shown. Scoped to the code added in zed-industries#58996; the same stale-index pattern in the delete and open-in-new-window handlers is left for a later change. Release Notes: - Fixed an issue where the worktree picker's "Remove Worktree from Window" button could act on the wrong worktree if the list updated at the moment of the click.
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.
Follow-up to #58996. The "Remove Worktree from Window" button captured the row index at render time and re-resolved it against the picker's matches at click time. Matches are rebuilt asynchronously (initial worktree list load, post-delete refresh, query changes), so the index could drift between the rendered frame and the click being processed, closing the workspace of a different worktree than the one the user clicked.
This changes the click handler to capture the worktree's path — a stable identity — instead of its index, adds the same
deleting_worktree_pathsclick-time guard the neighboring handlers use, and constructs the button only when it will actually be shown.Scoped to the code added in #58996; the same stale-index pattern in the delete and open-in-new-window handlers is left for a later change.
Release Notes: