fix(worktree-overlay): refresh list after removing a worktree #185
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.
Summary
Problem
After removing a worktree via the overlay UI, the removed worktree remained visible in the list until the overlay was closed and reopened.
The root cause: the foreground process detection is cached at 150ms intervals and often missed the quick
git worktree removecommand, so the automatic refresh (triggered when a foreground process completes) was never invoked.Solution
Added a delayed refresh mechanism that schedules a worktree list refresh 500ms after confirming removal:
pending_refresh_msfield to track when a delayed refresh should occurworktree_removal_refresh_delay_msconstant (500ms)handleRemoveModalClick, after emitting the remove action, set the pending refresh timeupdate(), check if the pending refresh time has passed and trigger the refreshThis ensures the worktree list updates after the git command has had time to complete, without relying on foreground process detection which can miss fast commands.
Test plan