fix: don't send unconfirmed suggested files in editing request (#234284)
This commit is contained in:
Родитель
21b82050ea
Коммит
543d860c85
|
@ -488,7 +488,7 @@ export class ChatEditingSession extends Disposable implements IChatEditingSessio
|
|||
|
||||
addFileToWorkingSet(resource: URI, description?: string, proposedState?: WorkingSetEntryState.Suggested): void {
|
||||
const state = this._workingSet.get(resource);
|
||||
if (!state && proposedState === WorkingSetEntryState.Suggested) {
|
||||
if (proposedState === WorkingSetEntryState.Suggested) {
|
||||
if (this._removedTransientEntries.has(resource)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ import { asCssVariable } from '../../../../platform/theme/common/colorUtils.js';
|
|||
import { IThemeService } from '../../../../platform/theme/common/themeService.js';
|
||||
import { ChatAgentLocation, IChatAgentCommand, IChatAgentData, IChatAgentService, IChatWelcomeMessageContent, isChatWelcomeMessageContent } from '../common/chatAgents.js';
|
||||
import { ChatContextKeys } from '../common/chatContextKeys.js';
|
||||
import { IChatEditingService, IChatEditingSession } from '../common/chatEditingService.js';
|
||||
import { IChatEditingService, IChatEditingSession, WorkingSetEntryState } from '../common/chatEditingService.js';
|
||||
import { IChatModel, IChatRequestVariableEntry, IChatResponseModel } from '../common/chatModel.js';
|
||||
import { ChatRequestAgentPart, IParsedChatRequest, chatAgentLeader, chatSubcommandLeader, formatChatQuestion } from '../common/chatParserTypes.js';
|
||||
import { ChatRequestParser } from '../common/chatRequestParser.js';
|
||||
|
@ -992,13 +992,22 @@ export class ChatWidget extends Disposable implements IChatWidget {
|
|||
let attachedContext = this.inputPart.getAttachedAndImplicitContext();
|
||||
let workingSet: URI[] | undefined;
|
||||
if (this.location === ChatAgentLocation.EditingSession) {
|
||||
const currentEditingSession = this.chatEditingService.currentEditingSessionObs.get();
|
||||
|
||||
const unconfirmedSuggestions = new ResourceSet();
|
||||
const uniqueWorkingSetEntries = new ResourceSet(); // NOTE: this is used for bookkeeping so the UI can avoid rendering references in the UI that are already shown in the working set
|
||||
const editingSessionAttachedContext: IChatRequestVariableEntry[] = this.inputPart.chatEditWorkingSetFiles.map((v) => {
|
||||
// Pick up everything that the user sees is part of the working set.
|
||||
// This should never exceed the maximum file entries limit above.
|
||||
uniqueWorkingSetEntries.add(v);
|
||||
return this.attachmentModel.asVariableEntry(v);
|
||||
});
|
||||
const editingSessionAttachedContext: IChatRequestVariableEntry[] = [];
|
||||
// Pick up everything that the user sees is part of the working set.
|
||||
// This should never exceed the maximum file entries limit above.
|
||||
for (const v of this.inputPart.chatEditWorkingSetFiles) {
|
||||
// Skip over any suggested files that haven't been confirmed yet in the working set
|
||||
if (currentEditingSession?.workingSet.get(v)?.state === WorkingSetEntryState.Suggested) {
|
||||
unconfirmedSuggestions.add(v);
|
||||
} else {
|
||||
uniqueWorkingSetEntries.add(v);
|
||||
editingSessionAttachedContext.push(this.attachmentModel.asVariableEntry(v));
|
||||
}
|
||||
}
|
||||
let maximumFileEntries = this.chatEditingService.editingSessionFileLimit - editingSessionAttachedContext.length;
|
||||
|
||||
// Then take any attachments that are not files
|
||||
|
@ -1008,7 +1017,6 @@ export class ChatWidget extends Disposable implements IChatWidget {
|
|||
}
|
||||
}
|
||||
|
||||
const currentEditingSession = this.chatEditingService.currentEditingSessionObs.get();
|
||||
for (const file of uniqueWorkingSetEntries) {
|
||||
// Make sure that any files that we sent are part of the working set
|
||||
// but do not permanently add file variables from previous requests to the working set
|
||||
|
@ -1044,6 +1052,7 @@ export class ChatWidget extends Disposable implements IChatWidget {
|
|||
actualSize: number;
|
||||
};
|
||||
this.telemetryService.publicLog2<ChatEditingWorkingSetEvent, ChatEditingWorkingSetClassification>('chatEditing/workingSetSize', { originalSize: this.inputPart.attemptedWorkingSetEntriesCount, actualSize: uniqueWorkingSetEntries.size });
|
||||
currentEditingSession?.remove(...unconfirmedSuggestions);
|
||||
}
|
||||
|
||||
const result = await this.chatService.sendRequest(this.viewModel.sessionId, input, {
|
||||
|
|
Загрузка…
Ссылка в новой задаче