microsoft/vscode · error · Error

No active repository found to delete worktree.

Error message

No active repository found to delete worktree.

What it means

Error "No active repository found to delete worktree." thrown in microsoft/vscode.

Source

Thrown at extensions/copilot/src/extension/chatSessions/vscode-node/copilotCLIChatSessionsContribution.ts:2225

			metadataStore,
			copilotCliWorkspaceSession,
		);
		return siblings.length > 0;
	}
	async function deleteSessionById(sessionId: string, options?: { keepWorktree?: boolean; sessionLabel?: string }): Promise<void> {
		const worktree = await copilotCLIWorktreeManagerService.getWorktreeProperties(sessionId);
		const worktreePath = await copilotCLIWorktreeManagerService.getWorktreePath(sessionId);

		await copilotCLISessionService.deleteSession(sessionId);
		await copilotCliWorkspaceSession.deleteTrackedWorkspaceFolder(sessionId);

		if (worktreePath && !options?.keepWorktree) {
			const worktreeExists = await fileSystemService.stat(worktreePath).then(() => true, () => false);
			if (worktreeExists) {
				try {
					const repository = worktree ? await gitService.getRepository(vscode.Uri.file(worktree.repositoryPath), true) : undefined;
					if (!repository) {
						throw new Error(l10n.t('No active repository found to delete worktree.'));
					}
					await gitService.deleteWorktree(repository.rootUri, worktreePath.fsPath, { label: options?.sessionLabel });
				} catch (error) {
					vscode.window.showErrorMessage(l10n.t('Failed to delete worktree: {0}', error instanceof Error ? error.message : String(error)));
				}
			}
		}
	}
	disposableStore.add(vscode.commands.registerCommand('github.copilot.cli.sessions.delete', async (sessionItem?: vscode.ChatSessionItem) => {
		if (sessionItem?.resource) {
			const id = SessionIdForCLI.parse(sessionItem.resource);
			const sessionId = copilotcliSessionItemProvider.untitledSessionIdMapping.get(id) ?? id;
			const worktreePath = await copilotCLIWorktreeManagerService.getWorktreePath(sessionId);
			const keepWorktree = !!worktreePath && await shouldKeepWorktreeForOtherSessions(sessionId, worktreePath);

			const confirmMessage = (worktreePath && !keepWorktree)
				? l10n.t('Are you sure you want to delete the session and its associated worktree?')
				: l10n.t('Are you sure you want to delete the session?');

View on GitHub (pinned to a94b963a32)

When it happens

Trigger: Thrown at extensions/copilot/src/extension/chatSessions/vscode-node/copilotCLIChatSessionsContribution.ts:2225 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of microsoft/vscode@a94b963a32 (2026-08-12). Data as JSON: /api/errors/d41ac0431a1ac305. Report an issue: GitHub.