Kill "interactive session provider" DEAD (#209700)

* Reduce chat provider usage

* Clear out IChat props

* Delete interactive session provider API

* Totally remove static chat provider registration

* Clean up onDidRegisterProvider events

* Remove provider ID references from model

* Eliminate many 'providerId' references

* Simplify view registration

* Clean up participant-specific actions

* Delete getProviderInfos

* Rename context key

* Fix tests

* Fix action label

* Fix view title

* Fix test

* Fix test

* Fix integration test

* Remove more providerId

* Add API stub to make this compatible with the existing Copilot Chat
This commit is contained in:
Rob Lourens
2024-04-08 01:06:43 -03:00
committed by GitHub
parent 8af2f4e3bf
commit ed6c6d3f28
64 changed files with 626 additions and 1530 deletions

View File

@@ -5,7 +5,7 @@
import * as assert from 'assert';
import 'mocha';
import { commands, CancellationToken, ChatContext, ChatRequest, ChatResult, ChatVariableLevel, Disposable, Event, EventEmitter, InteractiveSession, ProviderResult, chat, interactive } from 'vscode';
import { ChatContext, ChatRequest, ChatResult, ChatVariableLevel, Disposable, Event, EventEmitter, chat, commands } from 'vscode';
import { DeferredPromise, assertNoRpc, closeAllEditors, disposeAll } from '../utils';
suite('chat', () => {
@@ -31,14 +31,6 @@ suite('chat', () => {
function setupParticipant(): Event<{ request: ChatRequest; context: ChatContext }> {
const emitter = new EventEmitter<{ request: ChatRequest; context: ChatContext }>();
disposables.push(emitter);
disposables.push(interactive.registerInteractiveSessionProvider('provider', {
prepareSession: (_token: CancellationToken): ProviderResult<InteractiveSession> => {
return {
requester: { name: 'test' },
responder: { name: 'test' },
};
},
}));
const participant = chat.createChatParticipant('api-test.participant', (request, context, _progress, _token) => {
emitter.fire({ request, context });
@@ -52,19 +44,29 @@ suite('chat', () => {
const onRequest = setupParticipant();
commands.executeCommand('workbench.action.chat.open', { query: '@participant /hello friend' });
const deferred = new DeferredPromise<void>();
let i = 0;
disposables.push(onRequest(request => {
if (i === 0) {
assert.deepStrictEqual(request.request.command, 'hello');
assert.strictEqual(request.request.prompt, 'friend');
i++;
commands.executeCommand('workbench.action.chat.open', { query: '@participant /hello friend' });
} else {
assert.strictEqual(request.context.history.length, 1);
assert.strictEqual(request.context.history[0].participant, 'api-test.participant');
assert.strictEqual(request.context.history[0].command, 'hello');
try {
if (i === 0) {
assert.deepStrictEqual(request.request.command, 'hello');
assert.strictEqual(request.request.prompt, 'friend');
i++;
setTimeout(() => {
commands.executeCommand('workbench.action.chat.open', { query: '@participant /hello friend' });
}, 0);
} else {
assert.strictEqual(request.context.history.length, 2);
assert.strictEqual(request.context.history[0].participant, 'api-test.participant');
assert.strictEqual(request.context.history[0].command, 'hello');
deferred.complete();
}
} catch (e) {
deferred.error(e);
}
}));
await deferred.p;
});
test('participant and variable', async () => {
@@ -82,15 +84,6 @@ suite('chat', () => {
});
test('result metadata is returned to the followup provider', async () => {
disposables.push(interactive.registerInteractiveSessionProvider('provider', {
prepareSession: (_token: CancellationToken): ProviderResult<InteractiveSession> => {
return {
requester: { name: 'test' },
responder: { name: 'test' },
};
},
}));
const deferred = new DeferredPromise<ChatResult>();
const participant = chat.createChatParticipant('api-test.participant', (_request, _context, _progress, _token) => {
return { metadata: { key: 'value' } };