Skip to content

Commit 7afa954

Browse files
authored
Plumb custom mode body (microsoft#250250)
Towards microsoft/vscode-copilot#17638
1 parent 1034c12 commit 7afa954

File tree

7 files changed

+27
-1
lines changed

7 files changed

+27
-1
lines changed

src/vs/workbench/api/common/extHostTypeConverters.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2943,6 +2943,7 @@ export namespace ChatAgentRequest {
29432943
tools,
29442944
model,
29452945
editedFileEvents: request.editedFileEvents,
2946+
modeInstructions: request.modeInstructions,
29462947
};
29472948

29482949
if (!isProposedApiEnabled(extension, 'chatParticipantPrivate')) {

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,6 +1333,7 @@ export class ChatWidget extends Disposable implements IChatWidget {
13331333
attachedContext: requestInputs.attachedContext,
13341334
noCommandDetection: options?.noCommandDetection,
13351335
userSelectedTools: this.getUserSelectedTools(),
1336+
modeInstructions: this.input.currentMode2.body
13361337
});
13371338

13381339
if (result) {
@@ -1371,6 +1372,14 @@ export class ChatWidget extends Disposable implements IChatWidget {
13711372
return undefined;
13721373
}
13731374

1375+
getModeRequestOptions(): Partial<IChatSendRequestOptions> {
1376+
return {
1377+
modeInstructions: this.input.currentMode2.body,
1378+
userSelectedTools: this.getUserSelectedTools(),
1379+
mode: this.input.currentMode,
1380+
};
1381+
}
1382+
13741383
getCodeBlockInfosForResponse(response: IChatResponseViewModel): IChatCodeBlockInfo[] {
13751384
return this.renderer.getCodeBlockInfosForResponse(response);
13761385
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ export interface IChatAgentRequest {
137137
rejectedConfirmationData?: any[];
138138
userSelectedModelId?: string;
139139
userSelectedTools?: Record<string, boolean>;
140+
modeInstructions?: string;
140141
toolSelectionIsExclusive?: boolean;
141142
editedFileEvents?: IChatAgentEditedFileEvent[];
142143
}

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,16 @@ export class ChatModeService implements IChatModeService {
6262
}
6363
}
6464

65+
/**
66+
* TODO This data object is not quite the right pattern, needs to live-update on file changes
67+
*/
6568
export interface IChatMode {
6669
readonly id: string;
6770
readonly name: string;
6871
readonly description?: string;
6972
readonly kind: ChatMode;
7073
readonly customTools?: readonly string[];
74+
readonly body?: string;
7175
}
7276

7377
export function isIChatMode(mode: unknown): mode is IChatMode {
@@ -97,6 +101,10 @@ export class CustomChatMode implements IChatMode {
97101
return this.customChatMode.tools;
98102
}
99103

104+
get body(): string {
105+
return this.customChatMode.body;
106+
}
107+
100108
public readonly kind = ChatMode.Agent;
101109

102110
constructor(
@@ -112,7 +120,8 @@ export class CustomChatMode implements IChatMode {
112120
name: this.name,
113121
description: this.description,
114122
kind: this.kind,
115-
customTools: this.customTools
123+
customTools: this.customTools,
124+
body: this.body
116125
};
117126
}
118127
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ export interface IChatSendRequestOptions {
488488
mode?: ChatMode;
489489
userSelectedModelId?: string;
490490
userSelectedTools?: Record<string, boolean>;
491+
modeInstructions?: string;
491492
toolSelectionIsExclusive?: boolean;
492493
location?: ChatAgentLocation;
493494
locationData?: IChatLocationData;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,7 @@ export class ChatService extends Disposable implements IChatService {
763763
rejectedConfirmationData: options?.rejectedConfirmationData,
764764
userSelectedModelId: options?.userSelectedModelId,
765765
userSelectedTools: options?.userSelectedTools,
766+
modeInstructions: options?.modeInstructions,
766767
toolSelectionIsExclusive: options?.toolSelectionIsExclusive,
767768
editedFileEvents: request.editedFileEvents
768769
} satisfies IChatAgentRequest;

src/vscode-dts/vscode.proposed.chatParticipantAdditions.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,4 +446,8 @@ declare module 'vscode' {
446446
export interface LanguageModelToolInvocationOptions<T> {
447447
model?: LanguageModelChat;
448448
}
449+
450+
export interface ChatRequest {
451+
modeInstructions?: string;
452+
}
449453
}

0 commit comments

Comments
 (0)