Skip to content

Fix rename/usages tools: skip registration when no providers exist, show language names in UI#297684

Merged
jrieken merged 6 commits intomainfrom
copilot/update-tool-descriptions-languages
Mar 20, 2026
Merged

Fix rename/usages tools: skip registration when no providers exist, show language names in UI#297684
jrieken merged 6 commits intomainfrom
copilot/update-tool-descriptions-languages

Conversation

Copy link
Contributor

Copilot AI commented Feb 25, 2026

vscode_renameSymbol and vscode_listCodeUsages were always registered even when no language providers existed, and their userDescription never reflected which languages were actually supported.

Changes to renameTool.ts and usagesTool.ts:

  • getToolData() now returns undefined when no providers are registered — tools are not registered at all in that case
  • userDescription now includes human-readable language names (via ILanguageService.getLanguageName()) when providers are scoped to specific languages, e.g.:
    • "Rename a symbol across the workspace (JavaScript, TypeScript)"
    • "Find references, definitions, and implementations of a symbol (JavaScript, TypeScript)"
  • *-registered providers (all languages) keep the generic description without an enumeration
  • ILanguageService injected into both tool classes to resolve language IDs → display names
  • Contribution classes guard registerTool() with an undefined check so re-evaluation on provider changes also handles the no-provider case correctly
  • Simplified guard condition: size === 0 is sufficient (empty set can never contain '*')

Changes to renameTool.test.ts and usagesTool.test.ts:

  • Added ILanguageService mock as the second constructor argument to match the updated RenameTool/UsagesTool signatures
  • Updated the "no providers" getToolData tests to assert undefined (reflecting the new behavior where getToolData() returns undefined when no providers are registered)
  • Used optional chaining on getToolData() results in remaining tests to satisfy the IToolData | undefined return type
Original prompt

This section details on the original issue you should resolve

<issue_title>Tool descriptions don't mention any languages</issue_title>
<issue_description>Testing #297028

The TPI says

Check that the tool description spells out the supported languages

No tool description mentions any languages. That's true for the tool descriptions inside the request, and in the UI.</issue_description>

<agent_instructions>src/vs/workbench/contrib/chat/browser/tools/renameTool.ts should not return tool data and not register the tool when no rename provider exists. Also, update the user description with the nice names that you get via src/vs/editor/common/languages/language.ts#ILanguageService. Make the same changes for src/vs/workbench/contrib/chat/browser/tools/usagesTool.ts</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@jrieken @kieferrm from the logs you attached for https://github.com//issues/297585 I do see that they are spelled out. Tho, the tool is still registered even when no support exists. Also, the user description isn't updated.

Image</comment_new>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…, add language names to userDescription

Co-authored-by: jrieken <1794099+jrieken@users.noreply.github.com>
Copilot AI changed the title [WIP] Update tool descriptions to include supported languages Fix rename/usages tools: skip registration when no providers exist, show language names in UI Feb 25, 2026
Co-authored-by: jrieken <1794099+jrieken@users.noreply.github.com>
@jrieken jrieken marked this pull request as ready for review March 4, 2026 12:24
Copilot AI review requested due to automatic review settings March 4, 2026 12:24
@jrieken jrieken added this to the 1.111.0 milestone Mar 4, 2026
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 updates the built-in chat “Rename Symbol” and “List Code Usages” tools so they don’t register when the editor has no corresponding language providers, and so the UI-facing tool description can display nicer language names via ILanguageService.

Changes:

  • Inject ILanguageService into RenameTool/UsagesTool and use it to build language-friendly userDescription strings.
  • Change getToolData() to return undefined when there are no providers, and update contributions to skip tool registration in that case.
  • Simplify provider-guard logic by treating size === 0 as the only “no providers” case.

Reviewed changes

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

File Description
src/vs/workbench/contrib/chat/browser/tools/renameTool.ts Makes rename tool data/registration conditional on provider availability; uses ILanguageService for UI description language names.
src/vs/workbench/contrib/chat/browser/tools/usagesTool.ts Applies the same conditional registration + language-name UI description behavior to the usages tool.
Comments suppressed due to low confidence (2)

src/vs/workbench/contrib/chat/browser/tools/usagesTool.ts:58

  • The constructor now injects ILanguageService, but there are existing direct instantiations (e.g. src/vs/workbench/contrib/chat/test/browser/tools/usagesTool.test.ts) that haven't been updated to pass this new dependency. This will cause TypeScript compile failures unless those call sites provide an ILanguageService (mock/stub in tests).
	constructor(
		@ILanguageFeaturesService private readonly _languageFeaturesService: ILanguageFeaturesService,
		@ILanguageService private readonly _languageService: ILanguageService,
		@IModelService private readonly _modelService: IModelService,
		@ISearchService private readonly _searchService: ISearchService,
		@ITextModelService private readonly _textModelService: ITextModelService,
		@IWorkspaceContextService private readonly _workspaceContextService: IWorkspaceContextService,

src/vs/workbench/contrib/chat/browser/tools/renameTool.ts:61

  • The constructor now injects ILanguageService, but there are existing direct instantiations (e.g. src/vs/workbench/contrib/chat/test/browser/tools/renameTool.test.ts) that haven't been updated to pass this new dependency. This will cause TypeScript compile failures unless those call sites provide an ILanguageService (mock/stub in tests).
	constructor(
		@ILanguageFeaturesService private readonly _languageFeaturesService: ILanguageFeaturesService,
		@ILanguageService private readonly _languageService: ILanguageService,
		@ITextModelService private readonly _textModelService: ITextModelService,
		@IWorkspaceContextService private readonly _workspaceContextService: IWorkspaceContextService,
		@IChatService private readonly _chatService: IChatService,
		@IBulkEditService private readonly _bulkEditService: IBulkEditService,

@jrieken
Copy link
Member

jrieken commented Mar 4, 2026

@copilot fix compile errors in those two rename/usuage tool tests

Co-authored-by: jrieken <1794099+jrieken@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 4, 2026

@copilot fix compile errors in those two rename/usuage tool tests

Fixed in 35f486e. Both test files were missing the new ILanguageService constructor argument and had tests that expected non-undefined data when no providers were registered (now getToolData() returns undefined in that case).

@jrieken jrieken merged commit a2fa4ea into main Mar 20, 2026
21 checks passed
@jrieken jrieken deleted the copilot/update-tool-descriptions-languages branch March 20, 2026 14:55
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.

Tool descriptions don't mention any languages

4 participants