From aa4ff18ea4eb76da57a0e981b9f2c399f9a1c0a1 Mon Sep 17 00:00:00 2001 From: Lahari Gandrapu Date: Wed, 16 Jul 2025 22:18:42 -0400 Subject: [PATCH 1/3] feat: do not close file --- package.json | 5 +++ ...ode.proposed.chatParticipantAdditions.d.ts | 7 +++++ src/commands.ts | 31 +++++++++++-------- src/common/settingKeys.ts | 3 +- 4 files changed, 32 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 8a4cd74c4f..af7b7be036 100644 --- a/package.json +++ b/package.json @@ -735,6 +735,11 @@ "type": "boolean", "default": false, "description": "%githubIssues.alwaysPromptForNewIssueRepo.description%" + }, + "githubPullRequests.closeFileOnMarkFileAsViewed": { + "type": "boolean", + "description": "Close the diff editor automatically when marking a file as viewed from the editor title menu or via shortcut.", + "default": true } } }, diff --git a/src/@types/vscode.proposed.chatParticipantAdditions.d.ts b/src/@types/vscode.proposed.chatParticipantAdditions.d.ts index 369d340afe..c1f4e12c15 100644 --- a/src/@types/vscode.proposed.chatParticipantAdditions.d.ts +++ b/src/@types/vscode.proposed.chatParticipantAdditions.d.ts @@ -258,6 +258,13 @@ declare module 'vscode' { readonly tools: Map; } + export namespace lm { + /** + * Fired when the set of tools on a chat request changes. + */ + export const onDidChangeChatRequestTools: Event; + } + // TODO@API fit this into the stream export interface ChatUsedContext { documents: ChatDocumentContext[]; diff --git a/src/commands.ts b/src/commands.ts index 4d69f83eb8..cd78ce29dd 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -12,7 +12,7 @@ import { CommentReply, findActiveHandler, resolveCommentHandler } from './commen import { COPILOT_LOGINS } from './common/copilot'; import { commands } from './common/executeCommands'; import Logger from './common/logger'; -import { FILE_LIST_LAYOUT, PR_SETTINGS_NAMESPACE } from './common/settingKeys'; +import { CLOSE_ON_MARK_FILE_AS_VIEWED, FILE_LIST_LAYOUT, PR_SETTINGS_NAMESPACE } from './common/settingKeys'; import { editQuery } from './common/settingsUtils'; import { ITelemetry } from './common/telemetry'; import { asTempStorageURI, fromPRUri, fromReviewUri, Schemes, toPRUri } from './common/uri'; @@ -1366,18 +1366,23 @@ ${contents} if (treeNode instanceof FileChangeNode) { await treeNode.markFileAsViewed(false); } else if (treeNode) { - // When the argument is a uri it came from the editor menu and we should also close the file - // Do the close first to improve perceived performance of marking as viewed. - const tab = vscode.window.tabGroups.activeTabGroup.activeTab; - if (tab) { - let compareUri: vscode.Uri | undefined = undefined; - if (tab.input instanceof vscode.TabInputTextDiff) { - compareUri = tab.input.modified; - } else if (tab.input instanceof vscode.TabInputText) { - compareUri = tab.input.uri; - } - if (compareUri && treeNode.toString() === compareUri.toString()) { - vscode.window.tabGroups.close(tab); + // When the argument is a uri it came from the editor menu. By default we close the editor + // after marking the file as viewed, but this can be controlled by a setting. + const shouldCloseEditor = vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE) + .get(CLOSE_ON_MARK_FILE_AS_VIEWED, true); + if (shouldCloseEditor) { + // Do the close first to improve perceived performance of marking as viewed. + const tab = vscode.window.tabGroups.activeTabGroup.activeTab; + if (tab) { + let compareUri: vscode.Uri | undefined = undefined; + if (tab.input instanceof vscode.TabInputTextDiff) { + compareUri = tab.input.modified; + } else if (tab.input instanceof vscode.TabInputText) { + compareUri = tab.input.uri; + } + if (compareUri && treeNode.toString() === compareUri.toString()) { + vscode.window.tabGroups.close(tab); + } } } diff --git a/src/common/settingKeys.ts b/src/common/settingKeys.ts index 9db3eeee8d..db5979a126 100644 --- a/src/common/settingKeys.ts +++ b/src/common/settingKeys.ts @@ -89,4 +89,5 @@ export const COLOR_THEME = 'colorTheme'; export const CODING_AGENT = `${PR_SETTINGS_NAMESPACE}.codingAgent`; export const CODING_AGENT_ENABLED = 'enabled'; -export const CODING_AGENT_AUTO_COMMIT_AND_PUSH = 'autoCommitAndPush'; \ No newline at end of file +export const CODING_AGENT_AUTO_COMMIT_AND_PUSH = 'autoCommitAndPush'; +export const CLOSE_ON_MARK_FILE_AS_VIEWED = 'closeFileOnMarkFileAsViewed'; \ No newline at end of file From 96783c39dc0e0687c69fdd9042281749843ba2d2 Mon Sep 17 00:00:00 2001 From: Lahari Gandrapu Date: Fri, 18 Jul 2025 16:49:58 -0400 Subject: [PATCH 2/3] refactor: use command args instead of setting for markFileAsViewed behavior --- package.json | 10 ++++------ src/commands.ts | 11 +++++------ src/common/settingKeys.ts | 3 +-- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index af7b7be036..535f1dea11 100644 --- a/package.json +++ b/package.json @@ -735,11 +735,6 @@ "type": "boolean", "default": false, "description": "%githubIssues.alwaysPromptForNewIssueRepo.description%" - }, - "githubPullRequests.closeFileOnMarkFileAsViewed": { - "type": "boolean", - "description": "Close the diff editor automatically when marking a file as viewed from the editor title menu or via shortcut.", - "default": true } } }, @@ -2855,7 +2850,10 @@ { "command": "pr.markFileAsViewed", "group": "navigation", - "when": "resourceScheme != pr && resourceScheme != review && resourceScheme != filechange && resourcePath in github:unviewedFiles" + "when": "resourceScheme != pr && resourceScheme != review && resourceScheme != filechange && resourcePath in github:unviewedFiles", + "args": { + "closeFile": true + } }, { "command": "pr.unmarkFileAsViewed", diff --git a/src/commands.ts b/src/commands.ts index cd78ce29dd..ef25716b67 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -12,7 +12,7 @@ import { CommentReply, findActiveHandler, resolveCommentHandler } from './commen import { COPILOT_LOGINS } from './common/copilot'; import { commands } from './common/executeCommands'; import Logger from './common/logger'; -import { CLOSE_ON_MARK_FILE_AS_VIEWED, FILE_LIST_LAYOUT, PR_SETTINGS_NAMESPACE } from './common/settingKeys'; +import { FILE_LIST_LAYOUT, PR_SETTINGS_NAMESPACE } from './common/settingKeys'; import { editQuery } from './common/settingsUtils'; import { ITelemetry } from './common/telemetry'; import { asTempStorageURI, fromPRUri, fromReviewUri, Schemes, toPRUri } from './common/uri'; @@ -1356,7 +1356,7 @@ ${contents} }; context.subscriptions.push( - vscode.commands.registerCommand('pr.markFileAsViewed', async (treeNode: FileChangeNode | vscode.Uri | undefined) => { + vscode.commands.registerCommand('pr.markFileAsViewed', async (treeNode: FileChangeNode | vscode.Uri | undefined, args?: { closeFile?: boolean }) => { try { if (treeNode === undefined) { // Use the active editor to enable keybindings @@ -1366,10 +1366,9 @@ ${contents} if (treeNode instanceof FileChangeNode) { await treeNode.markFileAsViewed(false); } else if (treeNode) { - // When the argument is a uri it came from the editor menu. By default we close the editor - // after marking the file as viewed, but this can be controlled by a setting. - const shouldCloseEditor = vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE) - .get(CLOSE_ON_MARK_FILE_AS_VIEWED, true); + // When the argument is a uri it came from the editor menu. By default we don't close the editor + // but this can be controlled by the command argument + const shouldCloseEditor = args?.closeFile ?? false; if (shouldCloseEditor) { // Do the close first to improve perceived performance of marking as viewed. const tab = vscode.window.tabGroups.activeTabGroup.activeTab; diff --git a/src/common/settingKeys.ts b/src/common/settingKeys.ts index db5979a126..9db3eeee8d 100644 --- a/src/common/settingKeys.ts +++ b/src/common/settingKeys.ts @@ -89,5 +89,4 @@ export const COLOR_THEME = 'colorTheme'; export const CODING_AGENT = `${PR_SETTINGS_NAMESPACE}.codingAgent`; export const CODING_AGENT_ENABLED = 'enabled'; -export const CODING_AGENT_AUTO_COMMIT_AND_PUSH = 'autoCommitAndPush'; -export const CLOSE_ON_MARK_FILE_AS_VIEWED = 'closeFileOnMarkFileAsViewed'; \ No newline at end of file +export const CODING_AGENT_AUTO_COMMIT_AND_PUSH = 'autoCommitAndPush'; \ No newline at end of file From 4d335392c7accba34e2742106cf8142f609471a8 Mon Sep 17 00:00:00 2001 From: Lahari Gandrapu Date: Fri, 18 Jul 2025 18:12:36 -0400 Subject: [PATCH 3/3] Revert refactor: use command args instead of setting for markFileAsViewed behavior --- package.json | 10 ++++++---- src/commands.ts | 11 ++++++----- src/common/settingKeys.ts | 3 ++- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 729239bac9..c7932a7f33 100644 --- a/package.json +++ b/package.json @@ -737,6 +737,11 @@ "type": "boolean", "default": false, "description": "%githubIssues.alwaysPromptForNewIssueRepo.description%" + }, + "githubPullRequests.closeFileOnMarkFileAsViewed": { + "type": "boolean", + "description": "Close the diff editor automatically when marking a file as viewed from the editor title menu or via shortcut.", + "default": true } } }, @@ -2852,10 +2857,7 @@ { "command": "pr.markFileAsViewed", "group": "navigation", - "when": "resourceScheme != pr && resourceScheme != review && resourceScheme != filechange && resourcePath in github:unviewedFiles", - "args": { - "closeFile": true - } + "when": "resourceScheme != pr && resourceScheme != review && resourceScheme != filechange && resourcePath in github:unviewedFiles" }, { "command": "pr.unmarkFileAsViewed", diff --git a/src/commands.ts b/src/commands.ts index ef25716b67..cd78ce29dd 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -12,7 +12,7 @@ import { CommentReply, findActiveHandler, resolveCommentHandler } from './commen import { COPILOT_LOGINS } from './common/copilot'; import { commands } from './common/executeCommands'; import Logger from './common/logger'; -import { FILE_LIST_LAYOUT, PR_SETTINGS_NAMESPACE } from './common/settingKeys'; +import { CLOSE_ON_MARK_FILE_AS_VIEWED, FILE_LIST_LAYOUT, PR_SETTINGS_NAMESPACE } from './common/settingKeys'; import { editQuery } from './common/settingsUtils'; import { ITelemetry } from './common/telemetry'; import { asTempStorageURI, fromPRUri, fromReviewUri, Schemes, toPRUri } from './common/uri'; @@ -1356,7 +1356,7 @@ ${contents} }; context.subscriptions.push( - vscode.commands.registerCommand('pr.markFileAsViewed', async (treeNode: FileChangeNode | vscode.Uri | undefined, args?: { closeFile?: boolean }) => { + vscode.commands.registerCommand('pr.markFileAsViewed', async (treeNode: FileChangeNode | vscode.Uri | undefined) => { try { if (treeNode === undefined) { // Use the active editor to enable keybindings @@ -1366,9 +1366,10 @@ ${contents} if (treeNode instanceof FileChangeNode) { await treeNode.markFileAsViewed(false); } else if (treeNode) { - // When the argument is a uri it came from the editor menu. By default we don't close the editor - // but this can be controlled by the command argument - const shouldCloseEditor = args?.closeFile ?? false; + // When the argument is a uri it came from the editor menu. By default we close the editor + // after marking the file as viewed, but this can be controlled by a setting. + const shouldCloseEditor = vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE) + .get(CLOSE_ON_MARK_FILE_AS_VIEWED, true); if (shouldCloseEditor) { // Do the close first to improve perceived performance of marking as viewed. const tab = vscode.window.tabGroups.activeTabGroup.activeTab; diff --git a/src/common/settingKeys.ts b/src/common/settingKeys.ts index 9db3eeee8d..db5979a126 100644 --- a/src/common/settingKeys.ts +++ b/src/common/settingKeys.ts @@ -89,4 +89,5 @@ export const COLOR_THEME = 'colorTheme'; export const CODING_AGENT = `${PR_SETTINGS_NAMESPACE}.codingAgent`; export const CODING_AGENT_ENABLED = 'enabled'; -export const CODING_AGENT_AUTO_COMMIT_AND_PUSH = 'autoCommitAndPush'; \ No newline at end of file +export const CODING_AGENT_AUTO_COMMIT_AND_PUSH = 'autoCommitAndPush'; +export const CLOSE_ON_MARK_FILE_AS_VIEWED = 'closeFileOnMarkFileAsViewed'; \ No newline at end of file