Fix invalid json files detected for claude hook paths#312016
Open
Fix invalid json files detected for claude hook paths#312016
Conversation
Contributor
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes hook file discovery so that configured specific .json hook paths (notably Claude’s .claude/settings*.json) are treated as individual files rather than causing sibling .json files in the same directory to be picked up.
Changes:
- Adjust hook location resolution to use a
searchRootconcept (file or directory) instead of always using a “parent folder”, preventing accidental inclusion of sibling.jsonfiles. - Update consumers of the resolved-folder metadata to use
searchRoot. - Add tests validating that hook discovery returns only targeted
.jsonfiles (and not sibling.jsonfiles).
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/test/common/promptSyntax/utils/promptFilesLocator.test.ts | Adds coverage for hook discovery to ensure only configured .json files are returned. |
| src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.ts | Changes resolution and scanning logic to use searchRoot for hook paths (file vs directory). |
| src/vs/workbench/contrib/chat/common/promptSyntax/config/promptFileLocations.ts | Renames resolved-folder metadata from parent to searchRoot. |
| src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptSourceFolder.ts | Updates picker logic to reference searchRoot instead of the removed parent property. |
Copilot's findings
Comments suppressed due to low confidence (1)
src/vs/workbench/contrib/chat/common/promptSyntax/utils/promptFilesLocator.ts:872
- The JSDoc for
resolveSearchLocationstill references the oldgetParentFoldername and{ parent, filePattern }shape in the example. Please update the example and wording to useresolveSearchLocation(...)and{ searchRoot, filePattern }so the docs match the actual API.
* assert.strictDeepEqual(
* getParentFolder(PromptsType.prompt, URI.file('/home/user/{folder1,folder2}/file.md')),
* { parent: URI.file('/home/user'), filePattern: '{folder1,folder2}/file.md' },
* 'Must find correct non-glob parent dirname.',
* );
- Files reviewed: 4/4 changed files
- Comments generated: 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor concept of
parentto be asearchRoot. In the case of hook files, we just need to watch specific files (settings.json) not folders.Fixes #304314