Skip to content

Commit 61f447b

Browse files
authored
More small chat API fixes (microsoft#205901)
* Fix microsoft#205811 * Fix microsoft#205807 * Make description optional * Fix * fix test
1 parent dc0b20c commit 61f447b

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

extensions/vscode-api-tests/src/singlefolder-tests/chat.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ suite('chat', () => {
6767
interactive.sendInteractiveRequestToProvider('provider', { message: '@participant /hello friend' });
6868
} else {
6969
assert.strictEqual(request.context.history.length, 1);
70-
assert.strictEqual(request.context.history[0].participant.participant, 'participant');
70+
assert.strictEqual(request.context.history[0].participant.name, 'participant');
7171
assert.strictEqual(request.context.history[0].command, 'hello');
7272
}
7373
});

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,11 @@ export class ExtHostChatAgents2 implements ExtHostChatAgentsShape2 {
231231
{ ...ehResult, metadata: undefined };
232232

233233
// REQUEST turn
234-
res.push(new extHostTypes.ChatRequestTurn(h.request.message, h.request.command, h.request.variables.variables.map(typeConvert.ChatAgentResolvedVariable.to), { extensionId: '', participant: h.request.agentId }));
234+
res.push(new extHostTypes.ChatRequestTurn(h.request.message, h.request.command, h.request.variables.variables.map(typeConvert.ChatAgentResolvedVariable.to), { extensionId: '', name: h.request.agentId }));
235235

236236
// RESPONSE turn
237237
const parts = coalesce(h.response.map(r => typeConvert.ChatResponsePart.fromContent(r, this.commands.converter)));
238-
res.push(new extHostTypes.ChatResponseTurn(parts, result, { extensionId: '', participant: h.request.agentId }, h.request.command));
238+
res.push(new extHostTypes.ChatResponseTurn(parts, result, { extensionId: '', name: h.request.agentId }, h.request.command));
239239
}
240240

241241
return res;
@@ -508,9 +508,11 @@ class ExtHostChatAgent {
508508
updateMetadataSoon();
509509
},
510510
get fullName() {
511+
checkProposedApiEnabled(that.extension, 'defaultChatParticipant');
511512
return that._fullName ?? that.extension.displayName ?? that.extension.name;
512513
},
513514
set fullName(v) {
515+
checkProposedApiEnabled(that.extension, 'defaultChatParticipant');
514516
that._fullName = v;
515517
updateMetadataSoon();
516518
},

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4257,7 +4257,7 @@ export class ChatRequestTurn implements vscode.ChatRequestTurn {
42574257
readonly prompt: string,
42584258
readonly command: string | undefined,
42594259
readonly variables: vscode.ChatResolvedVariable[],
4260-
readonly participant: { extensionId: string; participant: string },
4260+
readonly participant: { extensionId: string; name: string },
42614261
) { }
42624262
}
42634263

@@ -4266,7 +4266,7 @@ export class ChatResponseTurn implements vscode.ChatResponseTurn {
42664266
constructor(
42674267
readonly response: ReadonlyArray<ChatResponseMarkdownPart | ChatResponseFileTreePart | ChatResponseAnchorPart | ChatResponseCommandButtonPart>,
42684268
readonly result: vscode.ChatResult,
4269-
readonly participant: { extensionId: string; participant: string },
4269+
readonly participant: { extensionId: string; name: string },
42704270
readonly command?: string
42714271
) { }
42724272
}

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

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ declare module 'vscode' {
2323
/**
2424
* The name of the chat participant and contributing extension to which this request was directed.
2525
*/
26-
readonly participant: { readonly extensionId: string; readonly participant: string };
26+
readonly participant: { readonly extensionId: string; readonly name: string };
2727

2828
/**
2929
* The name of the {@link ChatCommand command} that was selected for this request.
@@ -35,7 +35,7 @@ declare module 'vscode' {
3535
*/
3636
readonly variables: ChatResolvedVariable[];
3737

38-
private constructor(prompt: string, command: string | undefined, variables: ChatResolvedVariable[], participant: { extensionId: string; participant: string });
38+
private constructor(prompt: string, command: string | undefined, variables: ChatResolvedVariable[], participant: { extensionId: string; name: string });
3939
}
4040

4141
/**
@@ -56,14 +56,14 @@ declare module 'vscode' {
5656
/**
5757
* The name of the chat participant and contributing extension that this response came from.
5858
*/
59-
readonly participant: { readonly extensionId: string; readonly participant: string };
59+
readonly participant: { readonly extensionId: string; readonly name: string };
6060

6161
/**
6262
* The name of the command that this response came from.
6363
*/
6464
readonly command?: string;
6565

66-
private constructor(response: ReadonlyArray<ChatResponseMarkdownPart | ChatResponseFileTreePart | ChatResponseAnchorPart | ChatResponseCommandButtonPart>, result: ChatResult, participant: { extensionId: string; participant: string });
66+
private constructor(response: ReadonlyArray<ChatResponseMarkdownPart | ChatResponseFileTreePart | ChatResponseAnchorPart | ChatResponseCommandButtonPart>, result: ChatResult, participant: { extensionId: string; name: string });
6767
}
6868

6969
export interface ChatContext {
@@ -239,16 +239,10 @@ declare module 'vscode' {
239239
*/
240240
readonly name: string;
241241

242-
/**
243-
* The full name of this participant.
244-
* TODO@API This is only used for the default participant, but it seems useful, so should we keep it so we can use it in the future?
245-
*/
246-
fullName: string;
247-
248242
/**
249243
* A human-readable description explaining what this participant does.
250244
*/
251-
description: string;
245+
description?: string;
252246

253247
/**
254248
* Icon for the participant shown in UI.

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ declare module 'vscode' {
1818
*/
1919
isDefault?: boolean;
2020

21+
/**
22+
* The full name of this participant.
23+
*/
24+
fullName?: string;
25+
2126
/**
2227
* When true, this participant is invoked when the user submits their query using ctrl/cmd+enter
2328
* TODO@API name

0 commit comments

Comments
 (0)