agent_ui: Fix activity bar when plan and edited files list is long (#43759)

Closes https://github.com/zed-industries/zed/issues/43728

Release Notes:

- agent: Fixed a bug where the plan and edit files list would consume
the whole space of the thread if they were too long. They're now capped
by a max-height and scrollable.
This commit is contained in:
Danilo Leal
2025-11-28 22:01:02 +00:00
committed by GitHub
parent e8a3368226
commit 6040c0c00a
+205 -180
View File
@@ -3812,48 +3812,62 @@ impl AcpThreadView {
})) }))
} }
fn render_plan_entries(&self, plan: &Plan, window: &mut Window, cx: &Context<Self>) -> Div { fn render_plan_entries(
v_flex().children(plan.entries.iter().enumerate().flat_map(|(index, entry)| { &self,
let element = h_flex() plan: &Plan,
.py_1() window: &mut Window,
.px_2() cx: &Context<Self>,
.gap_2() ) -> impl IntoElement {
.justify_between() v_flex()
.bg(cx.theme().colors().editor_background) .id("plan_items_list")
.when(index < plan.entries.len() - 1, |parent| { .max_h_40()
parent.border_color(cx.theme().colors().border).border_b_1() .overflow_y_scroll()
}) .children(plan.entries.iter().enumerate().flat_map(|(index, entry)| {
.child( let element = h_flex()
h_flex() .py_1()
.id(("plan_entry", index)) .px_2()
.gap_1p5() .gap_2()
.max_w_full() .justify_between()
.overflow_x_scroll() .bg(cx.theme().colors().editor_background)
.text_xs() .when(index < plan.entries.len() - 1, |parent| {
.text_color(cx.theme().colors().text_muted) parent.border_color(cx.theme().colors().border).border_b_1()
.child(match entry.status { })
acp::PlanEntryStatus::Pending => Icon::new(IconName::TodoPending) .child(
.size(IconSize::Small) h_flex()
.color(Color::Muted) .id(("plan_entry", index))
.into_any_element(), .gap_1p5()
acp::PlanEntryStatus::InProgress => Icon::new(IconName::TodoProgress) .max_w_full()
.size(IconSize::Small) .overflow_x_scroll()
.color(Color::Accent) .text_xs()
.with_rotate_animation(2) .text_color(cx.theme().colors().text_muted)
.into_any_element(), .child(match entry.status {
acp::PlanEntryStatus::Completed => Icon::new(IconName::TodoComplete) acp::PlanEntryStatus::Pending => Icon::new(IconName::TodoPending)
.size(IconSize::Small) .size(IconSize::Small)
.color(Color::Success) .color(Color::Muted)
.into_any_element(), .into_any_element(),
}) acp::PlanEntryStatus::InProgress => {
.child(MarkdownElement::new( Icon::new(IconName::TodoProgress)
entry.content.clone(), .size(IconSize::Small)
plan_label_markdown_style(&entry.status, window, cx), .color(Color::Accent)
)), .with_rotate_animation(2)
); .into_any_element()
}
acp::PlanEntryStatus::Completed => {
Icon::new(IconName::TodoComplete)
.size(IconSize::Small)
.color(Color::Success)
.into_any_element()
}
})
.child(MarkdownElement::new(
entry.content.clone(),
plan_label_markdown_style(&entry.status, window, cx),
)),
);
Some(element) Some(element)
})) }))
.into_any_element()
} }
fn render_edits_summary( fn render_edits_summary(
@@ -3991,126 +4005,136 @@ impl AcpThreadView {
changed_buffers: &BTreeMap<Entity<Buffer>, Entity<BufferDiff>>, changed_buffers: &BTreeMap<Entity<Buffer>, Entity<BufferDiff>>,
pending_edits: bool, pending_edits: bool,
cx: &Context<Self>, cx: &Context<Self>,
) -> Div { ) -> impl IntoElement {
let editor_bg_color = cx.theme().colors().editor_background; let editor_bg_color = cx.theme().colors().editor_background;
v_flex().children(changed_buffers.iter().enumerate().flat_map( v_flex()
|(index, (buffer, _diff))| { .id("edited_files_list")
let file = buffer.read(cx).file()?; .max_h_40()
let path = file.path(); .overflow_y_scroll()
let path_style = file.path_style(cx); .children(
let separator = file.path_style(cx).primary_separator(); changed_buffers
.iter()
.enumerate()
.flat_map(|(index, (buffer, _diff))| {
let file = buffer.read(cx).file()?;
let path = file.path();
let path_style = file.path_style(cx);
let separator = file.path_style(cx).primary_separator();
let file_path = path.parent().and_then(|parent| { let file_path = path.parent().and_then(|parent| {
if parent.is_empty() { if parent.is_empty() {
None None
} else { } else {
Some( Some(
Label::new(format!("{}{separator}", parent.display(path_style))) Label::new(format!(
.color(Color::Muted) "{}{separator}",
parent.display(path_style)
))
.color(Color::Muted)
.size(LabelSize::XSmall)
.buffer_font(cx),
)
}
});
let file_name = path.file_name().map(|name| {
Label::new(name.to_string())
.size(LabelSize::XSmall) .size(LabelSize::XSmall)
.buffer_font(cx), .buffer_font(cx)
) .ml_1p5()
} });
});
let file_name = path.file_name().map(|name| { let file_icon = FileIcons::get_icon(path.as_std_path(), cx)
Label::new(name.to_string()) .map(Icon::from_path)
.size(LabelSize::XSmall) .map(|icon| icon.color(Color::Muted).size(IconSize::Small))
.buffer_font(cx) .unwrap_or_else(|| {
.ml_1p5() Icon::new(IconName::File)
}); .color(Color::Muted)
.size(IconSize::Small)
});
let file_icon = FileIcons::get_icon(path.as_std_path(), cx) let overlay_gradient = linear_gradient(
.map(Icon::from_path) 90.,
.map(|icon| icon.color(Color::Muted).size(IconSize::Small)) linear_color_stop(editor_bg_color, 1.),
.unwrap_or_else(|| { linear_color_stop(editor_bg_color.opacity(0.2), 0.),
Icon::new(IconName::File) );
.color(Color::Muted)
.size(IconSize::Small)
});
let overlay_gradient = linear_gradient( let element = h_flex()
90., .group("edited-code")
linear_color_stop(editor_bg_color, 1.), .id(("file-container", index))
linear_color_stop(editor_bg_color.opacity(0.2), 0.), .py_1()
); .pl_2()
.pr_1()
let element = h_flex() .gap_2()
.group("edited-code") .justify_between()
.id(("file-container", index)) .bg(editor_bg_color)
.py_1() .when(index < changed_buffers.len() - 1, |parent| {
.pl_2() parent.border_color(cx.theme().colors().border).border_b_1()
.pr_1() })
.gap_2()
.justify_between()
.bg(editor_bg_color)
.when(index < changed_buffers.len() - 1, |parent| {
parent.border_color(cx.theme().colors().border).border_b_1()
})
.child(
h_flex()
.id(("file-name-row", index))
.relative()
.pr_8()
.w_full()
.overflow_x_scroll()
.child( .child(
h_flex() h_flex()
.id(("file-name-path", index)) .id(("file-name-row", index))
.cursor_pointer() .relative()
.pr_0p5() .pr_8()
.gap_0p5() .w_full()
.hover(|s| s.bg(cx.theme().colors().element_hover)) .overflow_x_scroll()
.rounded_xs() .child(
.child(file_icon) h_flex()
.children(file_name) .id(("file-name-path", index))
.children(file_path) .cursor_pointer()
.tooltip(Tooltip::text("Go to File")) .pr_0p5()
.on_click({ .gap_0p5()
let buffer = buffer.clone(); .hover(|s| s.bg(cx.theme().colors().element_hover))
cx.listener(move |this, _, window, cx| { .rounded_xs()
this.open_edited_buffer(&buffer, window, cx); .child(file_icon)
}) .children(file_name)
}), .children(file_path)
.tooltip(Tooltip::text("Go to File"))
.on_click({
let buffer = buffer.clone();
cx.listener(move |this, _, window, cx| {
this.open_edited_buffer(&buffer, window, cx);
})
}),
)
.child(
div()
.absolute()
.h_full()
.w_12()
.top_0()
.bottom_0()
.right_0()
.bg(overlay_gradient),
),
) )
.child( .child(
div() h_flex()
.absolute() .gap_1()
.h_full() .visible_on_hover("edited-code")
.w_12() .child(
.top_0() Button::new("review", "Review")
.bottom_0() .label_size(LabelSize::Small)
.right_0() .on_click({
.bg(overlay_gradient), let buffer = buffer.clone();
), cx.listener(move |this, _, window, cx| {
) this.open_edited_buffer(&buffer, window, cx);
.child( })
h_flex() }),
.gap_1() )
.visible_on_hover("edited-code") .child(Divider::vertical().color(DividerColor::BorderVariant))
.child( .child(
Button::new("review", "Review") Button::new("reject-file", "Reject")
.label_size(LabelSize::Small) .label_size(LabelSize::Small)
.on_click({ .disabled(pending_edits)
let buffer = buffer.clone(); .on_click({
cx.listener(move |this, _, window, cx| { let buffer = buffer.clone();
this.open_edited_buffer(&buffer, window, cx); let action_log = action_log.clone();
}) let telemetry = telemetry.clone();
}), move |_, _, cx| {
) action_log.update(cx, |action_log, cx| {
.child(Divider::vertical().color(DividerColor::BorderVariant)) action_log
.child(
Button::new("reject-file", "Reject")
.label_size(LabelSize::Small)
.disabled(pending_edits)
.on_click({
let buffer = buffer.clone();
let action_log = action_log.clone();
let telemetry = telemetry.clone();
move |_, _, cx| {
action_log.update(cx, |action_log, cx| {
action_log
.reject_edits_in_ranges( .reject_edits_in_ranges(
buffer.clone(), buffer.clone(),
vec![Anchor::min_max_range_for_buffer( vec![Anchor::min_max_range_for_buffer(
@@ -4120,37 +4144,38 @@ impl AcpThreadView {
cx, cx,
) )
.detach_and_log_err(cx); .detach_and_log_err(cx);
}) })
} }
}), }),
) )
.child( .child(
Button::new("keep-file", "Keep") Button::new("keep-file", "Keep")
.label_size(LabelSize::Small) .label_size(LabelSize::Small)
.disabled(pending_edits) .disabled(pending_edits)
.on_click({ .on_click({
let buffer = buffer.clone(); let buffer = buffer.clone();
let action_log = action_log.clone(); let action_log = action_log.clone();
let telemetry = telemetry.clone(); let telemetry = telemetry.clone();
move |_, _, cx| { move |_, _, cx| {
action_log.update(cx, |action_log, cx| { action_log.update(cx, |action_log, cx| {
action_log.keep_edits_in_range( action_log.keep_edits_in_range(
buffer.clone(), buffer.clone(),
Anchor::min_max_range_for_buffer( Anchor::min_max_range_for_buffer(
buffer.read(cx).remote_id(), buffer.read(cx).remote_id(),
), ),
Some(telemetry.clone()), Some(telemetry.clone()),
cx, cx,
); );
}) })
} }
}), }),
), ),
); );
Some(element) Some(element)
}, }),
)) )
.into_any_element()
} }
fn render_message_editor(&mut self, window: &mut Window, cx: &mut Context<Self>) -> AnyElement { fn render_message_editor(&mut self, window: &mut Window, cx: &mut Context<Self>) -> AnyElement {