diff --git a/src/commands.ts b/src/commands.ts index e807226a7f..520763eff3 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -226,7 +226,7 @@ export function registerCommands( if (activePullRequests.length >= 1) { const result = await chooseItem( activePullRequests, - itemValue => itemValue.html_url, + itemValue => ({ label: itemValue.html_url }), ); if (result) { openPullRequestOnGitHub(result, telemetry); @@ -263,7 +263,7 @@ export function registerCommands( ? ( await chooseItem( activePullRequestsWithFolderManager, - itemValue => itemValue.activePr.html_url, + itemValue => ({ label: itemValue.activePr.html_url }), ) ) : activePullRequestsWithFolderManager[0]; @@ -442,7 +442,7 @@ export function registerCommands( } return chooseItem( reviewsManager.reviewManagers, - itemValue => pathLib.basename(itemValue.repository.rootUri.fsPath), + itemValue => ({ label: pathLib.basename(itemValue.repository.rootUri.fsPath) }), { placeHolder: vscode.l10n.t('Choose a repository to create a pull request in'), ignoreFocusOut: true }, ); } @@ -794,7 +794,7 @@ export function registerCommands( pullRequestModel = await chooseItem(reposManager.folderManagers .map(folderManager => folderManager.activePullRequest!) .filter(activePR => !!activePR), - itemValue => `${itemValue.number}: ${itemValue.title}`, + itemValue => ({ label: `${itemValue.number}: ${itemValue.title}` }), { placeHolder: vscode.l10n.t('Choose the pull request to exit') }); } else { pullRequestModel = pr; @@ -932,7 +932,7 @@ export function registerCommands( if (activePullRequests.length >= 1) { issueModel = await chooseItem( activePullRequests, - itemValue => itemValue.title, + itemValue => ({ label: itemValue.title }), ); } } else { @@ -1610,7 +1610,7 @@ ${contents} .filter(activePR => !!activePR); pr = await chooseItem( activePullRequests, - itemValue => `${itemValue.number}: ${itemValue.title}`, + itemValue => ({ label: `${itemValue.number}: ${itemValue.title}` }), { placeHolder: vscode.l10n.t('Pull request to create a link for') }, ); } @@ -1666,7 +1666,7 @@ ${contents} } const githubRepo = await chooseItem<{ manager: FolderRepositoryManager, repo: GitHubRepository }>( githubRepositories, - itemValue => `${itemValue.repo.remote.owner}/${itemValue.repo.remote.repositoryName}`, + itemValue => ({ label: `${itemValue.repo.remote.owner}/${itemValue.repo.remote.repositoryName}` }), { placeHolder: vscode.l10n.t('Which GitHub repository do you want to checkout the pull request from?') } ); if (!githubRepo) { @@ -1702,7 +1702,7 @@ ${contents} }); return chooseItem( githubRepositories, - itemValue => `${itemValue.remote.owner}/${itemValue.remote.repositoryName}`, + itemValue => ({ label: `${itemValue.remote.owner}/${itemValue.remote.repositoryName}` }), { placeHolder: vscode.l10n.t('Which GitHub repository do you want to open?') } ); } @@ -1926,7 +1926,7 @@ ${contents} const pr = await chooseItem( activePullRequests, - itemValue => `${itemValue.number}: ${itemValue.title}`, + itemValue => ({ label: `${itemValue.number}: ${itemValue.title}` }), { placeHolder: vscode.l10n.t('Pull request to create a link for') }, ); if (pr) { diff --git a/src/github/copilotRemoteAgent.ts b/src/github/copilotRemoteAgent.ts index 9736b2c5ee..d98b7c8108 100644 --- a/src/github/copilotRemoteAgent.ts +++ b/src/github/copilotRemoteAgent.ts @@ -426,7 +426,7 @@ export class CopilotRemoteAgentManager extends Disposable { private chooseFolderManager(): Promise { return chooseItem( this.repositoriesManager.folderManagers, - itemValue => pathLib.basename(itemValue.repository.rootUri.fsPath), + itemValue => ({ label: pathLib.basename(itemValue.repository.rootUri.fsPath) }), ); } @@ -461,7 +461,7 @@ export class CopilotRemoteAgentManager extends Disposable { const result = await chooseItem( ghRemotes, - itemValue => `${itemValue.remoteName} (${itemValue.owner}/${itemValue.repositoryName})`, + itemValue => ({ label: itemValue.remoteName, description: `(${itemValue.owner}/${itemValue.repositoryName})` }), { title: vscode.l10n.t('Coding agent will create pull requests against the selected remote.'), } @@ -665,6 +665,8 @@ export class CopilotRemoteAgentManager extends Disposable { summary, undefined, autoPushAndCommit, + undefined, + fm ); if (result.state !== 'success') { @@ -728,7 +730,7 @@ export class CopilotRemoteAgentManager extends Disposable { return vscode.l10n.t('🚀 Coding agent will continue work in [#{0}]({1}). Track progress [here]({2}).', number, link, webviewUri.toString()); } - async invokeRemoteAgent(prompt: string, problemContext?: string, token?: vscode.CancellationToken, autoPushAndCommit = true, chatStream?: vscode.ChatResponseStream): Promise { + async invokeRemoteAgent(prompt: string, problemContext?: string, token?: vscode.CancellationToken, autoPushAndCommit = true, chatStream?: vscode.ChatResponseStream, fm?: FolderRepositoryManager): Promise { const capiClient = await this.copilotApi; if (!capiClient) { return { error: vscode.l10n.t('Failed to initialize Copilot API. Please try again later.'), state: 'error' }; @@ -736,7 +738,7 @@ export class CopilotRemoteAgentManager extends Disposable { await this.promptAndUpdatePreferredGitHubRemote(true); - const repoInfo = await this.repoInfo(); + const repoInfo = await this.repoInfo(fm); if (!repoInfo) { return { error: vscode.l10n.t('No repository information found. Please open a workspace with a GitHub repository.'), state: 'error' }; } @@ -1108,7 +1110,16 @@ export class CopilotRemoteAgentManager extends Disposable { const uri = await toOpenPullRequestWebviewUri({ owner: pullRequest.remote.owner, repo: pullRequest.remote.repositoryName, pullRequestNumber: pullRequest.number }); const prLinkTitle = vscode.l10n.t('Open pull request in VS Code'); - const description = new vscode.MarkdownString(`[#${pullRequest.number}](${uri.toString()} "${prLinkTitle}")`); // pullRequest.base.ref === defaultBranch ? `PR #${pullRequest.number}`: `PR #${pullRequest.number} → ${pullRequest.base.ref}`; + + // If we have multiple repositories, include the repo name in the link text + // e.g., 'owner/repo #123' instead of just '#123' + let repoInfo = ''; + if (this.repositoriesManager.folderManagers.length > 1) { + const owner = pullRequest.remote.owner; + const repo = pullRequest.remote.repositoryName; + repoInfo = `${owner}/${repo} `; + } + const description = new vscode.MarkdownString(`[${repoInfo}#${pullRequest.number}](${uri.toString()} "${prLinkTitle}")`); // pullRequest.base.ref === defaultBranch ? `PR #${pullRequest.number}`: `PR #${pullRequest.number} → ${pullRequest.base.ref}`; return { id: `${pullRequest.number}`, label: pullRequest.title || `Session ${pullRequest.number}`, diff --git a/src/github/quickPicks.ts b/src/github/quickPicks.ts index 75717beb6d..78e723db45 100644 --- a/src/github/quickPicks.ts +++ b/src/github/quickPicks.ts @@ -20,7 +20,7 @@ import { formatError } from '../common/utils'; export async function chooseItem( itemsToChooseFrom: T[], - propertyGetter: (itemValue: T) => string, + propertyGetter: (itemValue: T) => { label: string; description?: string; }, options?: vscode.QuickPickOptions, ): Promise { if (itemsToChooseFrom.length === 0) { @@ -34,7 +34,7 @@ export async function chooseItem( } const items: Item[] = itemsToChooseFrom.map(currentItem => { return { - label: propertyGetter(currentItem), + ...propertyGetter(currentItem), itemValue: currentItem, }; });