Skip to content

git_ui: Resolve worktree picker remove-from-window clicks by path - #59084

Merged
MartinYe1234 merged 1 commit into
mainfrom
fix-worktree-picker-stale-index
Jun 16, 2026
Merged

git_ui: Resolve worktree picker remove-from-window clicks by path#59084
MartinYe1234 merged 1 commit into
mainfrom
fix-worktree-picker-stale-index

Conversation

@MartinYe1234

Copy link
Copy Markdown
Contributor

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_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 #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.

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 MartinYe1234 self-assigned this Jun 11, 2026
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jun 11, 2026
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label Jun 11, 2026
@MartinYe1234
MartinYe1234 marked this pull request as ready for review June 11, 2026 00:45
@MartinYe1234
MartinYe1234 requested a review from Anthony-Eid June 11, 2026 00:45
@MartinYe1234
MartinYe1234 added this pull request to the merge queue Jun 16, 2026
Merged via the queue into main with commit af7bdd5 Jun 16, 2026
44 checks passed
@MartinYe1234
MartinYe1234 deleted the fix-worktree-picker-stale-index branch June 16, 2026 02:35
This was referenced Jun 18, 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants