agent_ui: Add setting for turning off content max-width (#54316)
Follow up to https://github.com/zed-industries/zed/pull/52730. This PR adds a boolean setting `limit_content_width` in the Agent Panel settings that allows turning off the content max-width entirely, which was added for better readability. We had a handful of requests for it, so it feels fair. <img width="500" alt="Screenshot 2026-04-20 at 8 57@2x" src="https://github.com/user-attachments/assets/d2540b35-3fa8-4424-895d-dc499ac4839c" /> Release Notes: - Agent: Added a new `limit_content_width` setting in the agent panel that allows turning off the content max-width limit.
This commit is contained in:
1 parent
474846b563
commit
e4e691de17
8 files changed
+83
-32
No files matched your search
@@ -992,7 +992,11 @@
|
||||
"default_width": 640,
|
||||
// Default height when the agent panel is docked to the bottom.
|
||||
"default_height": 320,
|
||||
// Maximum content width when the agent panel is wider than this value.
|
||||
// Whether to limit the content width in the agent panel. When enabled,
|
||||
// content will be constrained to `max_content_width` and centered when
|
||||
// the panel is wider, for optimal readability.
|
||||
"limit_content_width": true,
|
||||
// Maximum content width in pixels when limit_content_width is enabled.
|
||||
// Content will be centered within the panel.
|
||||
"max_content_width": 850,
|
||||
// The default model to use when creating new threads.
|
||||
|
||||
@@ -574,7 +574,7 @@ mod tests {
|
||||
flexible: true,
|
||||
default_width: px(300.),
|
||||
default_height: px(600.),
|
||||
max_content_width: px(850.),
|
||||
max_content_width: Some(px(850.)),
|
||||
default_model: None,
|
||||
inline_assistant_model: None,
|
||||
inline_assistant_use_streaming_tools: false,
|
||||
|
||||
@@ -142,7 +142,7 @@ pub struct AgentSettings {
|
||||
pub sidebar_side: SidebarDockPosition,
|
||||
pub default_width: Pixels,
|
||||
pub default_height: Pixels,
|
||||
pub max_content_width: Pixels,
|
||||
pub max_content_width: Option<Pixels>,
|
||||
pub default_model: Option<LanguageModelSelection>,
|
||||
pub inline_assistant_model: Option<LanguageModelSelection>,
|
||||
pub inline_assistant_use_streaming_tools: bool,
|
||||
@@ -593,7 +593,11 @@ impl Settings for AgentSettings {
|
||||
sidebar_side: agent.sidebar_side.unwrap(),
|
||||
default_width: px(agent.default_width.unwrap()),
|
||||
default_height: px(agent.default_height.unwrap()),
|
||||
max_content_width: px(agent.max_content_width.unwrap()),
|
||||
max_content_width: if agent.limit_content_width.unwrap() {
|
||||
Some(px(agent.max_content_width.unwrap()))
|
||||
} else {
|
||||
None
|
||||
},
|
||||
flexible: agent.flexible.unwrap(),
|
||||
default_model: Some(agent.default_model.unwrap()),
|
||||
inline_assistant_model: agent.inline_assistant_model,
|
||||
|
||||
@@ -3553,9 +3553,8 @@ impl AgentPanel {
|
||||
|
||||
let base_container = h_flex()
|
||||
.size_full()
|
||||
// TODO: This is only until we remove Agent settings from the panel.
|
||||
.when(!is_in_history_or_config, |this| {
|
||||
this.max_w(max_content_width).mx_auto()
|
||||
this.when_some(max_content_width, |this, max_w| this.max_w(max_w).mx_auto())
|
||||
})
|
||||
.flex_none()
|
||||
.justify_between()
|
||||
|
||||
@@ -733,7 +733,7 @@ mod tests {
|
||||
flexible: true,
|
||||
default_width: px(300.),
|
||||
default_height: px(600.),
|
||||
max_content_width: px(850.),
|
||||
max_content_width: Some(px(850.)),
|
||||
default_model: None,
|
||||
inline_assistant_model: None,
|
||||
inline_assistant_use_streaming_tools: false,
|
||||
|
||||
@@ -2289,7 +2289,8 @@ impl ThreadView {
|
||||
.justify_center()
|
||||
.child(
|
||||
v_flex()
|
||||
.flex_basis(max_content_width)
|
||||
.when_some(max_content_width, |this, max_w| this.flex_basis(max_w))
|
||||
.when(max_content_width.is_none(), |this| this.w_full())
|
||||
.flex_shrink()
|
||||
.flex_grow_0()
|
||||
.max_w_full()
|
||||
@@ -3195,8 +3196,7 @@ impl ThreadView {
|
||||
.child(
|
||||
h_flex()
|
||||
.size_full()
|
||||
.max_w(max_content_width)
|
||||
.mx_auto()
|
||||
.when_some(max_content_width, |this, max_w| this.max_w(max_w).mx_auto())
|
||||
.pl_2()
|
||||
.pr_1()
|
||||
.flex_shrink_0()
|
||||
@@ -3293,7 +3293,8 @@ impl ThreadView {
|
||||
})
|
||||
.child(
|
||||
v_flex()
|
||||
.flex_basis(max_content_width)
|
||||
.when_some(max_content_width, |this, max_w| this.flex_basis(max_w))
|
||||
.when(max_content_width.is_none(), |this| this.w_full())
|
||||
.flex_shrink()
|
||||
.flex_grow_0()
|
||||
.when(fills_container, |this| this.h_full())
|
||||
@@ -4481,10 +4482,12 @@ impl ThreadView {
|
||||
fn render_entries(&mut self, cx: &mut Context<Self>) -> List {
|
||||
let max_content_width = AgentSettings::get_global(cx).max_content_width;
|
||||
let centered_container = move |content: AnyElement| {
|
||||
h_flex()
|
||||
.w_full()
|
||||
.justify_center()
|
||||
.child(div().max_w(max_content_width).w_full().child(content))
|
||||
h_flex().w_full().justify_center().child(
|
||||
div()
|
||||
.when_some(max_content_width, |this, max_w| this.max_w(max_w))
|
||||
.w_full()
|
||||
.child(content),
|
||||
)
|
||||
};
|
||||
|
||||
list(
|
||||
|
||||
@@ -128,6 +128,12 @@ pub struct AgentSettingsContent {
|
||||
/// Default: 320
|
||||
#[serde(serialize_with = "crate::serialize_optional_f32_with_two_decimal_places")]
|
||||
pub default_height: Option<f32>,
|
||||
/// Whether to limit the content width in the agent panel. When enabled,
|
||||
/// content will be constrained to `max_content_width` and centered when
|
||||
/// the panel is wider than that value, for optimal readability.
|
||||
///
|
||||
/// Default: true
|
||||
pub limit_content_width: Option<bool>,
|
||||
/// Maximum content width in pixels for the agent panel. Content will be
|
||||
/// centered when the panel is wider than this value.
|
||||
///
|
||||
|
||||
@@ -5859,23 +5859,58 @@ fn panels_page() -> SettingsPage {
|
||||
metadata: None,
|
||||
files: USER,
|
||||
}),
|
||||
SettingsPageItem::SettingItem(SettingItem {
|
||||
title: "Agent Panel Max Content Width",
|
||||
description: "Maximum content width in pixels. Content will be centered when the panel is wider than this value.",
|
||||
field: Box::new(SettingField {
|
||||
json_path: Some("agent.max_content_width"),
|
||||
pick: |settings_content| {
|
||||
settings_content.agent.as_ref()?.max_content_width.as_ref()
|
||||
},
|
||||
write: |settings_content, value| {
|
||||
settings_content
|
||||
.agent
|
||||
.get_or_insert_default()
|
||||
.max_content_width = value;
|
||||
},
|
||||
}),
|
||||
metadata: None,
|
||||
files: USER,
|
||||
SettingsPageItem::DynamicItem(DynamicItem {
|
||||
discriminant: SettingItem {
|
||||
files: USER,
|
||||
title: "Limit Content Width",
|
||||
description: "Whether to constrain the agent panel content to a maximum width, centering it when the panel is wider, for optimal readability.",
|
||||
field: Box::new(SettingField::<bool> {
|
||||
json_path: Some("agent.limit_content_width"),
|
||||
pick: |settings_content| {
|
||||
settings_content
|
||||
.agent
|
||||
.as_ref()?
|
||||
.limit_content_width
|
||||
.as_ref()
|
||||
},
|
||||
write: |settings_content, value| {
|
||||
settings_content
|
||||
.agent
|
||||
.get_or_insert_default()
|
||||
.limit_content_width = value;
|
||||
},
|
||||
}),
|
||||
metadata: None,
|
||||
},
|
||||
pick_discriminant: |settings_content| {
|
||||
let enabled = settings_content
|
||||
.agent
|
||||
.as_ref()?
|
||||
.limit_content_width
|
||||
.unwrap_or(true);
|
||||
Some(if enabled { 1 } else { 0 })
|
||||
},
|
||||
fields: vec![
|
||||
vec![],
|
||||
vec![SettingItem {
|
||||
files: USER,
|
||||
title: "Max Content Width",
|
||||
description: "Maximum content width in pixels. Content will be centered when the panel is wider than this value.",
|
||||
field: Box::new(SettingField {
|
||||
json_path: Some("agent.max_content_width"),
|
||||
pick: |settings_content| {
|
||||
settings_content.agent.as_ref()?.max_content_width.as_ref()
|
||||
},
|
||||
write: |settings_content, value| {
|
||||
settings_content
|
||||
.agent
|
||||
.get_or_insert_default()
|
||||
.max_content_width = value;
|
||||
},
|
||||
}),
|
||||
metadata: None,
|
||||
}],
|
||||
],
|
||||
}),
|
||||
]
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user