Skip to content

Commit 087126b

Browse files
authored
Agents - use "agents" in the worktree branch/folder name (#308811)
1 parent 16be183 commit 087126b

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

extensions/copilot/src/extension/chatSessions/vscode-node/chatSessionWorktreeServiceImpl.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,11 @@ export class ChatSessionWorktreeService extends Disposable implements IChatSessi
125125
}
126126

127127
private async generateBranchName(preferredName: string | undefined, repository: RepoContext) {
128-
const branchPrefix = vscode.workspace.getConfiguration('git').get<string>('branchPrefix') ?? '';
128+
const branchPrefixConfig = vscode.workspace.getConfiguration('git').get<string>('branchPrefix') ?? '';
129+
const branchPrefix = this.agentSessionsWorkspace.isAgentSessionsWorkspace ? 'agents' : 'copilot';
129130

130131
if (preferredName) {
131-
let branchName = `${branchPrefix}copilot/${preferredName}`;
132+
let branchName = `${branchPrefixConfig}${branchPrefix}/${preferredName}`;
132133
// Check if we already have a branch with the preferred name, and if not, then use it.
133134
// Else suffix the preferred name with a random string to avoid conflicts.
134135
const refs = await this.gitService.getRefs(repository.rootUri, { pattern: `refs/heads/${branchName}` });
@@ -142,8 +143,8 @@ export class ChatSessionWorktreeService extends Disposable implements IChatSessi
142143
// Attempt to generate a random branch name for the worktree
143144
const randomBranchName = await this.gitService.generateRandomBranchName(repository.rootUri);
144145

145-
const branch = randomBranchName ? `${branchPrefix}copilot/${randomBranchName.substring(branchPrefix.length)}`
146-
: `${branchPrefix}copilot/worktree-${new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19)}`;
146+
const branch = randomBranchName ? `${branchPrefixConfig}${branchPrefix}/${randomBranchName.substring(branchPrefixConfig.length)}`
147+
: `${branchPrefixConfig}${branchPrefix}/worktree-${new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19)}`;
147148

148149
return branch;
149150
}

extensions/git/src/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,5 +868,5 @@ export function getStashDescription(stash: Stash): string | undefined {
868868
}
869869

870870
export function isCopilotWorktreeFolder(path: string): boolean {
871-
return basename(path).startsWith('copilot-');
871+
return basename(path).startsWith('copilot-') || basename(path).startsWith('agents-');
872872
}

0 commit comments

Comments
 (0)