More small chat API fixes (#205901)

* Fix #205811

* Fix #205807

* Make description optional

* Fix

* fix test
This commit is contained in:
Rob Lourens 2024-02-21 20:57:18 +00:00 committed by GitHub
parent dc0b20cf98
commit 61f447b79a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 17 additions and 16 deletions

View file

@ -67,7 +67,7 @@ suite('chat', () => {
interactive.sendInteractiveRequestToProvider('provider', { message: '@participant /hello friend' });
} else {
assert.strictEqual(request.context.history.length, 1);
assert.strictEqual(request.context.history[0].participant.participant, 'participant');
assert.strictEqual(request.context.history[0].participant.name, 'participant');
assert.strictEqual(request.context.history[0].command, 'hello');
}
});

View file

@ -231,11 +231,11 @@ export class ExtHostChatAgents2 implements ExtHostChatAgentsShape2 {
{ ...ehResult, metadata: undefined };
// REQUEST turn
res.push(new extHostTypes.ChatRequestTurn(h.request.message, h.request.command, h.request.variables.variables.map(typeConvert.ChatAgentResolvedVariable.to), { extensionId: '', participant: h.request.agentId }));
res.push(new extHostTypes.ChatRequestTurn(h.request.message, h.request.command, h.request.variables.variables.map(typeConvert.ChatAgentResolvedVariable.to), { extensionId: '', name: h.request.agentId }));
// RESPONSE turn
const parts = coalesce(h.response.map(r => typeConvert.ChatResponsePart.fromContent(r, this.commands.converter)));
res.push(new extHostTypes.ChatResponseTurn(parts, result, { extensionId: '', participant: h.request.agentId }, h.request.command));
res.push(new extHostTypes.ChatResponseTurn(parts, result, { extensionId: '', name: h.request.agentId }, h.request.command));
}
return res;
@ -508,9 +508,11 @@ class ExtHostChatAgent {
updateMetadataSoon();
},
get fullName() {
checkProposedApiEnabled(that.extension, 'defaultChatParticipant');
return that._fullName ?? that.extension.displayName ?? that.extension.name;
},
set fullName(v) {
checkProposedApiEnabled(that.extension, 'defaultChatParticipant');
that._fullName = v;
updateMetadataSoon();
},

View file

@ -4257,7 +4257,7 @@ export class ChatRequestTurn implements vscode.ChatRequestTurn {
readonly prompt: string,
readonly command: string | undefined,
readonly variables: vscode.ChatResolvedVariable[],
readonly participant: { extensionId: string; participant: string },
readonly participant: { extensionId: string; name: string },
) { }
}
@ -4266,7 +4266,7 @@ export class ChatResponseTurn implements vscode.ChatResponseTurn {
constructor(
readonly response: ReadonlyArray<ChatResponseMarkdownPart | ChatResponseFileTreePart | ChatResponseAnchorPart | ChatResponseCommandButtonPart>,
readonly result: vscode.ChatResult,
readonly participant: { extensionId: string; participant: string },
readonly participant: { extensionId: string; name: string },
readonly command?: string
) { }
}

View file

@ -23,7 +23,7 @@ declare module 'vscode' {
/**
* The name of the chat participant and contributing extension to which this request was directed.
*/
readonly participant: { readonly extensionId: string; readonly participant: string };
readonly participant: { readonly extensionId: string; readonly name: string };
/**
* The name of the {@link ChatCommand command} that was selected for this request.
@ -35,7 +35,7 @@ declare module 'vscode' {
*/
readonly variables: ChatResolvedVariable[];
private constructor(prompt: string, command: string | undefined, variables: ChatResolvedVariable[], participant: { extensionId: string; participant: string });
private constructor(prompt: string, command: string | undefined, variables: ChatResolvedVariable[], participant: { extensionId: string; name: string });
}
/**
@ -56,14 +56,14 @@ declare module 'vscode' {
/**
* The name of the chat participant and contributing extension that this response came from.
*/
readonly participant: { readonly extensionId: string; readonly participant: string };
readonly participant: { readonly extensionId: string; readonly name: string };
/**
* The name of the command that this response came from.
*/
readonly command?: string;
private constructor(response: ReadonlyArray<ChatResponseMarkdownPart | ChatResponseFileTreePart | ChatResponseAnchorPart | ChatResponseCommandButtonPart>, result: ChatResult, participant: { extensionId: string; participant: string });
private constructor(response: ReadonlyArray<ChatResponseMarkdownPart | ChatResponseFileTreePart | ChatResponseAnchorPart | ChatResponseCommandButtonPart>, result: ChatResult, participant: { extensionId: string; name: string });
}
export interface ChatContext {
@ -239,16 +239,10 @@ declare module 'vscode' {
*/
readonly name: string;
/**
* The full name of this participant.
* 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?
*/
fullName: string;
/**
* A human-readable description explaining what this participant does.
*/
description: string;
description?: string;
/**
* Icon for the participant shown in UI.

View file

@ -18,6 +18,11 @@ declare module 'vscode' {
*/
isDefault?: boolean;
/**
* The full name of this participant.
*/
fullName?: string;
/**
* When true, this participant is invoked when the user submits their query using ctrl/cmd+enter
* TODO@API name