Debug panel should only be available for local sessions (#297817)

This commit is contained in:
Paul
2026-02-25 18:22:36 -08:00
committed by GitHub
parent 46664389f9
commit f9d6c407d8
11 changed files with 98 additions and 57 deletions

View File

@@ -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 = {