mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 10:08:49 +01:00
Add some learning prompts and "send to edit session" for inline chat (#267519)
* wip * update learnings * clean 1 * clean 2 * commit update-instructions.prompt.md * swap back to normal model after being in delegate * adding generation * wip * wip * update --------- Co-authored-by: Henning Dieterichs <hdieterichs@microsoft.com> Co-authored-by: Anthony Kim <anthonykim@microsoft.com> Co-authored-by: SteVen Batten <sbatten@microsoft.com>
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as aria from '../../../../base/browser/ui/aria/aria.js';
|
||||
import { alert } from '../../../../base/browser/ui/aria/aria.js';
|
||||
import { Barrier, DeferredPromise, Queue, raceCancellation } from '../../../../base/common/async.js';
|
||||
import { CancellationToken, CancellationTokenSource } from '../../../../base/common/cancellation.js';
|
||||
import { toErrorMessage } from '../../../../base/common/errorMessage.js';
|
||||
@@ -49,7 +50,7 @@ import { showChatView } from '../../chat/browser/chat.js';
|
||||
import { IChatAttachmentResolveService } from '../../chat/browser/chatAttachmentResolveService.js';
|
||||
import { IChatWidgetLocationOptions } from '../../chat/browser/chatWidget.js';
|
||||
import { ChatContextKeys } from '../../chat/common/chatContextKeys.js';
|
||||
import { ModifiedFileEntryState } from '../../chat/common/chatEditingService.js';
|
||||
import { IChatEditingSession, ModifiedFileEntryState } from '../../chat/common/chatEditingService.js';
|
||||
import { ChatModel, ChatRequestRemovalReason, IChatRequestModel, IChatTextEditGroup, IChatTextEditGroupState, IResponse } from '../../chat/common/chatModel.js';
|
||||
import { IChatService } from '../../chat/common/chatService.js';
|
||||
import { IChatRequestVariableEntry } from '../../chat/common/chatVariableEntries.js';
|
||||
@@ -66,7 +67,6 @@ import { InlineChatError } from './inlineChatSessionServiceImpl.js';
|
||||
import { HunkAction, IEditObserver, IInlineChatMetadata, LiveStrategy, ProgressingEditsOptions } from './inlineChatStrategies.js';
|
||||
import { EditorBasedInlineChatWidget } from './inlineChatWidget.js';
|
||||
import { InlineChatZoneWidget } from './inlineChatZoneWidget.js';
|
||||
import { alert } from '../../../../base/browser/ui/aria/aria.js';
|
||||
|
||||
export const enum State {
|
||||
CREATE_SESSION = 'CREATE_SESSION',
|
||||
@@ -199,6 +199,8 @@ export class InlineChatController1 implements IEditorContribution {
|
||||
|
||||
private readonly _sessionStore = this._store.add(new DisposableStore());
|
||||
private readonly _stashedSession = this._store.add(new MutableDisposable<StashedSession>());
|
||||
private _delegateSession?: IChatEditingSession;
|
||||
|
||||
private _session?: Session;
|
||||
private _strategy?: LiveStrategy;
|
||||
|
||||
@@ -238,6 +240,8 @@ export class InlineChatController1 implements IEditorContribution {
|
||||
selection: this._editor.getSelection(),
|
||||
document: this._session.textModelN.uri,
|
||||
wholeRange: this._session?.wholeRange.trackedInitialRange,
|
||||
close: () => this.cancelSession(),
|
||||
delegateSessionId: this._delegateSession?.chatSessionId,
|
||||
};
|
||||
}
|
||||
};
|
||||
@@ -488,6 +492,20 @@ export class InlineChatController1 implements IEditorContribution {
|
||||
this._messages.fire(msg);
|
||||
}));
|
||||
|
||||
const filePartOfEditSessions = this._chatService.editingSessions.filter(session =>
|
||||
session.entries.get().some(e => e.state.get() === ModifiedFileEntryState.Modified && e.modifiedURI.toString() === this._session!.textModelN.uri.toString())
|
||||
);
|
||||
|
||||
const withinEditSession = filePartOfEditSessions.find(session =>
|
||||
session.entries.get().some(e => e.state.get() === ModifiedFileEntryState.Modified && e.hasModificationAt({
|
||||
range: this._session!.wholeRange.trackedInitialRange,
|
||||
uri: this._session!.textModelN.uri
|
||||
}))
|
||||
);
|
||||
|
||||
const chatWidget = this._ui.value.widget.chatWidget;
|
||||
this._delegateSession = withinEditSession || filePartOfEditSessions[0];
|
||||
chatWidget.input.setIsWithinEditSession(!!withinEditSession, filePartOfEditSessions.length > 0);
|
||||
|
||||
this._sessionStore.add(this._editor.onDidChangeModelContent(e => {
|
||||
|
||||
@@ -586,6 +604,7 @@ export class InlineChatController1 implements IEditorContribution {
|
||||
}));
|
||||
store.add(this._strategy.onDidAccept(() => this.acceptSession()));
|
||||
store.add(this._strategy.onDidDiscard(() => this.cancelSession()));
|
||||
store.add(this.chatWidget.onDidHide(() => this.cancelSession()));
|
||||
store.add(Event.once(this._messages.event)(m => {
|
||||
this._log('state=_waitForInput) message received', m);
|
||||
message = m;
|
||||
@@ -1255,6 +1274,7 @@ export class InlineChatController2 implements IEditorContribution {
|
||||
@IEditorService private readonly _editorService: IEditorService,
|
||||
@IInlineChatSessionService inlineChatService: IInlineChatSessionService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IChatService chatService: IChatService,
|
||||
) {
|
||||
|
||||
const ctxInlineChatVisible = CTX_INLINE_CHAT_VISIBLE.bindTo(contextKeyService);
|
||||
@@ -1266,12 +1286,21 @@ export class InlineChatController2 implements IEditorContribution {
|
||||
location: ChatAgentLocation.EditorInline,
|
||||
resolveData: () => {
|
||||
assertType(this._editor.hasModel());
|
||||
const wholeRange = this._editor.getSelection();
|
||||
const document = this._editor.getModel().uri;
|
||||
|
||||
return {
|
||||
type: ChatAgentLocation.EditorInline,
|
||||
selection: this._editor.getSelection(),
|
||||
document: this._editor.getModel().uri,
|
||||
wholeRange: this._editor.getSelection(),
|
||||
document,
|
||||
wholeRange,
|
||||
close: () => this._showWidgetOverrideObs.set(false, undefined),
|
||||
delegateSessionId: chatService.editingSessions.find(session =>
|
||||
session.entries.get().some(e => e.hasModificationAt({
|
||||
range: wholeRange,
|
||||
uri: document
|
||||
}))
|
||||
)?.chatSessionId,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user