Fix missing implicit variables for inline chat participant (#212748)

This commit is contained in:
Rob Lourens 2024-05-14 16:07:51 -07:00 committed by GitHub
parent 4d03498fcd
commit 6ffbf8bff2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 11 additions and 11 deletions

View file

@ -297,7 +297,7 @@ export function registerChatTitleActions() {
}
const request = chatService.getSession(item.sessionId)?.getRequests().find(candidate => candidate.id === item.requestId);
if (request) {
await chatService.resendRequest(request, { noCommandDetection: false, attempt: request.attempt + 1, location: widget.location, implicitVariablesEnabled: true });
await chatService.resendRequest(request, { noCommandDetection: false, attempt: request.attempt + 1, location: widget.location });
}
}
});
@ -333,7 +333,7 @@ export function registerChatTitleActions() {
}
const request = chatService.getSession(item.sessionId)?.getRequests().find(candidate => candidate.id === item.requestId);
if (request) {
await chatService.resendRequest(request, { noCommandDetection: true, attempt: request.attempt, location: widget.location, implicitVariablesEnabled: true });
await chatService.resendRequest(request, { noCommandDetection: true, attempt: request.attempt, location: widget.location });
}
}
});

View file

@ -709,7 +709,7 @@ export class ChatWidget extends Disposable implements IChatWidget {
'query' in opts ? opts.query :
`${opts.prefix} ${editorValue}`;
const isUserQuery = !opts || 'prefix' in opts;
const result = await this.chatService.sendRequest(this.viewModel.sessionId, input, { implicitVariablesEnabled: false, location: this.location, parserContext: { selectedAgent: this._lastSelectedAgent }, attachedContext: [...this.inputPart.attachedContext.values()] });
const result = await this.chatService.sendRequest(this.viewModel.sessionId, input, { location: this.location, parserContext: { selectedAgent: this._lastSelectedAgent }, attachedContext: [...this.inputPart.attachedContext.values()] });
this.inputPart.attachedContext.clear();
if (result) {

View file

@ -299,7 +299,6 @@ export interface IChatSendRequestData extends IChatSendRequestResponseState {
}
export interface IChatSendRequestOptions {
implicitVariablesEnabled?: boolean;
location?: ChatAgentLocation;
parserContext?: IChatParserContext;
attempt?: number;

View file

@ -425,13 +425,11 @@ export class ChatService extends Disposable implements IChatService {
const location = options?.location ?? model.initialLocation;
const attempt = options?.attempt ?? 0;
const enableCommandDetection = !options?.noCommandDetection;
const implicitVariablesEnabled = options?.implicitVariablesEnabled ?? false;
const defaultAgent = this.chatAgentService.getDefaultAgent(location)!;
this.removeRequest(model.sessionId, request.id);
await this._sendRequestAsync(model, model.sessionId, request.message, attempt, enableCommandDetection, implicitVariablesEnabled, defaultAgent, location, options);
await this._sendRequestAsync(model, model.sessionId, request.message, attempt, enableCommandDetection, defaultAgent, location, options);
}
async sendRequest(sessionId: string, request: string, options?: IChatSendRequestOptions): Promise<IChatSendRequestData | undefined> {
@ -456,7 +454,6 @@ export class ChatService extends Disposable implements IChatService {
const location = options?.location ?? model.initialLocation;
const attempt = options?.attempt ?? 0;
const implicitVariablesEnabled = options?.implicitVariablesEnabled ?? false;
const defaultAgent = this.chatAgentService.getDefaultAgent(location)!;
const parsedRequest = this.parseChatRequest(sessionId, request, location, options);
@ -465,7 +462,7 @@ export class ChatService extends Disposable implements IChatService {
// This method is only returning whether the request was accepted - don't block on the actual request
return {
...this._sendRequestAsync(model, sessionId, parsedRequest, attempt, !options?.noCommandDetection, implicitVariablesEnabled, defaultAgent, location, options),
...this._sendRequestAsync(model, sessionId, parsedRequest, attempt, !options?.noCommandDetection, defaultAgent, location, options),
agent,
slashCommand: agentSlashCommandPart?.command,
};
@ -495,7 +492,7 @@ export class ChatService extends Disposable implements IChatService {
return newTokenSource.token;
}
private _sendRequestAsync(model: ChatModel, sessionId: string, parsedRequest: IParsedChatRequest, attempt: number, enableCommandDetection: boolean, implicitVariablesEnabled: boolean, defaultAgent: IChatAgent, location: ChatAgentLocation, options?: IChatSendRequestOptions): IChatSendRequestResponseState {
private _sendRequestAsync(model: ChatModel, sessionId: string, parsedRequest: IParsedChatRequest, attempt: number, enableCommandDetection: boolean, defaultAgent: IChatAgent, location: ChatAgentLocation, options?: IChatSendRequestOptions): IChatSendRequestResponseState {
const followupsCancelToken = this.refreshFollowupsCancellationToken(sessionId);
let request: ChatRequestModel;
const agentPart = 'kind' in parsedRequest ? undefined : parsedRequest.parts.find((r): r is ChatRequestAgentPart => r instanceof ChatRequestAgentPart);
@ -572,6 +569,9 @@ export class ChatService extends Disposable implements IChatService {
const promptTextResult = getPromptText(request.message);
const updatedVariableData = updateRanges(variableData, promptTextResult.diff); // TODO bit of a hack
// TODO- should figure out how to get rid of implicit variables for inline chat
const implicitVariablesEnabled = location === ChatAgentLocation.Editor;
if (implicitVariablesEnabled) {
const implicitVariables = agent.defaultImplicitVariables;
if (implicitVariables) {
@ -595,7 +595,8 @@ export class ChatService extends Disposable implements IChatService {
enableCommandDetection,
attempt,
location,
...options
acceptedConfirmationData: options?.acceptedConfirmationData,
rejectedConfirmationData: options?.rejectedConfirmationData,
};
const agentResult = await this.chatAgentService.invokeAgent(agent.id, requestProps, progressCallback, history, token);