Skip to content

agents: render Copilot CLI 'rg' search tool#313838

Merged
roblourens merged 7 commits intomainfrom
roblou/agents/rg-tool-rendering-update
May 2, 2026
Merged

agents: render Copilot CLI 'rg' search tool#313838
roblourens merged 7 commits intomainfrom
roblou/agents/rg-tool-rendering-update

Conversation

@roblourens
Copy link
Copy Markdown
Member

@roblourens roblourens commented May 2, 2026

Adds first-class rendering for the Copilot CLI rg and grep search tools in VS Code's agent host.

Changes

Tool display (copilotToolDisplay.ts)

  • Recognizes rg as a first-class tool alongside grep
  • Shows Searching for "{pattern}" while running and Searched for "{pattern}" when complete
  • Separate ICopilotGrepToolArgs / ICopilotRgToolArgs interfaces matching the EH-CLI GrepTool schema
  • rg reuses the grep l10n keys to avoid duplicate strings for translators

Search icon pipeline

  • Added IChatSearchToolInvocationData { kind: 'search' } to the toolSpecificData discriminated union
  • getToolKind() in copilotToolDisplay.ts returns 'search' for grep/rg tools
  • stateToProgressAdapter.ts sets toolSpecificData = { kind: 'search' } for running and completed search tools
  • Icon rendering: chatThinkingContentPart.ts detects toolSpecificData.kind === 'search' and shows Codicon.search as the outer type-icon — consistent with how terminal tools use isTerminalTool to show Codicon.terminal
  • The inner status icon (check / spinner) comes from getIcon() in BaseChatToolInvocationSubPart as normal

Tests

  • 4 unit tests in copilotToolDisplay.test.ts covering rg/grep invocation and past-tense messages

(Written by Copilot)

The Copilot CLI emits both 'grep' and 'rg' search tool calls, but the
agent-host only recognized 'grep'. 'rg' calls fell through to generic
'Using "rg"' / 'Used "rg"' messages.

Add 'rg' as a first-class tool in copilotToolDisplay.ts with its own
typed args interface (matching the CLI parity reference), display name
'Search', and 'Searching for {pattern}' / 'Searched for {pattern}'
messages mirroring the existing 'grep' wording. Also broaden
ICopilotGrepToolArgs to match the current CLI schema.

(Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 2, 2026 01:51
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

Adds first-class display support for the Copilot CLI rg search tool in the agent-host so rg tool calls render like grep (as “Search”) instead of falling back to the generic “Using/Used …” messaging.

Changes:

  • Add rg to the known Copilot tool names and implement dedicated display/invocation/past-tense/input-string handling.
  • Expand the typed grep args schema to match current CLI behavior and introduce a parallel rg args interface.
  • Add focused unit tests covering rg/grep invocation & completion messages and getToolInputString.
Show a summary per file
File Description
src/vs/platform/agentHost/node/copilot/copilotToolDisplay.ts Adds rg tool support and updates grep/rg argument typing + message rendering.
src/vs/platform/agentHost/test/node/copilotToolDisplay.test.ts Adds tests validating rg/grep rendering parity and pattern extraction.

Copilot's findings

Comments suppressed due to low confidence (1)

src/vs/platform/agentHost/node/copilot/copilotToolDisplay.ts:450

  • Same localization duplication concern as in getInvocationMessage: toolComplete.rgPattern/toolComplete.rg introduce new keys even though the text matches the grep completion messages. Reusing the grep keys until divergence would reduce translation churn.
		case CopilotToolName.Rg: {
			const args = parameters as ICopilotRgToolArgs | undefined;
			if (args?.pattern) {
				return md(localize('toolComplete.rgPattern', "Searched for {0}", appendEscapedMarkdownInlineCode(truncate(args.pattern, 80))));
			}
			return localize('toolComplete.rg', "Searched files");
		}
  • Files reviewed: 2/2 changed files
  • Comments generated: 2

Comment thread src/vs/platform/agentHost/node/copilot/copilotToolDisplay.ts Outdated
Comment thread src/vs/platform/agentHost/node/copilot/copilotToolDisplay.ts Outdated
- Remove bare filename reference from ICopilotGrepToolArgs doc comment
- rg cases reuse toolInvoke.grepPattern/grep and toolComplete.grepPattern/grep
  instead of introducing duplicate localization keys with identical strings

(Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 2, 2026

blocks-ci screenshots changed

Replace the contents of test/componentFixtures/blocks-ci-screenshots.md with:

Updated blocks-ci-screenshots.md
<!-- auto-generated by CI — do not edit manually -->

#### editor/codeEditor/CodeEditor/Dark
![screenshot](https://hediet-screenshots.azurewebsites.net/images/cb32a3e854b5734fe5aaca2318f2e0a42ee821b05ea97883ea42c5ba95edb3c3)

#### editor/codeEditor/CodeEditor/Light
![screenshot](https://hediet-screenshots.azurewebsites.net/images/42624fbba5e0db7f32c224b5eb9c5dd3b08245697ae2e7d2a88be0d7c287129b)

#### editor/inlineChatZoneWidget/InlineChatZoneWidget/Dark
![screenshot](https://hediet-screenshots.azurewebsites.net/images/28af1b719f3877d2f048fef10bb4534d5f638c1987bb0536331f4ab50ea0ea7a)

#### editor/inlineChatZoneWidget/InlineChatZoneWidget/Light
![screenshot](https://hediet-screenshots.azurewebsites.net/images/c6c77ca2785665ae66c817cda21a8e5f5ea7d51e798c5b4e5aedcda9fd7323bd)

#### editor/inlineChatZoneWidget/InlineChatZoneWidgetTerminated/Dark
![screenshot](https://hediet-screenshots.azurewebsites.net/images/2fbc12507b59ff950d9612d2df92e6b39d8bf0bf500478e42eca2ead4d1ae206)

#### editor/inlineChatZoneWidget/InlineChatZoneWidgetTerminated/Light
![screenshot](https://hediet-screenshots.azurewebsites.net/images/4632ab04d1fdd7db9ab0e00cce10aefb7a6344eb8869dfce740309a8801cab73)

- Add SEARCH_TOOL_NAMES set (grep, rg) in copilotToolDisplay.ts; getToolKind() returns 'search' for these tools
- Widen toolKind type to include 'search' in mapSessionEvents.ts, sessionReducers.ts, and IHistoryToolStartRecord
- Add IChatSearchToolInvocationData { kind: 'search' } to chatService.ts and all toolSpecificData union types
- stateToProgressAdapter: set toolSpecificData = { kind: 'search' } for completed and running search tools
- chatToolInvocationSubPart.ts: getIcon() returns Codicon.search (spinning while running) for search tools

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
roblourens and others added 4 commits May 2, 2026 09:37
…icData

Revert the 'search' toolKind / IChatSearchToolInvocationData approach from the
previous commit. Instead, use the existing getToolInvocationIcon() function
(chatThinkingContentPart.ts) which already returns Codicon.search for tool IDs
containing 'grep', 'search',  the same mechanism used by EH CLI sessions.etc.

Changes:
- Add 'rg' exact-match to getToolInvocationIcon()'s search condition
- getIcon() in BaseChatToolInvocationSubPart now calls getToolInvocationIcon(toolId)
  instead of hardcoding Codicon.check / Codicon.loading, so all tools show their
  semantic icon (search, pencil, terminal, etc.) rather than a generic check/spinner
- Revert all IChatSearchToolInvocationData / toolSpecificData / getToolKind changes

(Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
(Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The rg/grep tools were showing two icons per row:
- Outer icon: generic tools (Codicon.tools) from chatThinkingContentPart
- Inner icon: Codicon.search from getIcon() in BaseChatToolInvocationSubPart

This is inconsistent with how terminal tools work (outer=terminal, inner=check/spinner).

Fix:
- chatThinkingContentPart: detect toolSpecificData.kind === 'search' and show
  Codicon.search as the outer type-icon (same pattern as the isTerminalTool check)
- chatToolInvocationSubPart: remove the search-specific case from getIcon() so the
  inner icon reverts to normal check/spinner status icons

Result: outer=search (type), inner=check/spinner (status) - consistent with terminal.

(Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@roblourens roblourens requested a review from Copilot May 2, 2026 19:14
@roblourens roblourens marked this pull request as ready for review May 2, 2026 19:36
@roblourens roblourens enabled auto-merge (squash) May 2, 2026 19:36
@roblourens roblourens merged commit 6bdca78 into main May 2, 2026
43 of 46 checks passed
@roblourens roblourens deleted the roblou/agents/rg-tool-rendering-update branch May 2, 2026 22:37
@vs-code-engineering vs-code-engineering Bot added this to the 1.119.0 milestone May 2, 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