Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions extensions/git/src/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -957,11 +957,14 @@ export class Repository implements Disposable {
: new ThemeIcon('repo');

// Hidden
// This is a temporary solution to hide worktrees created by Copilot
// when the main repository is opened. Users can still manually open
// the worktree from the Repositories view.
this._isHidden = repository.kind === 'worktree' &&
isCopilotWorktree(repository.root) && parent !== undefined;
// This is a temporary solution to hide:
// * repositories in the empty window
// * worktrees created by Copilot when the main repository
// is opened. Users can still manually open the worktree
// from the Repositories view.
this._isHidden = workspace.workspaceFolders === undefined ||
(repository.kind === 'worktree' &&
isCopilotWorktree(repository.root) && parent !== undefined);
Comment on lines +965 to +967
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _isHidden property is only set once during repository initialization, but workspace.workspaceFolders can change dynamically during the VS Code session. This creates a bug where:

  1. If VS Code opens with no workspace folders (empty window), repositories will be hidden
  2. When a user later adds a workspace folder via "Add Folder to Workspace", the existing repositories remain hidden because _isHidden is never updated

The property needs to be made reactive to workspace folder changes. Consider one of these approaches:

  • Add a listener for workspace.onDidChangeWorkspaceFolders in the Repository constructor to update _isHidden
  • Make isHidden a computed getter that checks workspace.workspaceFolders dynamically
  • Dispose and recreate repositories when workspace folders change from empty to non-empty (or vice versa)

See below for a potential fix:

		const computeIsHidden = () => workspace.workspaceFolders === undefined ||
			(repository.kind === 'worktree' &&
				isCopilotWorktree(repository.root) && parent !== undefined);

		this._isHidden = computeIsHidden();

		const root = Uri.file(repository.root);
		this._sourceControl = scm.createSourceControl('git', 'Git', root, icon, this._isHidden, parent);
		this._sourceControl.contextValue = repository.kind;

		const workspaceFoldersListener = workspace.onDidChangeWorkspaceFolders(() => {
			const newIsHidden = computeIsHidden();
			if (newIsHidden === this._isHidden) {
				return;
			}
			this._isHidden = newIsHidden;
			this._sourceControl.hidden = this._isHidden;
		});
		this.disposables.push(workspaceFoldersListener);

Copilot uses AI. Check for mistakes.

const root = Uri.file(repository.root);
this._sourceControl = scm.createSourceControl('git', 'Git', root, icon, this._isHidden, parent);
Expand Down
6 changes: 5 additions & 1 deletion extensions/git/src/statusbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,17 @@ export class StatusBarCommands {
private checkoutStatusBar: CheckoutStatusBar;
private disposables: Disposable[] = [];

constructor(repository: Repository, remoteSourcePublisherRegistry: IRemoteSourcePublisherRegistry) {
constructor(private readonly repository: Repository, remoteSourcePublisherRegistry: IRemoteSourcePublisherRegistry) {
this.syncStatusBar = new SyncStatusBar(repository, remoteSourcePublisherRegistry);
this.checkoutStatusBar = new CheckoutStatusBar(repository);
this.onDidChange = anyEvent(this.syncStatusBar.onDidChange, this.checkoutStatusBar.onDidChange);
}

get commands(): Command[] {
if (this.repository.isHidden) {
return [];
}

return [this.checkoutStatusBar.command, this.syncStatusBar.command]
.filter((c): c is Command => !!c);
}
Expand Down
Loading