From b65282b349c38caa7f201f36a82774d415b61a2c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Dec 2025 14:43:32 +0000 Subject: [PATCH 1/7] Initial plan From 2c12a464fab8358d58176030919256bf79bf0d94 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Dec 2025 14:49:39 +0000 Subject: [PATCH 2/7] Initial analysis complete Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> --- src/@types/vscode.proposed.chatParticipantAdditions.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/@types/vscode.proposed.chatParticipantAdditions.d.ts b/src/@types/vscode.proposed.chatParticipantAdditions.d.ts index 71520fa1ec..aa7001a3d2 100644 --- a/src/@types/vscode.proposed.chatParticipantAdditions.d.ts +++ b/src/@types/vscode.proposed.chatParticipantAdditions.d.ts @@ -105,6 +105,7 @@ declare module 'vscode' { isComplete?: boolean; toolSpecificData?: ChatTerminalToolInvocationData; fromSubAgent?: boolean; + presentation?: 'hidden' | 'hiddenAfterComplete' | undefined; constructor(toolName: string, toolCallId: string, isError?: boolean); } From d99bd24d3b96902343929defb0632aee5ce55759 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 10 Dec 2025 14:51:30 +0000 Subject: [PATCH 3/7] Add commit SHA linking to file view comments Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> --- src/github/prComment.ts | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/github/prComment.ts b/src/github/prComment.ts index 12d74662f3..5d2249bb5c 100644 --- a/src/github/prComment.ts +++ b/src/github/prComment.ts @@ -421,6 +421,38 @@ ${lineContents} return replaceImages(body, html, this.githubRepository?.remote.host); } + private replaceCommitShas(body: string): string { + const githubRepository = this.githubRepository; + if (!githubRepository) { + return body; + } + + // Match commit SHAs that are: + // - Either 7 or 40 hex characters + // - Not already part of a URL or markdown link + // - Not inside code blocks (backticks) + const commitShaRegex = /(? { + // Don't replace if inside code blocks + const beforeMatch = body.substring(0, offset); + const backtickCount = (beforeMatch.match(/`/g)?.length ?? 0); + if (backtickCount % 2 === 1) { + return match; + } + + // Don't replace if already part of a markdown link + if (beforeMatch.endsWith('[') || body.substring(offset + match.length).startsWith(']')) { + return match; + } + + const owner = githubRepository.remote.owner; + const repo = githubRepository.remote.repositoryName; + const commitUrl = `https://${githubRepository.remote.host}/${owner}/${repo}/commit/${match}`; + return `[${shortSha}](${commitUrl})`; + }); + } + private replaceNewlines(body: string) { return body.replace(/(? Date: Wed, 10 Dec 2025 14:54:36 +0000 Subject: [PATCH 4/7] Add tests for commit SHA regex pattern Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> --- src/test/github/prComment.test.ts | 55 +++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/test/github/prComment.test.ts b/src/test/github/prComment.test.ts index fff88abca4..d2d029ab21 100644 --- a/src/test/github/prComment.test.ts +++ b/src/test/github/prComment.test.ts @@ -6,6 +6,61 @@ import { default as assert } from 'assert'; import { replaceImages } from '../../github/prComment'; +describe('commit SHA replacement', function () { + it('should match 7-character commit SHAs', function () { + const commitShaRegex = /(? Date: Wed, 10 Dec 2025 14:58:36 +0000 Subject: [PATCH 5/7] Extract COMMIT_SHA_EXPRESSION as exported constant Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> --- src/github/prComment.ts | 5 ++--- src/test/github/prComment.test.ts | 23 ++++++++--------------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/github/prComment.ts b/src/github/prComment.ts index 5d2249bb5c..bd7970b75e 100644 --- a/src/github/prComment.ts +++ b/src/github/prComment.ts @@ -217,6 +217,7 @@ export class TemporaryComment extends CommentBase { const SUGGESTION_EXPRESSION = /```suggestion(\u0020*(\r\n|\n))((?[\s\S]*?)(\r\n|\n))?```/; const IMG_EXPRESSION = /.+?)['"].*?>/g; const UUID_EXPRESSION = /[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}/; +export const COMMIT_SHA_EXPRESSION = /(? { + return body.replace(COMMIT_SHA_EXPRESSION, (match, shortSha, remaining, offset) => { // Don't replace if inside code blocks const beforeMatch = body.substring(0, offset); const backtickCount = (beforeMatch.match(/`/g)?.length ?? 0); diff --git a/src/test/github/prComment.test.ts b/src/test/github/prComment.test.ts index d2d029ab21..95df5459df 100644 --- a/src/test/github/prComment.test.ts +++ b/src/test/github/prComment.test.ts @@ -4,59 +4,52 @@ *--------------------------------------------------------------------------------------------*/ import { default as assert } from 'assert'; -import { replaceImages } from '../../github/prComment'; +import { COMMIT_SHA_EXPRESSION, replaceImages } from '../../github/prComment'; describe('commit SHA replacement', function () { it('should match 7-character commit SHAs', function () { - const commitShaRegex = /(? Date: Wed, 10 Dec 2025 15:00:29 +0000 Subject: [PATCH 6/7] Revert unrelated type definition change Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> --- src/@types/vscode.proposed.chatParticipantAdditions.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/@types/vscode.proposed.chatParticipantAdditions.d.ts b/src/@types/vscode.proposed.chatParticipantAdditions.d.ts index aa7001a3d2..71520fa1ec 100644 --- a/src/@types/vscode.proposed.chatParticipantAdditions.d.ts +++ b/src/@types/vscode.proposed.chatParticipantAdditions.d.ts @@ -105,7 +105,6 @@ declare module 'vscode' { isComplete?: boolean; toolSpecificData?: ChatTerminalToolInvocationData; fromSubAgent?: boolean; - presentation?: 'hidden' | 'hiddenAfterComplete' | undefined; constructor(toolName: string, toolCallId: string, isError?: boolean); } From 490b411e3116066e8a169598c518353f023628d3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 15 Dec 2025 11:03:57 +0000 Subject: [PATCH 7/7] Fix test: regex correctly excludes SHAs in backticks Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> --- src/@types/vscode.proposed.chatParticipantAdditions.d.ts | 1 + src/@types/vscode.proposed.chatSessionsProvider.d.ts | 5 +++++ src/test/github/prComment.test.ts | 5 +++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/@types/vscode.proposed.chatParticipantAdditions.d.ts b/src/@types/vscode.proposed.chatParticipantAdditions.d.ts index 71520fa1ec..aa7001a3d2 100644 --- a/src/@types/vscode.proposed.chatParticipantAdditions.d.ts +++ b/src/@types/vscode.proposed.chatParticipantAdditions.d.ts @@ -105,6 +105,7 @@ declare module 'vscode' { isComplete?: boolean; toolSpecificData?: ChatTerminalToolInvocationData; fromSubAgent?: boolean; + presentation?: 'hidden' | 'hiddenAfterComplete' | undefined; constructor(toolName: string, toolCallId: string, isError?: boolean); } diff --git a/src/@types/vscode.proposed.chatSessionsProvider.d.ts b/src/@types/vscode.proposed.chatSessionsProvider.d.ts index bd4e624430..772fc387b9 100644 --- a/src/@types/vscode.proposed.chatSessionsProvider.d.ts +++ b/src/@types/vscode.proposed.chatSessionsProvider.d.ts @@ -95,6 +95,11 @@ declare module 'vscode' { */ description?: string | MarkdownString; + /** + * An optional badge that provides additional context about the chat session. + */ + badge?: string | MarkdownString; + /** * An optional status indicating the current state of the session. */ diff --git a/src/test/github/prComment.test.ts b/src/test/github/prComment.test.ts index 95df5459df..41786c8a82 100644 --- a/src/test/github/prComment.test.ts +++ b/src/test/github/prComment.test.ts @@ -31,8 +31,9 @@ describe('commit SHA replacement', function () { it('should not match SHAs in code blocks', function () { const text = 'Fixed in commit 5cf56bc but not in `abc1234`'; const matches = Array.from(text.matchAll(COMMIT_SHA_EXPRESSION)); - // The regex will match both, but the replacement logic checks backtick count - assert.strictEqual(matches.length, 2); + // The regex should only match the first SHA, not the one inside backticks + assert.strictEqual(matches.length, 1); + assert.strictEqual(matches[0][1], '5cf56bc'); }); it('should not match non-hex strings', function () {