Skip to content

Stale worktree repo entry persists in PR sidebar after worktree removal #8525

@erdembircan

Description

@erdembircan

Bug Report

When a git worktree is created inside a repository's root folder and then removed, the PR sidebar retains a stale entry for that worktree. The refresh button does not clear it — only a full window reload removes it.

Additionally, active PRs stop showing under the main repo entry. Expanding sections like "All Open" or "Created By Me" returns nothing, even though open PRs exist. The PR list remains broken until a full window reload.

Steps to Reproduce

  1. Open a repository in VS Code
  2. Create a worktree inside the repo root (e.g., git worktree add worktrees/review-77 origin/task/75)
  3. The extension detects the worktree and adds a separate repo entry in the Pull Requests sidebar
  4. Remove the worktree (git worktree remove worktrees/review-77)
  5. Optionally remove the now-empty worktrees/ directory
  6. Click the Refresh button in the Pull Requests sidebar

Expected Behavior

  • The stale worktree entry should be removed from the sidebar after refresh
  • Active PRs should continue to show under the main repo entry

Actual Behavior

  • The stale entry remains in the sidebar
  • PRs stop appearing under the main repo — all categories show empty
  • Only Developer: Reload Window restores normal behavior

Context

This is related to the worktree handling introduced in #7896 / PR #7900. The fix correctly filters worktrees not in workspace folders, but repo detection appears to be cached for the lifetime of the window — removed worktrees are never evicted, and the presence of the stale entry breaks PR listing for the actual repository.

Environment

  • VS Code: latest
  • GitHub Pull Requests extension: latest (post-February 2026)
  • OS: macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions