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

Fix #213206. Migrate off IInlineChatService #213263

Merged
merged 2 commits into from
May 23, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { Disposable, IDisposable, toDisposable } from 'vs/base/common/lifecycle'
import { IMarkerData, IMarkerService } from 'vs/platform/markers/common/markers';
import { IRange } from 'vs/editor/common/core/range';
import { ICellExecutionError, ICellExecutionStateChangedEvent, IExecutionStateChangedEvent, INotebookExecutionStateService, NotebookExecutionType } from 'vs/workbench/contrib/notebook/common/notebookExecutionStateService';
import { IInlineChatService } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { CellKind, NotebookSetting } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { INotebookEditor, INotebookEditorContribution } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
Expand All @@ -16,6 +15,7 @@ import { Iterable } from 'vs/base/common/iterator';
import { CodeCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel';
import { URI } from 'vs/base/common/uri';
import { Event } from 'vs/base/common/event';
import { IChatAgentService } from 'vs/workbench/contrib/chat/common/chatAgents';

type CellDiagnostic = {
cellUri: URI;
Expand All @@ -35,14 +35,14 @@ export class CellDiagnostics extends Disposable implements INotebookEditorContri
private readonly notebookEditor: INotebookEditor,
@INotebookExecutionStateService private readonly notebookExecutionStateService: INotebookExecutionStateService,
@IMarkerService private readonly markerService: IMarkerService,
@IInlineChatService private readonly inlineChatService: IInlineChatService,
@IChatAgentService private readonly chatAgentService: IChatAgentService,
@IConfigurationService private readonly configurationService: IConfigurationService
) {
super();

this.updateEnabled();

this._register(inlineChatService.onDidChangeProviders(() => this.updateEnabled()));
this._register(chatAgentService.onDidChangeAgents(() => this.updateEnabled()));
this._register(configurationService.onDidChangeConfiguration((e) => {
if (e.affectsConfiguration(NotebookSetting.cellFailureDiagnostics)) {
this.updateEnabled();
Expand All @@ -52,10 +52,10 @@ export class CellDiagnostics extends Disposable implements INotebookEditorContri

private updateEnabled() {
const settingEnabled = this.configurationService.getValue(NotebookSetting.cellFailureDiagnostics);
if (this.enabled && (!settingEnabled || Iterable.isEmpty(this.inlineChatService.getAllProvider()))) {
if (this.enabled && (!settingEnabled || Iterable.isEmpty(this.chatAgentService.getAgents()))) {
this.enabled = false;
this.clearAll();
} else if (!this.enabled && settingEnabled && !Iterable.isEmpty(this.inlineChatService.getAllProvider())) {
} else if (!this.enabled && settingEnabled && !Iterable.isEmpty(this.chatAgentService.getAgents())) {
this.enabled = true;
if (!this.listening) {
this.listening = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import * as assert from 'assert';
import { Emitter } from 'vs/base/common/event';
import { Emitter, Event } from 'vs/base/common/event';
import { DisposableStore } from 'vs/base/common/lifecycle';
import { ResourceMap } from 'vs/base/common/map';
import { waitForState } from 'vs/base/common/observable';
Expand All @@ -15,12 +15,13 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
import { IMarkerData, IMarkerService } from 'vs/platform/markers/common/markers';
import { IInlineChatService, IInlineChatSessionProvider } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { ChatAgentLocation, IChatAgent, IChatAgentData, IChatAgentService } from 'vs/workbench/contrib/chat/common/chatAgents';
import { CellDiagnostics } from 'vs/workbench/contrib/notebook/browser/contrib/cellDiagnostics/cellDiagnosticEditorContrib';
import { CodeCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel';
import { CellKind, NotebookSetting } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { ICellExecutionStateChangedEvent, IExecutionStateChangedEvent, INotebookCellExecution, INotebookExecutionStateService, NotebookExecutionType } from 'vs/workbench/contrib/notebook/common/notebookExecutionStateService';
import { setupInstantiationService, TestNotebookExecutionStateService, withTestNotebook } from 'vs/workbench/contrib/notebook/test/browser/testNotebookEditor';
import { nullExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';


suite('notebookCellDiagnostics', () => {
Expand Down Expand Up @@ -64,8 +65,26 @@ suite('notebookCellDiagnostics', () => {
testExecutionService = new TestExecutionService();
instantiationService.stub(INotebookExecutionStateService, testExecutionService);

const chatProviders = instantiationService.get<IInlineChatService>(IInlineChatService);
disposables.add(chatProviders.addProvider({} as IInlineChatSessionProvider));
const agentData = {
extensionId: nullExtensionDescription.identifier,
extensionDisplayName: '',
extensionPublisherId: '',
name: 'testEditorAgent',
isDefault: true,
locations: [ChatAgentLocation.Editor],
metadata: {},
slashCommands: []
};
const chatAgentService = new class extends mock<IChatAgentService>() {
override getAgents(): IChatAgentData[] {
return [{
id: 'testEditorAgent',
...agentData
}];
}
override onDidChangeAgents: Event<IChatAgent | undefined> = Event.None;
};
instantiationService.stub(IChatAgentService, chatAgentService);

markerService = new class extends mock<ITestMarkerService>() {
override markers: ResourceMap<IMarkerData[]> = new ResourceMap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ import { EditorFontLigatures, EditorFontVariations } from 'vs/editor/common/conf
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
import { mainWindow } from 'vs/base/browser/window';
import { TestCodeEditorService } from 'vs/editor/test/browser/editorTestServices';
import { IInlineChatService } from 'vs/workbench/contrib/inlineChat/common/inlineChat';
import { InlineChatServiceImpl } from 'vs/workbench/contrib/inlineChat/common/inlineChatServiceImpl';
import { INotebookCellOutlineProviderFactory, NotebookCellOutlineProviderFactory } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineProviderFactory';
import { ILanguageDetectionService } from 'vs/workbench/services/languageDetection/common/languageDetectionWorkerService';

Expand Down Expand Up @@ -201,7 +199,6 @@ export function setupInstantiationService(disposables: DisposableStore) {
instantiationService.stub(IKeybindingService, new MockKeybindingService());
instantiationService.stub(INotebookCellStatusBarService, disposables.add(new NotebookCellStatusBarService()));
instantiationService.stub(ICodeEditorService, disposables.add(new TestCodeEditorService(testThemeService)));
instantiationService.stub(IInlineChatService, instantiationService.createInstance(InlineChatServiceImpl));
instantiationService.stub(INotebookCellOutlineProviderFactory, instantiationService.createInstance(NotebookCellOutlineProviderFactory));

instantiationService.stub(ILanguageDetectionService, new class MockLanguageDetectionService implements ILanguageDetectionService {
Expand Down
Loading