feat(penpal): live-detect worktree additions and removals#548
Draft
feat(penpal): live-detect worktree additions and removals#548
Conversation
Watch each project's .git/worktrees/ directory so that `git worktree add` and `git worktree remove` are detected without restarting the server. On change, full re-discovery runs and an SSE event pushes the updated worktree list to the frontend. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
Previously, Penpal discovered git worktrees once at startup and never refreshed the list. If you ran
git worktree addorgit worktree removewhile Penpal was running, the sidebar's worktree list went stale — showing deleted worktrees and missing new ones.Now, Penpal watches each project's
.git/worktrees/directory for filesystem changes. When a worktree is added or removed, the worktree list updates automatically and the sidebar reflects the change within moments — no restart needed.discovery/worktree.go— NewGitWorktreesDir()resolves the.git/worktrees/metadata directory viagit rev-parse --git-common-dir, working for both main and linked worktreeswatcher/watcher.go— Base watches now include.git/worktrees/dirs; events there trigger full re-discovery and an SSE broadcast so the frontend picks up the change🤖 Generated with Claude Code