Skip to content

feat: auto-discover and register worktrees from .quick-pr-studio/worktrees directory #31

@SunYanbox

Description

@SunYanbox

Summary

Currently, the plugin only tracks worktrees that are explicitly registered in .quick-pr-studio/worktrees.json via the "Start Step-by-Step PR" workflow. Worktrees created manually (e.g., via git worktree add in .quick-pr-studio/worktrees/) are not visible in the sidebar since there is no auto-discovery mechanism.

Proposed Feature

Automatically discover git worktrees inside .quick-pr-studio/worktrees/ and register them in worktrees.json so they appear in the sidebar TreeView.

Triggers

  1. On extension activation — Scan .quick-pr-studio/worktrees/ for git worktrees and add any unregistered ones to the registry.
  2. Periodic refresh — A timer (e.g., every 30-60 seconds) or a debounced watcher on the worktrees directory to pick up newly created worktrees.

Details

  • When a worktree directory is found in .quick-pr-studio/worktrees/<name>/ but has no corresponding entry in worktrees.json, create a WorktreeInfo entry for it with reasonable defaults:
    • id: derived from the directory/branch name
    • branchName: extracted from the worktree's git branch
    • worktreePath: the full path
    • status: created (default)
    • Other fields populated with sensible defaults or left empty
  • When a worktree directory is removed but still exists in worktrees.json, optionally clean up the stale entry.
  • The periodic timer should be efficient — avoid excessive filesystem scanning (e.g., check mtime on the directory before re-scanning).

Why

This makes the sidebar consistent with the actual state of worktrees on disk, and allows users to manage manually-created worktrees through the plugin UI (commit, finalize, delete).

Files to Modify

  • src/worktreeManager.ts — Add a discoverWorktrees() function that scans .quick-pr-studio/worktrees/ and merges unregistered entries
  • src/extension.ts — Call discoverWorktrees() on activation and set up a periodic timer

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions