Skip to content

Load existing worktrees from .quick-pr-studio/worktrees on extension startup #19

@SunYanbox

Description

@SunYanbox

Problem

Currently, worktrees created manually or from outside the extension are not recognized by Quick PR Studio. When the extension starts, it only shows worktrees that were previously tracked in worktrees.json. If the .quick-pr-studio/worktrees/ directory contains worktree directories (created manually or left over from a previous session), they remain invisible in the sidebar.

Proposed Solution

On extension activation, scan the <project-root>/.quick-pr-studio/worktrees/ directory and register any existing worktrees that are not already tracked in worktrees.json. This ensures:

  • Worktrees created outside the extension (e.g., via CLI) appear in the sidebar
  • Worktrees from a prior session are automatically recovered, even if worktrees.json was lost or corrupted
  • Consistent state between disk and the extension's tracking metadata

Implementation Notes

  • Use git worktree list to verify each directory under .quick-pr-studio/worktrees/ is still a valid git worktree
  • Add only valid worktrees to the worktree manager
  • Log a warning for any directories that exist but are no longer valid worktrees
  • This should happen during extension activation, after the worktree manager is initialized

Acceptance Criteria

  • On startup, all valid worktrees in .quick-pr-studio/worktrees/ are loaded and visible in the sidebar
  • Invalid/stale directories are skipped with a warning log
  • No duplicate entries if a worktree is already tracked in worktrees.json

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