mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 20:26:08 +00:00
Handle duplicate chat participant names (#208142)
* Enable duplicate chat participant names #208103 * Register participants with an ID * Update participant history in API * Changes to dupe chat suggest widget, and fix serialize/deserialize * Tweaks * Test fixes * Fix tests * Test fixes * Fix integration test
This commit is contained in:
@@ -65,6 +65,7 @@
|
||||
"contributes": {
|
||||
"chatParticipants": [
|
||||
{
|
||||
"id": "api-test.participant",
|
||||
"name": "participant",
|
||||
"description": "test",
|
||||
"isDefault": true,
|
||||
|
||||
@@ -30,7 +30,7 @@ suite('chat', () => {
|
||||
|
||||
function setupParticipant(): Event<{ request: ChatRequest; context: ChatContext }> {
|
||||
const emitter = new EventEmitter<{ request: ChatRequest; context: ChatContext }>();
|
||||
disposables.push();
|
||||
disposables.push(emitter);
|
||||
disposables.push(interactive.registerInteractiveSessionProvider('provider', {
|
||||
prepareSession: (_token: CancellationToken): ProviderResult<InteractiveSession> => {
|
||||
return {
|
||||
@@ -40,7 +40,7 @@ suite('chat', () => {
|
||||
},
|
||||
}));
|
||||
|
||||
const participant = chat.createChatParticipant('participant', (request, context, _progress, _token) => {
|
||||
const participant = chat.createChatParticipant('api-test.participant', (request, context, _progress, _token) => {
|
||||
emitter.fire({ request, context });
|
||||
return null;
|
||||
});
|
||||
@@ -49,12 +49,12 @@ suite('chat', () => {
|
||||
return emitter.event;
|
||||
}
|
||||
|
||||
test('participant and slash command', async () => {
|
||||
test('participant and slash command history', async () => {
|
||||
const onRequest = setupParticipant();
|
||||
commands.executeCommand('workbench.action.chat.open', { query: '@participant /hello friend' });
|
||||
|
||||
let i = 0;
|
||||
onRequest(request => {
|
||||
disposables.push(onRequest(request => {
|
||||
if (i === 0) {
|
||||
assert.deepStrictEqual(request.request.command, 'hello');
|
||||
assert.strictEqual(request.request.prompt, 'friend');
|
||||
@@ -62,10 +62,10 @@ suite('chat', () => {
|
||||
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.name, 'participant');
|
||||
assert.strictEqual(request.context.history[0].participant, 'api-test.participant');
|
||||
assert.strictEqual(request.context.history[0].command, 'hello');
|
||||
}
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
||||
test('participant and variable', async () => {
|
||||
@@ -93,7 +93,7 @@ suite('chat', () => {
|
||||
}));
|
||||
|
||||
const deferred = new DeferredPromise<ChatResult>();
|
||||
const participant = chat.createChatParticipant('participant', (_request, _context, _progress, _token) => {
|
||||
const participant = chat.createChatParticipant('api-test.participant', (_request, _context, _progress, _token) => {
|
||||
return { metadata: { key: 'value' } };
|
||||
});
|
||||
participant.isDefault = true;
|
||||
|
||||
Reference in New Issue
Block a user