Skip to content

Conversation

@pwang347
Copy link
Member

@pwang347 pwang347 commented Jan 9, 2026

image

This affects all file uri renderings for uris that are agent skills. Alternatively, I could pass a flag from the uri itself to signal to render as a skill (and with the skill name), but I think it is cleaner to handle it in the general case here so that we can easily extend to other types in the future.

Copy link
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 adds custom rendering for agent skills in chat by displaying the skill name instead of the file path. The implementation introduces a caching layer for agent skills to enable synchronous lookups by URI.

Key changes:

  • Adds a new getSkillByUri method to IPromptsService for synchronous skill lookups
  • Implements a cachedSkillsByUri cache that is populated when findAgentSkills is called
  • Updates InlineAnchorWidget to display skill names instead of file paths when rendering skill references

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/common/promptSyntax/service/promptsService.ts Adds the getSkillByUri interface method with documentation
src/vs/workbench/contrib/chat/common/promptSyntax/service/promptsServiceImpl.ts Implements skill caching with ResourceMap and the getSkillByUri method
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatInlineAnchorWidget.ts Injects IPromptsService and uses skill name as label when available

Comment on lines +714 to +718
// Update the cached skills map for synchronous lookup
this.cachedSkillsByUri.clear();
for (const skill of result) {
this.cachedSkillsByUri.set(skill.uri, skill);
}
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

The cache is only populated when findAgentSkills is called, but there's no mechanism to invalidate or refresh the cache when skill files change. If a skill file is added, removed, or modified after findAgentSkills is initially called, getSkillByUri will continue returning stale data. Consider adding file watchers to invalidate the cache when skill files change, or implementing a cache refresh mechanism similar to how cachedCustomAgents.refresh() works for custom agents.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

TODO: I think we should support skills as a promptType and leverage the existing watcher mechanisms there?

Comment on lines +725 to +727
public getSkillByUri(uri: URI): IAgentSkill | undefined {
return this.cachedSkillsByUri.get(uri);
}
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

The new getSkillByUri method lacks test coverage. Since there are comprehensive tests for findAgentSkills in promptsService.test.ts, tests should be added to verify that getSkillByUri correctly returns cached skills after findAgentSkills is called, and returns undefined when the cache is empty or the URI is not found.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

See above. We should wait until things are more unified before testing here.

@aeschli
Copy link
Contributor

aeschli commented Jan 9, 2026

Agree we need something like 'getSkillByUri'.
Wanted to suggest we do the rendering all on the extension side. Putting that IPromptsService dependency into chatInlineAnchorWidget.ts looks wrong.

@pwang347
Copy link
Member Author

Closed in favour of #286839

@pwang347 pwang347 closed this Jan 10, 2026
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