Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hide untitled file hint when inline chat session is starting #185244

Merged
merged 1 commit into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IContentActionHandler, renderFormattedText } from 'vs/base/browser/formattedTextRenderer';
import { ApplyFileSnippetAction } from 'vs/workbench/contrib/snippets/browser/commands/fileTemplateSnippets';
import { IInlineChatSessionService } from 'vs/workbench/contrib/inlineChat/browser/inlineChatSession';
import { isEqual } from 'vs/base/common/resources';

const $ = dom.$;

Expand All @@ -37,7 +39,7 @@ export class UntitledTextEditorHintContribution implements IEditorContribution {
@ICommandService private readonly commandService: ICommandService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IKeybindingService private readonly keybindingService: IKeybindingService,

@IInlineChatSessionService inlineChatSessionService: IInlineChatSessionService,
) {
this.toDispose = [];
this.toDispose.push(this.editor.onDidChangeModel(() => this.update()));
Expand All @@ -47,6 +49,11 @@ export class UntitledTextEditorHintContribution implements IEditorContribution {
this.update();
}
}));
this.toDispose.push(inlineChatSessionService.onWillStartSession(uri => {
if (isEqual(uri, this.editor.getModel()?.uri)) {
this.untitledTextHintContentWidget?.dispose();
}
}));
}

private update(): void {
Expand Down
15 changes: 14 additions & 1 deletion src/vs/workbench/contrib/inlineChat/browser/inlineChatSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { isEqual } from 'vs/base/common/resources';
import { URI } from 'vs/base/common/uri';
import { Event } from 'vs/base/common/event';
import { Emitter, Event } from 'vs/base/common/event';
import { ResourceEdit, ResourceFileEdit, ResourceTextEdit } from 'vs/editor/browser/services/bulkEditService';
import { TextEdit } from 'vs/editor/common/languages';
import { IModelDeltaDecoration, ITextModel } from 'vs/editor/common/model';
Expand Down Expand Up @@ -357,6 +357,8 @@ export const IInlineChatSessionService = createDecorator<IInlineChatSessionServi
export interface IInlineChatSessionService {
_serviceBrand: undefined;

onWillStartSession: Event<URI>;

createSession(editor: IActiveCodeEditor, options: { editMode: EditMode; wholeRange?: IRange }, token: CancellationToken): Promise<Session | undefined>;

getSession(editor: ICodeEditor, uri: URI): Session | undefined;
Expand All @@ -379,6 +381,9 @@ export class InlineChatSessionService implements IInlineChatSessionService {

declare _serviceBrand: undefined;

private readonly _onWillStartSession = new Emitter<URI>();
readonly onWillStartSession: Event<URI> = this._onWillStartSession.event;

private readonly _sessions = new Map<string, SessionData>();
private readonly _keyComputers = new Map<string, ISessionKeyComputer>();
private _recordings: Recording[] = [];
Expand All @@ -391,6 +396,12 @@ export class InlineChatSessionService implements IInlineChatSessionService {
@ILogService private readonly _logService: ILogService,
) { }

dispose() {
this._onWillStartSession.dispose();
this._sessions.forEach(x => x.store.dispose());
this._sessions.clear();
}


async createSession(editor: IActiveCodeEditor, options: { editMode: EditMode; wholeRange?: Range }, token: CancellationToken): Promise<Session | undefined> {

Expand All @@ -400,6 +411,8 @@ export class InlineChatSessionService implements IInlineChatSessionService {
return undefined;
}

this._onWillStartSession.fire(editor.getModel().uri);

const textModel = editor.getModel();
const selection = editor.getSelection();
let raw: IInlineChatSession | undefined | null;
Expand Down