edits: show diffs for files being approved during edits#1905
Merged
connor4312 merged 2 commits intomainfrom Nov 11, 2025
Merged
edits: show diffs for files being approved during edits#1905connor4312 merged 2 commits intomainfrom
connor4312 merged 2 commits intomainfrom
Conversation
Requires a PR in core as well to adopt this nicely.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds diff visualization for files requiring confirmation during edit operations. When the AI wants to edit sensitive or system files that require user approval, the confirmation dialog now shows unified diffs of the proposed changes instead of just the raw input/patch content.
Key changes:
- Introduced
formatDiffAsUnified()utility to generate unified diff format from old/new content - Refactored
createEditConfirmation()to accept an async callback that generates detailed diff previews - Implemented caching in edit tools to avoid recomputing patches/edits during prepare→invoke flow
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| src/extension/tools/node/editFileToolUtils.tsx | Added formatDiffAsUnified() function to generate unified diffs and updated createEditConfirmation() signature to support async detail messages |
| src/extension/tools/node/abstractReplaceStringTool.tsx | Refactored to cache prepared edits and generate diff confirmations; changed from urisForInput() to extractReplaceInputs() pattern |
| src/extension/tools/node/replaceStringTool.tsx | Updated to implement new extractReplaceInputs() method and use cached prepareEdits() |
| src/extension/tools/node/multiReplaceStringTool.tsx | Updated to implement new extractReplaceInputs() method for multi-file replacements |
| src/extension/tools/node/applyPatchTool.tsx | Added caching for patch processing and diff generation in confirmation dialogs |
| src/extension/tools/node/createFileTool.tsx | Updated to show diff for new file creation (empty→content) |
| src/extension/tools/node/insertEditTool.tsx | Updated function signature to match new async createEditConfirmation() API |
| src/extension/tools/node/editNotebookTool.tsx | Changed sendEditNotebookTelemetry() to accept model as string or LanguageModelChat object |
connor4312
added a commit
to microsoft/vscode
that referenced
this pull request
Nov 10, 2025
Goes with microsoft/vscode-copilot-chat#1905 - Adds common markdown rendering to the `IChatContentPartRenderContext`. These have to get passed down everywhere that can render markdown 'properly' and so this made sense, though we may want to revisit this and make them actual dependency-injected services with scope instantiation service. - Add a new basic `MarkdownDiffBlockPart` and allow consumers to optionally enable that for handling of `diff` blocks in their markdown. - Some further tweaks to deal with md/code in nested blocks.
connor4312
added a commit
to microsoft/vscode
that referenced
this pull request
Nov 10, 2025
Goes with microsoft/vscode-copilot-chat#1905 - Adds common markdown rendering to the `IChatContentPartRenderContext`. These have to get passed down everywhere that can render markdown 'properly' and so this made sense, though we may want to revisit this and make them actual dependency-injected services with scope instantiation service. - Add a new basic `MarkdownDiffBlockPart` and allow consumers to optionally enable that for handling of `diff` blocks in their markdown. - Some further tweaks to deal with md/code in nested blocks.
DonJayamanne
approved these changes
Nov 11, 2025
connor4312
added a commit
to microsoft/vscode
that referenced
this pull request
Nov 11, 2025
* edits: show diff for sensitive edit confirmations Goes with microsoft/vscode-copilot-chat#1905 - Adds common markdown rendering to the `IChatContentPartRenderContext`. These have to get passed down everywhere that can render markdown 'properly' and so this made sense, though we may want to revisit this and make them actual dependency-injected services with scope instantiation service. - Add a new basic `MarkdownDiffBlockPart` and allow consumers to optionally enable that for handling of `diff` blocks in their markdown. - Some further tweaks to deal with md/code in nested blocks. * comment
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.
Requires a PR in core as well to adopt this nicely.