Skip to content

Commit 329b00e

Browse files
authored
Contribute statistics for coding agent sessions. (#7699)
1 parent b213a85 commit 329b00e

6 files changed

Lines changed: 31 additions & 3 deletions

File tree

src/@types/vscode.proposed.chatSessionsProvider.d.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,21 @@ declare module 'vscode' {
108108
*/
109109
endTime?: number;
110110
};
111+
112+
/**
113+
* Statistics about the chat session.
114+
*/
115+
statistics?: {
116+
/**
117+
* Number of insertions made during the session.
118+
*/
119+
insertions: number;
120+
121+
/**
122+
* Number of deletions made during the session.
123+
*/
124+
deletions: number;
125+
};
111126
}
112127

113128
export interface ChatSession {

src/github/copilotRemoteAgent.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -827,8 +827,9 @@ export class CopilotRemoteAgentManager extends Disposable {
827827
const status = copilotPRStatusToSessionStatus(prAndStatus.status);
828828
const pullRequest = prAndStatus.item;
829829
const tooltip = await issueMarkdown(pullRequest, this.context, this.repositoriesManager);
830-
const defaultBranch = await pullRequest.githubRepository.getDefaultBranch();
831-
const description = pullRequest.base.ref === defaultBranch ? `pull request #${pullRequest.number}` : `pull request #${pullRequest.number}${pullRequest.base.ref}`;
830+
831+
const uri = await toOpenPullRequestWebviewUri({ owner: pullRequest.remote.owner, repo: pullRequest.remote.repositoryName, pullRequestNumber: pullRequest.number });
832+
const description = new vscode.MarkdownString(`PR [#${pullRequest.number}](${uri.toString()})`); // pullRequest.base.ref === defaultBranch ? `PR #${pullRequest.number}`: `PR #${pullRequest.number} → ${pullRequest.base.ref}`;
832833
return {
833834
id: `${pullRequest.number}`,
834835
label: pullRequest.title || `Session ${pullRequest.number}`,
@@ -839,7 +840,11 @@ export class CopilotRemoteAgentManager extends Disposable {
839840
status,
840841
timing: {
841842
startTime: timestampNumber
842-
}
843+
},
844+
statistics: pullRequest.item.additions !== undefined && pullRequest.item.deletions !== undefined && (pullRequest.item.additions > 0 || pullRequest.item.deletions > 0) ? {
845+
insertions: pullRequest.item.additions,
846+
deletions: pullRequest.item.deletions
847+
} : undefined
843848
};
844849
}));
845850
} catch (error) {

src/github/graphql.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,8 @@ export interface PullRequest extends Issue {
720720
viewerCanDisableAutoMerge: boolean;
721721
isDraft?: boolean;
722722
suggestedReviewers: SuggestedReviewerResponse[];
723+
additions?: number;
724+
deletions?: number;
723725
}
724726

725727
export enum DefaultCommitTitle {

src/github/interface.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ export interface PullRequest extends Issue {
238238
squashCommitMeta?: { title: string, description: string };
239239
suggestedReviewers?: ISuggestedReviewer[];
240240
hasComments?: boolean;
241+
additions?: number;
242+
deletions?: number;
241243
}
242244

243245
export enum NotificationSubjectType {

src/github/queries.gql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ fragment PullRequestFragment on PullRequest {
249249
...Node
250250
}
251251
}
252+
additions
253+
deletions
252254
}
253255

254256
query Issue($owner: String!, $name: String!, $number: Int!) {

src/github/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,8 @@ export async function parseGraphQLPullRequest(
848848
reactionCount: graphQLPullRequest.reactions.totalCount,
849849
reactions: parseGraphQLReaction(graphQLPullRequest.reactionGroups),
850850
commentCount: graphQLPullRequest.comments.totalCount,
851+
additions: graphQLPullRequest.additions,
852+
deletions: graphQLPullRequest.deletions,
851853
};
852854
pr.mergeCommitMeta = parseCommitMeta(graphQLPullRequest.baseRepository.mergeCommitTitle, graphQLPullRequest.baseRepository.mergeCommitMessage, pr);
853855
pr.squashCommitMeta = parseCommitMeta(graphQLPullRequest.baseRepository.squashMergeCommitTitle, graphQLPullRequest.baseRepository.squashMergeCommitMessage, pr);

0 commit comments

Comments
 (0)