Skip to content

Conversation

@forketyfork
Copy link
Owner

Summary

  • Fix worktree overlay not refreshing after removing a worktree

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 remove command, 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:

  1. Added pending_refresh_ms field to track when a delayed refresh should occur
  2. Added worktree_removal_refresh_delay_ms constant (500ms)
  3. In handleRemoveModalClick, after emitting the remove action, set the pending refresh time
  4. In update(), check if the pending refresh time has passed and trigger the refresh

This 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

  • Open worktree overlay (Cmd+T)
  • Click × on a worktree to remove it
  • Confirm removal in the modal
  • Verify the worktree disappears from the list within ~500ms without needing to close/reopen the overlay

Issue: After removing a worktree via the overlay UI, the removed worktree
remained visible in the list until the overlay was closed and reopened.

Solution: The foreground process detection (cached at 150ms intervals) often
missed the quick `git worktree remove` command, so the automatic refresh was
never triggered. Added a delayed refresh mechanism that schedules a worktree
list refresh 500ms after confirming removal, ensuring the list updates after
the git command completes.
@forketyfork forketyfork requested a review from Copilot February 2, 2026 11:05
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where the worktree overlay UI didn't refresh after removing a worktree. The issue occurred because the foreground process detection cache (150ms intervals) often missed the quick git worktree remove command, preventing the automatic refresh from triggering.

Changes:

  • Added a delayed refresh mechanism (500ms) that triggers after worktree removal confirmation
  • Introduced tracking for pending refresh timing via pending_refresh_ms field
  • Added logic in update() to check and execute pending refreshes when their scheduled time arrives

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@forketyfork forketyfork merged commit 2cee841 into main Feb 2, 2026
4 checks passed
@forketyfork forketyfork deleted the fix/worktree-overlay-refresh-after-removal branch February 2, 2026 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants