mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-18 15:55:59 +01:00
Debug panel should only be available for local sessions (#297817)
This commit is contained in:
@@ -9,6 +9,7 @@ import { URI } from '../../../../../base/common/uri.js';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../../base/test/common/utils.js';
|
||||
import { ChatDebugLogLevel, IChatDebugEvent, IChatDebugGenericEvent, IChatDebugLogProvider, IChatDebugModelTurnEvent, IChatDebugResolvedEventContent, IChatDebugToolCallEvent } from '../../common/chatDebugService.js';
|
||||
import { ChatDebugServiceImpl } from '../../common/chatDebugServiceImpl.js';
|
||||
import { LocalChatSessionUri } from '../../common/model/chatUri.js';
|
||||
|
||||
suite('ChatDebugServiceImpl', () => {
|
||||
const disposables = ensureNoDisposablesAreLeakedInTestSuite();
|
||||
@@ -17,9 +18,10 @@ suite('ChatDebugServiceImpl', () => {
|
||||
|
||||
const session1 = URI.parse('vscode-chat-session://local/session-1');
|
||||
const session2 = URI.parse('vscode-chat-session://local/session-2');
|
||||
const sessionA = URI.parse('vscode-chat-session://local/a');
|
||||
const sessionB = URI.parse('vscode-chat-session://local/b');
|
||||
const sessionA = LocalChatSessionUri.forSession('a');
|
||||
const sessionB = LocalChatSessionUri.forSession('b');
|
||||
const sessionGeneric = URI.parse('vscode-chat-session://local/session');
|
||||
const nonLocalSession = URI.parse('vscode-chat-session://remote-provider/session-1');
|
||||
|
||||
setup(() => {
|
||||
service = disposables.add(new ChatDebugServiceImpl());
|
||||
@@ -145,6 +147,16 @@ suite('ChatDebugServiceImpl', () => {
|
||||
assert.strictEqual(event.category, 'testing');
|
||||
assert.strictEqual(event.parentEventId, 'parent-1');
|
||||
});
|
||||
|
||||
test('should not log events for non-local sessions', () => {
|
||||
const firedEvents: IChatDebugEvent[] = [];
|
||||
disposables.add(service.onDidAddEvent(e => firedEvents.push(e)));
|
||||
|
||||
service.log(nonLocalSession, 'should-be-skipped', 'details');
|
||||
|
||||
assert.strictEqual(firedEvents.length, 0);
|
||||
assert.strictEqual(service.getEvents(nonLocalSession).length, 0);
|
||||
});
|
||||
});
|
||||
|
||||
suite('getSessionResources', () => {
|
||||
@@ -319,6 +331,29 @@ suite('ChatDebugServiceImpl', () => {
|
||||
assert.strictEqual(tokenA.isCancellationRequested, false, 'session-a token should not be cancelled');
|
||||
});
|
||||
|
||||
test('should not invoke providers for non-local sessions', async () => {
|
||||
let providerCalled = false;
|
||||
|
||||
const provider: IChatDebugLogProvider = {
|
||||
provideChatDebugLog: async () => {
|
||||
providerCalled = true;
|
||||
return [{
|
||||
kind: 'generic',
|
||||
sessionResource: nonLocalSession,
|
||||
created: new Date(),
|
||||
name: 'should-not-appear',
|
||||
level: ChatDebugLogLevel.Info,
|
||||
}];
|
||||
},
|
||||
};
|
||||
|
||||
disposables.add(service.registerProvider(provider));
|
||||
await service.invokeProviders(nonLocalSession);
|
||||
|
||||
assert.strictEqual(providerCalled, false);
|
||||
assert.strictEqual(service.getEvents(nonLocalSession).length, 0);
|
||||
});
|
||||
|
||||
test('newly registered provider should be invoked for active sessions', async () => {
|
||||
// Start an invocation before the provider is registered
|
||||
const firstProvider: IChatDebugLogProvider = {
|
||||
|
||||
Reference in New Issue
Block a user