diff --git a/src/vs/workbench/contrib/chat/browser/promptsDebugContribution.ts b/src/vs/workbench/contrib/chat/browser/promptsDebugContribution.ts index 9620797fe5e..964f68d2ac0 100644 --- a/src/vs/workbench/contrib/chat/browser/promptsDebugContribution.ts +++ b/src/vs/workbench/contrib/chat/browser/promptsDebugContribution.ts @@ -7,7 +7,6 @@ import { Disposable } from '../../../../base/common/lifecycle.js'; import { generateUuid } from '../../../../base/common/uuid.js'; import { IWorkbenchContribution } from '../../../common/contributions.js'; import { IChatDebugResolvedEventContent, IChatDebugService } from '../common/chatDebugService.js'; -import { LocalChatSessionUri } from '../common/model/chatUri.js'; import { IPromptDiscoveryInfo, IPromptsService } from '../common/promptSyntax/service/promptsService.js'; /** @@ -53,7 +52,7 @@ export class PromptsDebugContribution extends Disposable implements IWorkbenchCo } chatDebugService.log( - LocalChatSessionUri.forSession(entry.sessionId), + entry.sessionResource, entry.name, entry.details, undefined, diff --git a/src/vs/workbench/contrib/chat/browser/widget/chatWidget.ts b/src/vs/workbench/contrib/chat/browser/widget/chatWidget.ts index 16e96f0e435..21453356496 100644 --- a/src/vs/workbench/contrib/chat/browser/widget/chatWidget.ts +++ b/src/vs/workbench/contrib/chat/browser/widget/chatWidget.ts @@ -2826,8 +2826,8 @@ export class ChatWidget extends Disposable implements IChatWidget { this.logService.debug(`ChatWidget#_autoAttachInstructions: prompt files are always enabled`); const enabledTools = this.input.currentModeKind === ChatModeKind.Agent ? this.input.selectedToolsModel.userSelectedTools.get() : undefined; const enabledSubAgents = this.input.currentModeKind === ChatModeKind.Agent ? this.input.currentModeObs.get().agents?.get() : undefined; - const sessionId = this._viewModel?.model.sessionId; - const computer = this.instantiationService.createInstance(ComputeAutomaticInstructions, this.input.currentModeKind, enabledTools, enabledSubAgents, sessionId); + const sessionResource = this._viewModel?.model.sessionResource; + const computer = this.instantiationService.createInstance(ComputeAutomaticInstructions, this.input.currentModeKind, enabledTools, enabledSubAgents, sessionResource); await computer.collect(attachedContext, CancellationToken.None); } diff --git a/src/vs/workbench/contrib/chat/common/chatDebugServiceImpl.ts b/src/vs/workbench/contrib/chat/common/chatDebugServiceImpl.ts index f9787ed7978..cce684e6d5b 100644 --- a/src/vs/workbench/contrib/chat/common/chatDebugServiceImpl.ts +++ b/src/vs/workbench/contrib/chat/common/chatDebugServiceImpl.ts @@ -10,6 +10,7 @@ import { Disposable, IDisposable, toDisposable } from '../../../../base/common/l import { ResourceMap } from '../../../../base/common/map.js'; import { URI } from '../../../../base/common/uri.js'; import { ChatDebugLogLevel, IChatDebugEvent, IChatDebugLogProvider, IChatDebugResolvedEventContent, IChatDebugService } from './chatDebugService.js'; +import { LocalChatSessionUri } from './model/chatUri.js'; export class ChatDebugServiceImpl extends Disposable implements IChatDebugService { declare readonly _serviceBrand: undefined; @@ -33,6 +34,9 @@ export class ChatDebugServiceImpl extends Disposable implements IChatDebugServic activeSessionResource: URI | undefined; log(sessionResource: URI, name: string, details?: string, level: ChatDebugLogLevel = ChatDebugLogLevel.Info, options?: { id?: string; category?: string; parentEventId?: string }): void { + if (!LocalChatSessionUri.isLocalSession(sessionResource)) { + return; + } this.addEvent({ kind: 'generic', id: options?.id, @@ -118,6 +122,10 @@ export class ChatDebugServiceImpl extends Disposable implements IChatDebugServic } async invokeProviders(sessionResource: URI): Promise { + if (!LocalChatSessionUri.isLocalSession(sessionResource)) { + return; + } + // Cancel only the previous invocation for THIS session, not others. // Each session has its own pipeline so events from multiple sessions // can be streamed concurrently. diff --git a/src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts b/src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts index d92c02ee695..ab5981ff799 100644 --- a/src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts +++ b/src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts @@ -954,7 +954,7 @@ export class ChatService extends Disposable implements IChatService { let collectedHooks: IChatRequestHooks | undefined; let hasDisabledClaudeHooks = false; try { - const hooksInfo = await this.promptsService.getHooks(token, model.sessionId); + const hooksInfo = await this.promptsService.getHooks(token, model.sessionResource); if (hooksInfo) { collectedHooks = hooksInfo.hooks; hasDisabledClaudeHooks = hooksInfo.hasDisabledClaudeHooks; diff --git a/src/vs/workbench/contrib/chat/common/promptSyntax/computeAutomaticInstructions.ts b/src/vs/workbench/contrib/chat/common/promptSyntax/computeAutomaticInstructions.ts index 62b01c294e5..16b5459a50c 100644 --- a/src/vs/workbench/contrib/chat/common/promptSyntax/computeAutomaticInstructions.ts +++ b/src/vs/workbench/contrib/chat/common/promptSyntax/computeAutomaticInstructions.ts @@ -63,7 +63,7 @@ export class ComputeAutomaticInstructions { private readonly _modeKind: ChatModeKind, private readonly _enabledTools: UserSelectedTools | undefined, private readonly _enabledSubagents: (readonly string[]) | undefined, - private readonly _sessionId: string | undefined, + private readonly _sessionResource: URI | undefined, @IPromptsService private readonly _promptsService: IPromptsService, @ILogService public readonly _logService: ILogService, @ILabelService private readonly _labelService: ILabelService, @@ -93,7 +93,7 @@ export class ComputeAutomaticInstructions { public async collect(variables: ChatRequestVariableSet, token: CancellationToken): Promise { - const instructionFiles = await this._promptsService.getInstructionFiles(token, this._sessionId); + const instructionFiles = await this._promptsService.getInstructionFiles(token, this._sessionResource); this._logService.trace(`[InstructionsContextComputer] ${instructionFiles.length} instruction files available.`); @@ -354,7 +354,7 @@ export class ComputeAutomaticInstructions { entries.push('', '', ''); // add trailing newline } - const agentSkills = await this._promptsService.findAgentSkills(token, this._sessionId); + const agentSkills = await this._promptsService.findAgentSkills(token, this._sessionResource); // Filter out skills with disableModelInvocation=true (they can only be triggered manually via /name) const modelInvocableSkills = agentSkills?.filter(skill => !skill.disableModelInvocation); if (modelInvocableSkills && modelInvocableSkills.length > 0) { @@ -400,7 +400,7 @@ export class ComputeAutomaticInstructions { return (agent: ICustomAgent) => subagents.includes(agent.name); } })(); - const agents = await this._promptsService.getCustomAgents(token, this._sessionId); + const agents = await this._promptsService.getCustomAgents(token, this._sessionResource); if (agents.length > 0) { entries.push(''); entries.push('Here is a list of agents that can be used when running a subagent.'); diff --git a/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.ts b/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.ts index a2ca1942cf0..73f48099a13 100644 --- a/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.ts +++ b/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.ts @@ -22,7 +22,7 @@ import { IResolvedPromptSourceFolder } from '../config/promptFileLocations.js'; * A debug bridge (e.g. contribution) can listen and forward these to IChatDebugService. */ export interface IPromptDiscoveryLogEntry { - readonly sessionId: string; + readonly sessionResource: URI; readonly name: string; readonly details?: string; readonly category?: string; @@ -410,9 +410,9 @@ export interface IPromptsService extends IDisposable { /** * Returns a prompt command if the command name is valid. - * @param sessionId Optional session ID to scope debug logging to a specific session. + * @param sessionResource Optional session resource to scope debug logging to a specific session. */ - getPromptSlashCommands(token: CancellationToken, sessionId?: string): Promise; + getPromptSlashCommands(token: CancellationToken, sessionResource?: URI): Promise; /** * Returns the prompt command name for the given URI. @@ -426,9 +426,9 @@ export interface IPromptsService extends IDisposable { /** * Finds all available custom agents - * @param sessionId Optional session ID to scope debug logging to a specific session. + * @param sessionResource Optional session resource to scope debug logging to a specific session. */ - getCustomAgents(token: CancellationToken, sessionId?: string): Promise; + getCustomAgents(token: CancellationToken, sessionResource?: URI): Promise; /** * Parses the provided URI @@ -486,30 +486,30 @@ export interface IPromptsService extends IDisposable { /** * Gets list of agent skills files. - * @param sessionId Optional session ID to scope debug logging to a specific session. + * @param sessionResource Optional session resource to scope debug logging to a specific session. */ - findAgentSkills(token: CancellationToken, sessionId?: string): Promise; + findAgentSkills(token: CancellationToken, sessionResource?: URI): Promise; /** * Gets detailed discovery information for a prompt type. * This includes all files found and their load/skip status with reasons. * Used for diagnostics and config-info displays. - * @param sessionId Optional session ID to scope debug logging to a specific session. + * @param sessionResource Optional session resource to scope debug logging to a specific session. */ - getPromptDiscoveryInfo(type: PromptsType, token: CancellationToken, sessionId?: string): Promise; + getPromptDiscoveryInfo(type: PromptsType, token: CancellationToken, sessionResource?: URI): Promise; /** * Gets all hooks collected from hooks.json files. * The result is cached and invalidated when hook files change. - * @param sessionId Optional session ID to scope debug logging to a specific session. + * @param sessionResource Optional session resource to scope debug logging to a specific session. */ - getHooks(token: CancellationToken, sessionId?: string): Promise; + getHooks(token: CancellationToken, sessionResource?: URI): Promise; /** * Gets all instruction files, logging discovery info to the debug log. - * @param sessionId Optional session ID to scope debug logging to a specific session. + * @param sessionResource Optional session resource to scope debug logging to a specific session. */ - getInstructionFiles(token: CancellationToken, sessionId?: string): Promise; + getInstructionFiles(token: CancellationToken, sessionResource?: URI): Promise; /** * Fired when a discovery-related log entry is produced. diff --git a/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.ts b/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.ts index 927def920ce..15e82a42860 100644 --- a/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.ts +++ b/src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.ts @@ -574,7 +574,7 @@ export class PromptsService extends Disposable implements IPromptsService { return this.cachedSlashCommands.onDidChange; } - public async getPromptSlashCommands(token: CancellationToken, sessionId?: string): Promise { + public async getPromptSlashCommands(token: CancellationToken, sessionResource?: URI): Promise { return await this.cachedSlashCommands.get(token); } @@ -648,17 +648,17 @@ export class PromptsService extends Disposable implements IPromptsService { return this.cachedCustomAgents.onDidChange; } - public async getCustomAgents(token: CancellationToken, sessionId?: string): Promise { + public async getCustomAgents(token: CancellationToken, sessionResource?: URI): Promise { const sw = StopWatch.create(); const result = await this.cachedCustomAgents.get(token); - if (sessionId) { + if (sessionResource) { const elapsed = sw.elapsed(); const discoveryInfo = await this.getAgentDiscoveryInfo(token); const details = result.length === 1 ? localize("promptsService.resolvedAgent", "Resolved {0} agent in {1}ms", result.length, elapsed.toFixed(1)) : localize("promptsService.resolvedAgents", "Resolved {0} agents in {1}ms", result.length, elapsed.toFixed(1)); this._onDidLogDiscovery.fire({ - sessionId, + sessionResource, name: localize("promptsService.loadAgents", "Load Agents"), details, discoveryInfo, @@ -1042,7 +1042,7 @@ export class PromptsService extends Disposable implements IPromptsService { return this.cachedSkills.onDidChange; } - public async findAgentSkills(token: CancellationToken, sessionId?: string): Promise { + public async findAgentSkills(token: CancellationToken, sessionResource?: URI): Promise { const useAgentSkills = this.configurationService.getValue(PromptsConfig.USE_AGENT_SKILLS); if (!useAgentSkills) { return undefined; @@ -1050,14 +1050,14 @@ export class PromptsService extends Disposable implements IPromptsService { const sw = StopWatch.create(); const result = await this.cachedSkills.get(token); - if (sessionId) { + if (sessionResource) { const elapsed = sw.elapsed(); const discoveryInfo = await this.getSkillDiscoveryInfo(token); const details = result.length === 1 ? localize("promptsService.resolvedSkill", "Resolved {0} skill in {1}ms", result.length, elapsed.toFixed(1)) : localize("promptsService.resolvedSkills", "Resolved {0} skills in {1}ms", result.length, elapsed.toFixed(1)); this._onDidLogDiscovery.fire({ - sessionId, + sessionResource, name: localize("promptsService.loadSkills", "Load Skills"), details, discoveryInfo, @@ -1170,10 +1170,10 @@ export class PromptsService extends Disposable implements IPromptsService { return result; } - public async getHooks(token: CancellationToken, sessionId?: string): Promise { + public async getHooks(token: CancellationToken, sessionResource?: URI): Promise { const sw = StopWatch.create(); const result = await this.cachedHooks.get(token); - if (sessionId) { + if (sessionResource) { const elapsed = sw.elapsed(); const hookCount = result ? Object.values(result.hooks).reduce((sum, arr) => sum + arr.length, 0) : 0; const discoveryInfo = await this.getHookDiscoveryInfo(token); @@ -1181,7 +1181,7 @@ export class PromptsService extends Disposable implements IPromptsService { ? localize("promptsService.resolvedHook", "Resolved {0} hook in {1}ms", hookCount, elapsed.toFixed(1)) : localize("promptsService.resolvedHooks", "Resolved {0} hooks in {1}ms", hookCount, elapsed.toFixed(1)); this._onDidLogDiscovery.fire({ - sessionId, + sessionResource, name: localize("promptsService.loadHooks", "Load Hooks"), details, discoveryInfo, @@ -1191,17 +1191,17 @@ export class PromptsService extends Disposable implements IPromptsService { return result; } - public async getInstructionFiles(token: CancellationToken, sessionId?: string): Promise { + public async getInstructionFiles(token: CancellationToken, sessionResource?: URI): Promise { const sw = StopWatch.create(); const result = await this.listPromptFiles(PromptsType.instructions, token); - if (sessionId) { + if (sessionResource) { const elapsed = sw.elapsed(); const discoveryInfo = await this.getInstructionsDiscoveryInfo(token); const details = result.length === 1 ? localize("promptsService.resolvedInstruction", "Resolved {0} instruction in {1}ms", result.length, elapsed.toFixed(1)) : localize("promptsService.resolvedInstructions", "Resolved {0} instructions in {1}ms", result.length, elapsed.toFixed(1)); this._onDidLogDiscovery.fire({ - sessionId, + sessionResource, name: localize("promptsService.loadInstructions", "Load Instructions"), details, discoveryInfo, @@ -1304,10 +1304,10 @@ export class PromptsService extends Disposable implements IPromptsService { return { hooks: result, hasDisabledClaudeHooks }; } - public async getPromptDiscoveryInfo(type: PromptsType, token: CancellationToken, sessionId?: string): Promise { - if (sessionId) { + public async getPromptDiscoveryInfo(type: PromptsType, token: CancellationToken, sessionResource?: URI): Promise { + if (sessionResource) { this._onDidLogDiscovery.fire({ - sessionId, + sessionResource, name: localize("promptsService.discoveryStart", "Discovery {0} (Start)", type), category: 'discovery', }); @@ -1338,7 +1338,7 @@ export class PromptsService extends Disposable implements IPromptsService { result = { ...result, sourceFolders }; } - if (sessionId) { + if (sessionResource) { const details = localize( "promptsService.discoveryResult", "{0} loaded, {1} skipped", @@ -1346,7 +1346,7 @@ export class PromptsService extends Disposable implements IPromptsService { skippedCount, ); this._onDidLogDiscovery.fire({ - sessionId, + sessionResource, name: localize("promptsService.discoveryEnd", "Discovery {0} (End)", type), details, discoveryInfo: result, diff --git a/src/vs/workbench/contrib/chat/common/tools/builtinTools/runSubagentTool.ts b/src/vs/workbench/contrib/chat/common/tools/builtinTools/runSubagentTool.ts index fe31a470b1d..bf441cf3d5e 100644 --- a/src/vs/workbench/contrib/chat/common/tools/builtinTools/runSubagentTool.ts +++ b/src/vs/workbench/contrib/chat/common/tools/builtinTools/runSubagentTool.ts @@ -20,7 +20,6 @@ import { IChatProgress, IChatService } from '../../chatService/chatService.js'; import { ChatAgentLocation, ChatConfiguration, ChatModeKind } from '../../constants.js'; import { ILanguageModelsService } from '../../languageModels.js'; import { ChatModel, IChatRequestModeInstructions } from '../../model/chatModel.js'; -import { chatSessionResourceToId } from '../../model/chatUri.js'; import { IChatAgentRequest, IChatAgentService } from '../../participants/chatAgents.js'; import { ComputeAutomaticInstructions } from '../../promptSyntax/computeAutomaticInstructions.js'; import { IChatRequestHooks } from '../../promptSyntax/hookSchema.js'; @@ -245,14 +244,13 @@ export class RunSubagentTool extends Disposable implements IToolImpl { } const variableSet = new ChatRequestVariableSet(); - const sessionId = chatSessionResourceToId(invocation.context.sessionResource); - const computer = this.instantiationService.createInstance(ComputeAutomaticInstructions, ChatModeKind.Agent, modeTools, undefined, sessionId); // agents can not call subagents + const computer = this.instantiationService.createInstance(ComputeAutomaticInstructions, ChatModeKind.Agent, modeTools, undefined, invocation.context.sessionResource); // agents can not call subagents await computer.collect(variableSet, token); // Collect hooks from hook .json files let collectedHooks: IChatRequestHooks | undefined; try { - const info = await this.promptsService.getHooks(token, chatSessionResourceToId(invocation.context.sessionResource)); + const info = await this.promptsService.getHooks(token, invocation.context.sessionResource); collectedHooks = info?.hooks; } catch (error) { this.logService.warn('[ChatService] Failed to collect hooks:', error); diff --git a/src/vs/workbench/contrib/chat/test/browser/promptsDebugContribution.test.ts b/src/vs/workbench/contrib/chat/test/browser/promptsDebugContribution.test.ts index 2233f9cd992..f5045a72ed8 100644 --- a/src/vs/workbench/contrib/chat/test/browser/promptsDebugContribution.test.ts +++ b/src/vs/workbench/contrib/chat/test/browser/promptsDebugContribution.test.ts @@ -10,6 +10,7 @@ import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../../base/tes import { TestInstantiationService } from '../../../../../platform/instantiation/test/common/instantiationServiceMock.js'; import { ChatDebugLogLevel, IChatDebugEvent, IChatDebugGenericEvent, IChatDebugService } from '../../common/chatDebugService.js'; import { ChatDebugServiceImpl } from '../../common/chatDebugServiceImpl.js'; +import { LocalChatSessionUri } from '../../common/model/chatUri.js'; import { PromptsDebugContribution } from '../../browser/promptsDebugContribution.js'; import { IPromptDiscoveryLogEntry, IPromptDiscoveryInfo, IPromptsService, PromptsStorage } from '../../common/promptSyntax/service/promptsService.js'; import { PromptsType } from '../../common/promptSyntax/promptTypes.js'; @@ -38,7 +39,7 @@ suite('PromptsDebugContribution', () => { disposables.add(chatDebugService.onDidAddEvent(e => firedEvents.push(e))); promptsOnDidLogDiscovery.fire({ - sessionId: 'session-1', + sessionResource: LocalChatSessionUri.forSession('session-1'), name: 'Load Instructions', details: 'Resolved 3 instructions in 12.5ms', category: 'discovery', @@ -76,7 +77,7 @@ suite('PromptsDebugContribution', () => { }; promptsOnDidLogDiscovery.fire({ - sessionId: 'session-1', + sessionResource: LocalChatSessionUri.forSession('session-1'), name: 'Discovery End', details: '1 loaded, 0 skipped', category: 'discovery', @@ -114,7 +115,7 @@ suite('PromptsDebugContribution', () => { disposables.add(chatDebugService.onDidAddEvent(e => firedEvents.push(e))); promptsOnDidLogDiscovery.fire({ - sessionId: 'session-1', + sessionResource: LocalChatSessionUri.forSession('session-1'), name: 'Discovery Start', category: 'discovery', }); @@ -149,7 +150,7 @@ suite('PromptsDebugContribution', () => { }; promptsOnDidLogDiscovery.fire({ - sessionId: 'session-1', + sessionResource: LocalChatSessionUri.forSession('session-1'), name: 'Discovery End', discoveryInfo, }); @@ -172,7 +173,7 @@ suite('PromptsDebugContribution', () => { disposables.add(chatDebugService.onDidAddEvent(e => firedEvents.push(e))); promptsOnDidLogDiscovery.fire({ - sessionId: 'session-1', + sessionResource: LocalChatSessionUri.forSession('session-1'), name: 'Test', }); diff --git a/src/vs/workbench/contrib/chat/test/common/chatDebugServiceImpl.test.ts b/src/vs/workbench/contrib/chat/test/common/chatDebugServiceImpl.test.ts index a0df375b4c3..5a247eaea99 100644 --- a/src/vs/workbench/contrib/chat/test/common/chatDebugServiceImpl.test.ts +++ b/src/vs/workbench/contrib/chat/test/common/chatDebugServiceImpl.test.ts @@ -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 = { diff --git a/src/vs/workbench/contrib/chat/test/common/promptSyntax/service/mockPromptsService.ts b/src/vs/workbench/contrib/chat/test/common/promptSyntax/service/mockPromptsService.ts index d222b92eb68..e01bc0089f0 100644 --- a/src/vs/workbench/contrib/chat/test/common/promptSyntax/service/mockPromptsService.ts +++ b/src/vs/workbench/contrib/chat/test/common/promptSyntax/service/mockPromptsService.ts @@ -31,7 +31,7 @@ export class MockPromptsService implements IPromptsService { this._onDidChangeCustomChatModes.fire(); } - async getCustomAgents(token: CancellationToken, sessionId?: string): Promise { + async getCustomAgents(token: CancellationToken, sessionResource?: URI): Promise { return this._customModes; } @@ -50,7 +50,7 @@ export class MockPromptsService implements IPromptsService { resolvePromptSlashCommand(command: string, _token: CancellationToken): Promise { throw new Error('Not implemented'); } get onDidChangeSlashCommands(): Event { throw new Error('Not implemented'); } // eslint-disable-next-line @typescript-eslint/no-explicit-any - getPromptSlashCommands(_token: CancellationToken, _sessionId?: string): Promise { throw new Error('Not implemented'); } + getPromptSlashCommands(_token: CancellationToken, _sessionResource?: URI): Promise { throw new Error('Not implemented'); } getPromptSlashCommandName(uri: URI, _token: CancellationToken): Promise { throw new Error('Not implemented'); } // eslint-disable-next-line @typescript-eslint/no-explicit-any parse(_uri: URI, _type: any, _token: CancellationToken): Promise { throw new Error('Not implemented'); } @@ -65,11 +65,11 @@ export class MockPromptsService implements IPromptsService { getDisabledPromptFiles(type: PromptsType): ResourceSet { throw new Error('Method not implemented.'); } setDisabledPromptFiles(type: PromptsType, uris: ResourceSet): void { throw new Error('Method not implemented.'); } registerPromptFileProvider(extension: IExtensionDescription, type: PromptsType, provider: { providePromptFiles: (context: IPromptFileContext, token: CancellationToken) => Promise }): IDisposable { throw new Error('Method not implemented.'); } - findAgentSkills(token: CancellationToken, sessionId?: string): Promise { throw new Error('Method not implemented.'); } + findAgentSkills(token: CancellationToken, sessionResource?: URI): Promise { throw new Error('Method not implemented.'); } // eslint-disable-next-line @typescript-eslint/no-explicit-any - getPromptDiscoveryInfo(_type: any, _token: CancellationToken, _sessionId?: string): Promise { throw new Error('Method not implemented.'); } + getPromptDiscoveryInfo(_type: any, _token: CancellationToken, _sessionResource?: URI): Promise { throw new Error('Method not implemented.'); } // eslint-disable-next-line @typescript-eslint/no-explicit-any - getHooks(_token: CancellationToken): Promise { throw new Error('Method not implemented.'); } - getInstructionFiles(_token: CancellationToken, _sessionId?: string): Promise { throw new Error('Method not implemented.'); } + getHooks(_token: CancellationToken, _sessionResource?: URI): Promise { throw new Error('Method not implemented.'); } + getInstructionFiles(_token: CancellationToken, _sessionResource?: URI): Promise { throw new Error('Method not implemented.'); } dispose(): void { } }