Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 24, 2025

Problem

The PullRequestFileChangesService was not properly generating URIs for different file change types when creating multi-diff views for pull requests. The previous implementation always set both originalUri and modifiedUri to valid file paths, which violated the ChatResponseDiffEntry API specification and resulted in incorrect visual representation of added and deleted files.

According to the VS Code ChatResponseDiffEntry interface:

  • Added files should have originalUri set to undefined (no original version exists)
  • Deleted files should have modifiedUri set to undefined (no modified version exists)

The previous implementation treated all file types the same way, causing the multi-diff view to display incorrect diff information for these special cases.

Solution

Updated pullRequestFileChangesService.ts to properly handle all GitHub PR file status types using an explicit switch statement:

  • added: Sets only modifiedUri (new file location), leaves originalUri as undefined
  • removed: Sets only originalUri (deleted file location), leaves modifiedUri as undefined
  • renamed: Sets originalUri to old filename (from previous_filename) and modifiedUri to new filename
  • modified/changed: Sets both URIs to the same file path (standard diff)
  • copied: Sets originalUri to source file and modifiedUri to target file (using previous_filename)

Example

For a PR with an added file:

Before:

{
  originalUri: vscode.Uri.file('/workspace/newfile.ts'),  // ❌ Incorrect
  modifiedUri: vscode.Uri.file('/workspace/newfile.ts')
}

After:

{
  originalUri: undefined,  // ✅ Correct - no original version
  modifiedUri: vscode.Uri.file('/workspace/newfile.ts')
}

Benefits

  • Correct API Usage: Fully complies with the ChatResponseDiffEntry interface specification
  • Improved UX: Multi-diff view now correctly shows "New file" indicators for additions and "Deleted file" indicators for removals
  • Accurate Diff Display: Renamed files properly show the before/after file names
  • Better Debugging: Enhanced logging includes file status for easier troubleshooting

Testing

  • ✅ Code compiles successfully without errors
  • ✅ Passes ESLint and tsfmt checks
  • ✅ Aligns with VS Code's proposed ChatParticipantAdditions API
Original prompt

please check if we can generate proper file changes uris for the multi file chnages part

The user has attached the following files as relevant context:

  • src/extension/chatSessions/vscode-node/copilotCloudSessionsProvider.ts

The user has attached the following files from their workspace:

  • src/extension/chatSessions/vscode-node/copilotCloudSessionsProvider.ts

Created from VS Code via the GitHub Pull Request extension.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: rebornix <876920+rebornix@users.noreply.github.com>
Copilot AI changed the title [WIP] Check if proper file changes URIs can be generated Fix file changes URI generation for multi-file changes in pull requests Oct 24, 2025
Copilot AI requested a review from rebornix October 24, 2025 18:05
Copilot finished work on behalf of rebornix October 24, 2025 18:05
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.

2 participants