Skip to content

Copilot CLI agent panel: git worktree creation path defaults to inside workspace folder, causing silent duplicate loading in plugin-scan runtimes #316250

Open

Description

@FredFraiche

Environment:

  • VS Code Version: 1.120.0
  • Copilot Chat Extension: 0.41
  • OS: Windows 11 Home

Background:

When the Copilot CLI agent panel creates a git worktree (e.g. for a new branch session), it places the worktree as a sibling directory inside the current workspace folder. For most projects this is harmless. For projects that are themselves loaded by a runtime that recursively scans the workspace folder for plugins/modules — such as ComfyUI, which scans custom_nodes/ and loads every subdirectory with an __init__.py — this causes silent duplicate loading.

Steps to reproduce:

  1. Have a project structured as a runtime plugin (e.g. a ComfyUI custom node at custom_nodes/MyPlugin/)
  2. Open that folder as a VS Code workspace and launch the Copilot CLI agent panel
  3. The agent creates a worktree branch, placing it at custom_nodes/MyPlugin.worktrees/my-branch/
  4. The worktree contains __init__.py (inherited from the branch)
  5. Start the host runtime (ComfyUI)

Expected behavior:

The worktree is created outside the workspace folder — e.g. a sibling of the workspace root — so it is invisible to the runtime's plugin scanner. Or: the user is warned that the proposed worktree path falls inside a directory that may be scanned by a plugin loader, and offered an alternative path.

Actual behavior:

The worktree lands inside custom_nodes/, directly in the runtime's scan path. The runtime loads both the main plugin folder and the worktree as separate instances of the same plugin. First-registration wins for node classes and frontend JS files. Changes made in the worktree are silently overridden by the main repo version (or vice versa, depending on load order). The developer sees stale behavior and has no indication why — the duplicate is invisible in the runtime UI.

Why this matters:

This affects any project where:

  • The workspace root IS the plugin/module directory (not just a parent of it)
  • The host runtime scans recursively for entrypoints (__init__.py, package.json, index.js, etc.)
  • The developer uses the agent panel for branch-isolated dev work (the intended use case)

ComfyUI is one example. The pattern applies equally to VSCode extensions, pytest plugin directories, Poetry monorepos, Webpack multi-entry setups, and any other ecosystem where a recursive scan of a source directory drives runtime loading.

Proposed fix:

  • Default worktree creation path to one level above the workspace root (e.g. ../MyPlugin.worktrees/) rather than inside it
  • Or: allow the user to configure a default worktree base path in settings (copilot.agent.worktreeBasePath)
  • Or: at minimum, warn when the proposed worktree path is inside the workspace folder and the workspace contains an __init__.py, package.json, or similar runtime entrypoint at its root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

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