Skip to content

promptService: cache IHookDiscoveryInfo#306734

Open
aeschli wants to merge 2 commits intomainfrom
aeschli/afraid-ladybug-356
Open

promptService: cache IHookDiscoveryInfo#306734
aeschli wants to merge 2 commits intomainfrom
aeschli/afraid-ladybug-356

Conversation

@aeschli
Copy link
Copy Markdown
Contributor

@aeschli aeschli commented Mar 31, 2026

No description provided.

Copilot AI review requested due to automatic review settings March 31, 2026 12:55
@aeschli aeschli enabled auto-merge (squash) March 31, 2026 12:55
@aeschli aeschli self-assigned this Mar 31, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates PromptsService hook loading to cache and emit full hook discovery diagnostics (IHookDiscoveryInfo) alongside the resolved hooks, improving observability and avoiding a second discovery pass during logging.

Changes:

  • Change the hooks cache (cachedHooks) to store IHookDiscoveryInfo (discovery + resolved hooks) instead of only IConfiguredHooksInfo | undefined.
  • Refactor hook computation to build discovery results (files, sourceFolders) in the same pass as hook collection, including parallel processing of hook files.
  • Add tests covering hook discovery logging behavior and Claude/setting interactions.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/vs/workbench/contrib/chat/test/common/promptSyntax/service/promptsService.test.ts Adds tests for hook discovery logging and a Claude hooks edge case.
src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.ts Refactors hook loading to compute/cache IHookDiscoveryInfo and log it directly.
src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsService.ts Introduces IHookDiscoveryInfo to pair discovery info with resolved hooks.

Comment on lines +3917 to +3919
const result = await service.getHooks(CancellationToken.None);
// No hooks should be collected (the only file has disableAllHooks)
assert.strictEqual(result, undefined, 'Expected no hooks result');
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test name/comment says it is validating hasDisabledClaudeHooks, but the assertions only check that getHooks() returns undefined. If the intent is to guard the hasDisabledClaudeHooks behavior, capture the hook discovery log (or otherwise access the discovery info) and assert on hooksInfo?.hasDisabledClaudeHooks (or adjust the test name/comments to match what’s actually being asserted).

Suggested change
const result = await service.getHooks(CancellationToken.None);
// No hooks should be collected (the only file has disableAllHooks)
assert.strictEqual(result, undefined, 'Expected no hooks result');
// Capture hook discovery info to verify hasDisabledClaudeHooks behavior.
const sessionResource = URI.file('/session');
let capturedDiscoveryInfo: IPromptDiscoveryInfo | undefined;
const logDisposable = service.onDidLogDiscovery((entry: IPromptDiscoveryLogEntry) => {
if (entry.discoveryInfo?.type === PromptsType.hook) {
capturedDiscoveryInfo = entry.discoveryInfo;
}
});
const result = await service.getHooks(CancellationToken.None, sessionResource);
logDisposable.dispose();
// No hooks should be collected (the only file has disableAllHooks)
assert.strictEqual(result, undefined, 'Expected no hooks result');
// Discovery info should be logged, but should not report Claude hooks as disabled
assert.ok(capturedDiscoveryInfo, 'Expected discovery info to be logged for hooks');
assert.notStrictEqual(capturedDiscoveryInfo!.hasDisabledClaudeHooks, true, 'Claude hooks should not be reported as disabled when Claude hooks are turned off');

Copilot uses AI. Check for mistakes.
chrmarti
chrmarti previously approved these changes Mar 31, 2026
…ptsServiceImpl.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants