agent_ui: Restrict agent toolbar width only for threads (#56410)

For all other modes, we want full-width view

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- N/A
This commit is contained in:
Ben Brandt 2026-05-11 15:29:09 +02:00 committed by GitHub
parent 0efac164b3
commit cb715fb374
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3775,10 +3775,22 @@ impl AgentPanel {
selected_agent.into_any_element()
};
let is_empty_state = !matches!(self.base_view, BaseView::Terminal { .. })
&& !self.active_thread_has_messages(cx);
enum ToolbarMode {
Overlay,
Terminal,
EmptyThread,
ActiveThread,
}
let is_in_history_or_config = self.is_overlay_open();
let mode = if self.is_overlay_open() {
ToolbarMode::Overlay
} else if matches!(self.base_view, BaseView::Terminal { .. }) {
ToolbarMode::Terminal
} else if self.active_thread_has_messages(cx) {
ToolbarMode::ActiveThread
} else {
ToolbarMode::EmptyThread
};
let is_full_screen = self.is_zoomed(window, cx);
let full_screen_button = if is_full_screen {
@ -3797,20 +3809,19 @@ impl AgentPanel {
}))
};
let use_v2_empty_toolbar = is_empty_state && !is_in_history_or_config;
let max_content_width = AgentSettings::get_global(cx).max_content_width;
let base_container = h_flex()
.size_full()
.when(!is_in_history_or_config, |this| {
this.when_some(max_content_width, |this, max_w| this.max_w(max_w).mx_auto())
})
.when(
matches!(mode, ToolbarMode::EmptyThread | ToolbarMode::ActiveThread),
|this| this.when_some(max_content_width, |this, max_w| this.max_w(max_w).mx_auto()),
)
.flex_none()
.justify_between()
.gap_2();
let toolbar_content = if use_v2_empty_toolbar {
let toolbar_content = if matches!(mode, ToolbarMode::EmptyThread) {
let (chevron_icon, icon_color, label_color) =
if self.new_thread_menu_handle.is_deployed() {
(IconName::ChevronUp, Color::Accent, Color::Accent)
@ -3903,7 +3914,7 @@ impl AgentPanel {
.size_full()
.gap(DynamicSpacing::Base04.rems(cx))
.pl(DynamicSpacing::Base04.rems(cx))
.child(if self.is_overlay_open() {
.child(if matches!(mode, ToolbarMode::Overlay) {
self.render_toolbar_back_button(cx).into_any_element()
} else {
selected_agent.into_any_element()