Skip to content

chat: constrain symbol tools to active workspace - #333144

Merged
Alexandru Dima (alexdima) merged 2 commits into
mainfrom
alexd/scope-symbol-tools
Aug 28, 2026
Merged

Alexandru Dima (alexdima) merged 2 commits into
mainfrom
alexd/scope-symbol-tools

Conversation

@alexdima

Copy link
Copy Markdown
Member

Summary

  • normalize symbol-tool URIs with provider-aware path and casing semantics
  • keep target resources, returned usages, preview searches, and rename edits within the active working directory or workspace
  • add focused coverage for traversal, multi-root workspaces, remote URIs, preview scope, and edit result types

Validation

  • npm run typecheck-client
  • ./scripts/test.sh src/vs/workbench/contrib/chat/test/browser/tools/toolHelpers.test.ts src/vs/workbench/contrib/chat/test/browser/tools/renameTool.test.ts src/vs/workbench/contrib/chat/test/browser/tools/usagesTool.test.ts
  • git diff --check

Normalize symbol tool resources with provider-aware URI semantics and keep target resources, returned references, preview searches, and rename edits within the active workspace boundary. Add focused coverage for workspace, working directory, remote URI, and edit-result cases.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings August 28, 2026 11:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

Review tier: Balanced
Findings: 1 High severity · 3 Low severity

New issues introduced by this change (4)
Severity Finding
High severity src/​vs/​workbench/​contrib/​chat/​browser/​tools/​renameTool.ts — An in-scope file or custom edit passes this check, but the chat-context path only forwards…
Low severity src/​vs/​workbench/​contrib/​chat/​browser/​tools/​usagesTool.ts — errorResult also assigns this text to toolResultMessage, so this new user-visible message must…
Low severity src/​vs/​workbench/​contrib/​chat/​browser/​tools/​renameTool.ts — errorResult also assigns this text to toolResultMessage, so this updated user-visible message…
Low severity src/​vs/​workbench/​contrib/​chat/​browser/​tools/​toolHelpers.ts — This description is incomplete when workingDirectory is supplied: filePath is then relative to…
What changed in this PR

Constrain symbol lookup and rename operations to the active workspace or working directory.

Changes:

  • Add provider-aware URI normalization and scope validation.
  • Filter usage results, previews, and rename edits by scope.
  • Add traversal, multi-root, remote URI, preview, and edit-type tests.
File Description
toolHelpers.ts Adds shared URI scope validation.
usagesTool.ts Restricts targets, results, and preview searches.
renameTool.ts Rejects out-of-scope targets and edits.
toolHelpers.test.ts Tests URI resolution and traversal boundaries.
usagesTool.test.ts Tests result and preview scoping.
renameTool.test.ts Tests target and edit scoping.
Suppressed comments (1)

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

  • This new error is exposed through toolResultMessage; localize it before displaying it to users.
				return errorResult('Rename was not applied because it would modify files outside the current workspace or working directory.');

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Localize the new error messages, clarify file path resolution, and reject rename edit types that cannot be represented in the chat edit stream.

Co-authored-by: Copilot <[email protected]>
@alexdima
Alexandru Dima (alexdima) marked this pull request as ready for review August 28, 2026 12:23
@alexdima
Alexandru Dima (alexdima) enabled auto-merge (squash) August 28, 2026 12:24
@alexdima
Alexandru Dima (alexdima) merged commit d8cfdc7 into main Aug 28, 2026
37 checks passed
@alexdima
Alexandru Dima (alexdima) deleted the alexd/scope-symbol-tools branch August 28, 2026 13:10
@vs-code-engineering vs-code-engineering Bot added this to the 1.136.0 milestone Aug 28, 2026
Abdullah Atrash (abdullahatrash) added a commit to abdullahatrash/flowleap-agent-v2 that referenced this pull request Sep 20, 2026
* port(chat-ui): preserve #file reference when editing text before it (#394)

Upstream d750fe2 (microsoft#333965), applied clean with its tests.
Typing before an existing #file attachment silently deleted the attachment.
Adds touchesReference and findReferenceRangeForNonOverlappingEdit.

* port(chat-ui): highlight generic tool output by content type (#394)

Upstream 63acf08 (microsoft#333923). chatInputOutputMarkdownProgressPart.ts
applied clean; the chatToolOutputContentSubPart.ts hunk was hand-applied because the
fork's adjacent-code-part loop predates upstream's refactor. The agentHost
stateToProgressAdapter.ts hunk and its test are dropped (Agent Host only).
Our patent tools return large JSON payloads into exactly this part.

* port(chat-ui): fix IME handling in the chat find widget (#394)

Upstream b9861ad (microsoft#332950), applied clean with its tests.
Composition input (CJK) broke search in the transcript find widget.

* port(chat-ui): fix transcript Find keybindings (#394)

Upstream cefc831 (microsoft#333135). chatFindActions.ts, chatFindWidget.ts,
chatListWidget.ts and the find tests applied clean; the chatListWidget.test.ts hunk was
hand-applied because that test file is diverged. Enter/Escape/F3 inside the transcript
find widget went to the generic tree find instead of chat Find.

* port(chat-ui): configurable paste-to-attachment threshold and Insert in Prompt (#394)

Upstream e1801a0 (microsoft#331978). chatPasteProviders.ts, chatCopyActions.ts,
constants.ts, chatAccessibilityHelp.ts, the chat.shared.contribution.ts configuration
registration and the paste tests all applied clean. The src/vs/sessions hunks are left
out: the fork has no caller of createPastedTextArtifact there, and sessions files belong
to the deferred wave W.

* port(chat-ui): remove the line requirement for paste attachments (#394)

Upstream 36053db (microsoft#335100), hand-applied: the fork's
chatPasteProviders.ts lacks the GitHub-URL pattern that surrounds the hunk, and its
chatAccessibilityHelp.ts and both test files are behind upstream's base. A short paste
now becomes an attachment on character count alone, so pasting a single-line claim
works like pasting a multi-line one.

* port(chat-ui): reuse text buffers for checkpoint replay (#394)

Upstream 903d0d0 (microsoft#336095), applied clean with its tests.
Checkpoint restore rebuilt a text model per replayed edit.

* port(chat-ui): constrain symbol tools to the active workspace (#394)

Upstream d8cfdc7 (microsoft#333144), applied clean with its tests.
renameTool and usagesTool no longer reach outside the active workspace folder.
Abdon Morales (abdonmorales) pushed a commit to abdonmorales/vscode-utcs that referenced this pull request Sep 27, 2026
* chat: constrain symbol tools to active workspace

Normalize symbol tool resources with provider-aware URI semantics and keep target resources, returned references, preview searches, and rename edits within the active workspace boundary. Add focused coverage for workspace, working directory, remote URI, and edit-result cases.

Co-authored-by: Copilot <[email protected]>

* chat: address symbol tool review feedback

Localize the new error messages, clarify file path resolution, and reject rename edit types that cannot be represented in the chat edit stream.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
(cherry picked from commit d8cfdc7)
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Oct 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants