Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 15, 2025

Problem

When multiple files were selected in the "Combined Changes" area, only the diff of the last selected file was displayed. This made it difficult to review changes across multiple files simultaneously.

Solution

Modified SelectionView.svelte to iterate over and display diffs for all selected files instead of just one.

Key Changes

  • Replaced single file display with array iteration: Changed from computing a single selectedFile to using the full selectedFiles array from the selection
  • Added {#each} loop: Now renders a diff view for each selected file sequentially
  • Updated layout: Added flex-direction: column to properly stack multiple diffs vertically
  • Improved visual separation: Automatically adds borders between file diffs for better readability
  • Code cleanup: Removed unused readKey import

Technical Details

The original implementation used logic to determine which single file to display:

// Before: Only one file shown
const selectedFile = $derived.by(() => {
  if (selection.current.length === 1 || !$lastAdded) return selection.current[0];
  return readKey($lastAdded.key);
});

Now it uses all selected files:

// After: All files shown
const selectedFiles = $derived.by(() => {
  if (!selectionId || !selection) return [];
  return selection.current;
});

Behavior

  • Single file selection: Works exactly as before
  • Multiple file selection: Now displays all selected files' diffs in order
  • No selection: Shows placeholder as before

This change makes it much easier to review changes across multiple related files without having to switch between individual file selections.

Original prompt

When multiple files are selected in the "Combined Changes" area, it should show a diff of each file, not just the last selected one.


💡 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.

Copy link

vercel bot commented Oct 15, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
gitbutler-web Skipped Skipped Oct 15, 2025 4:45am

@Copilot Copilot AI changed the title [WIP] Update diff view to show all selected files Show diffs for all selected files in Combined Changes area Oct 15, 2025
@Copilot Copilot AI requested a review from Byron October 15, 2025 03:15
Copilot finished work on behalf of Byron October 15, 2025 03:15
@Byron Byron force-pushed the copilot/show-diff-for-all-files-selected branch from bf45307 to 7d103c5 Compare October 15, 2025 04:41
@Byron
Copy link
Collaborator

Byron commented Oct 15, 2025

Without having looked at the code at all, I am surprised it actually works! The prompt was

When multiple files are selected in the "Combined Changes" area, it should show a diff of each file, not just the last selected one.

Screen.Recording.2025-10-15.at.06.40.09.mov

Of course, ideally we figure out how to deal with filenames, and it seems like getting this right is a little less trivial.

But overall, even with this improvement, it feels much more natural than it did before.

What do you think, @PavelLaptev, @krlvi. And does @estib-vega think the code is salvageable?
Thanks everyone.

@Byron Byron force-pushed the copilot/show-diff-for-all-files-selected branch from 7d103c5 to a3a0b3f Compare October 15, 2025 04:45
@Caleb-T-Owens
Copy link
Contributor

@Byron displaying just one file diff at a time was originally done in part as a performance tweak. When users would try to do something like select 50 files to amend a commit with them, it would cause the UI to freeze as we tried to mount all those elements and query their data.

We do now have some more intelligent lazy loading so maybe those performance characteristics have changed

@Byron
Copy link
Collaborator

Byron commented Oct 15, 2025

Thanks for the reminder! I wonder if there can be a 'safe' way to do this that gets this behaviour for common usecases.

The reason I noticed this isn't even that I personally want or need this feature, it's just that it feels unintuitive that I can't see more in a row when multi-selecting. I also had no idea that files can be dragged, so it seemed useless to be able to multi-select them at all and showing more would have given them meaning.

In any case, it looks like this PR is nothing more than a motivator to put in the time to make this safe even if 500 files are selected, and that then isn't so straightforward anymore.
It's probably along the lines of the GitHub diff view that hides things if it has too much.

In any case, it might not be worth it to pursue this feature based on performance concerns alone (even though saying this always makes me sad).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants