Skip to content

Commit 6b35522

Browse files
authored
Exclude a couple more file schemes from chat attachments (microsoft#264236)
Doesn't seem like we can hide them from the main "Add Context" picker though unfortunately
1 parent 04f0bcb commit 6b35522

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/vs/workbench/contrib/chat/browser/contrib/chatInputCompletions.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import { ChatRequestAgentPart, ChatRequestAgentSubcommandPart, ChatRequestSlashP
5151
import { IChatSlashCommandService } from '../../common/chatSlashCommands.js';
5252
import { IChatRequestVariableEntry } from '../../common/chatVariableEntries.js';
5353
import { IDynamicVariable } from '../../common/chatVariables.js';
54-
import { ChatAgentLocation, ChatModeKind } from '../../common/constants.js';
54+
import { ChatAgentLocation, ChatModeKind, ChatUnsupportedFileSchemes } from '../../common/constants.js';
5555
import { ToolSet } from '../../common/languageModelToolsService.js';
5656
import { IPromptsService } from '../../common/promptSyntax/service/promptsService.js';
5757
import { ChatSubmitAction } from '../actions/chatExecuteActions.js';
@@ -920,9 +920,8 @@ class BuiltinDynamicCompletions extends Disposable {
920920

921921
// HISTORY
922922
// always take the last N items
923-
const ignoredSchemes = new Set([Schemas.vscodeChatEditor, Schemas.walkThrough]);
924923
for (const [i, item] of this.historyService.getHistory().entries()) {
925-
if (!item.resource || seen.has(item.resource) || ignoredSchemes.has(item.resource.scheme)) {
924+
if (!item.resource || seen.has(item.resource) || ChatUnsupportedFileSchemes.has(item.resource.scheme)) {
926925
// ignore editors without a resource
927926
continue;
928927
}

src/vs/workbench/contrib/chat/common/constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
import { Schemas } from '../../../../base/common/network.js';
7+
68
export enum ChatConfiguration {
79
UseFileStorage = 'chat.useFileStorage',
810
AgentEnabled = 'chat.agent.enabled',
@@ -71,3 +73,5 @@ export namespace ChatAgentLocation {
7173
return ChatAgentLocation.Panel;
7274
}
7375
}
76+
77+
export const ChatUnsupportedFileSchemes = new Set([Schemas.vscodeChatEditor, Schemas.walkThrough, Schemas.vscodeChatSession, 'ccreq']);

src/vs/workbench/contrib/search/browser/chatContributions.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import * as glob from '../../../../base/common/glob.js';
3333
import { ResourceSet } from '../../../../base/common/map.js';
3434
import { SymbolsQuickAccessProvider } from './symbolsQuickAccess.js';
3535
import { SymbolKinds } from '../../../../editor/common/languages.js';
36+
import { ChatUnsupportedFileSchemes } from '../../chat/common/constants.js';
3637

3738
export class SearchChatContextContribution extends Disposable implements IWorkbenchContribution {
3839

@@ -167,7 +168,10 @@ class FilesAndFoldersPickerPick implements IChatContextPickerItem {
167168

168169
const defaultItems: IChatContextPickerPickItem[] = [];
169170
(await getTopLevelFolders(workspaces, this._fileService)).forEach(uri => defaultItems.push(this._createPickItem(uri, FileKind.FOLDER)));
170-
this._historyService.getHistory().filter(a => a.resource).slice(0, 30).forEach(uri => defaultItems.push(this._createPickItem(uri.resource!, FileKind.FILE)));
171+
this._historyService.getHistory()
172+
.filter(a => a.resource && !ChatUnsupportedFileSchemes.has(a.resource.scheme))
173+
.slice(0, 30)
174+
.forEach(uri => defaultItems.push(this._createPickItem(uri.resource!, FileKind.FILE)));
171175

172176
if (value === '') {
173177
return defaultItems;

0 commit comments

Comments
 (0)