agent_ui: Alphabetically sort edited files in the panel & review view (#47300)

This makes the ordering of files consistent with the Git diff view.

Release Notes:

- N/A
This commit is contained in:
Danilo Leal 2026-01-21 13:03:33 -03:00 committed by GitHub
parent 1b0771eb9c
commit 8fb5587ed8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 4 deletions

View file

@ -5600,13 +5600,21 @@ impl AcpThreadView {
) -> impl IntoElement {
let editor_bg_color = cx.theme().colors().editor_background;
// Sort edited files alphabetically for consistency with Git diff view
let mut sorted_buffers: Vec<_> = changed_buffers.iter().collect();
sorted_buffers.sort_by(|(buffer_a, _), (buffer_b, _)| {
let path_a = buffer_a.read(cx).file().map(|f| f.path().clone());
let path_b = buffer_b.read(cx).file().map(|f| f.path().clone());
path_a.cmp(&path_b)
});
v_flex()
.id("edited_files_list")
.max_h_40()
.overflow_y_scroll()
.children(
changed_buffers
.iter()
sorted_buffers
.into_iter()
.enumerate()
.flat_map(|(index, (buffer, diff))| {
let file = buffer.read(cx).file()?;

View file

@ -131,6 +131,15 @@ impl AgentDiffPane {
.action_log()
.read(cx)
.changed_buffers(cx);
// Sort edited files alphabetically for consistency with Git diff view
let mut sorted_buffers: Vec<_> = changed_buffers.iter().collect();
sorted_buffers.sort_by(|(buffer_a, _), (buffer_b, _)| {
let path_a = buffer_a.read(cx).file().map(|f| f.path().clone());
let path_b = buffer_b.read(cx).file().map(|f| f.path().clone());
path_a.cmp(&path_b)
});
let mut paths_to_delete = self
.multibuffer
.read(cx)
@ -138,7 +147,7 @@ impl AgentDiffPane {
.cloned()
.collect::<HashSet<_>>();
for (buffer, diff_handle) in changed_buffers {
for (buffer, diff_handle) in sorted_buffers {
if buffer.read(cx).file().is_none() {
continue;
}
@ -168,7 +177,7 @@ impl AgentDiffPane {
multibuffer_context_lines(cx),
cx,
);
multibuffer.add_diff(diff_handle, cx);
multibuffer.add_diff(diff_handle.clone(), cx);
(was_empty, is_excerpt_newly_added)
});