From a6fa2d40342973943bde670fc868a02793c63bf8 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 24 Mar 2026 23:30:19 -0700 Subject: [PATCH] Don't grow agent panel to fill entire center (#52380) This PR simplifies the flexible-width agent panel's rendering such that for now, it will not grow to fill the center area when there are no files open. The problem with doing that is that it makes the bottom dock invisible. We could potentially revisit this, and just shrink the width of the agent panel when the bottom dock was toggled, but that might feel unstable, so for now I'm doing a simpler thing and just keeping the center area visible even when it is empty. Release Notes: - N/A --- crates/workspace/src/dock.rs | 2 +- crates/workspace/src/workspace.rs | 20 +------------------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/crates/workspace/src/dock.rs b/crates/workspace/src/dock.rs index 7e86a5a8a3314dd20c3bd0320a3d2a3657496ce3..459f7a697177c4cd6776ebf5838307eaa794bb27 100644 --- a/crates/workspace/src/dock.rs +++ b/crates/workspace/src/dock.rs @@ -1017,7 +1017,7 @@ pub(crate) fn resolve_panel_size( if position.axis() == Axis::Horizontal && panel.supports_flexible_size(window, cx) { let ratio = size_state .flexible_size_ratio - .or_else(|| workspace.default_flexible_dock_ratio(position, cx)); + .or_else(|| workspace.default_flexible_dock_ratio(position)); if let Some(ratio) = ratio { return workspace diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 52c84b82a46b58830a8fe936a2a6bbb09f895588..4dc3599db3e0956eee8ad5d98f8c54329376465e 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -2261,20 +2261,11 @@ impl Workspace { Some((workspace_width - opposite_width).max(RESIZE_HANDLE_SIZE)) } - pub fn default_flexible_dock_ratio(&self, position: DockPosition, cx: &App) -> Option { + pub fn default_flexible_dock_ratio(&self, position: DockPosition) -> Option { if position.axis() != Axis::Horizontal { return None; } - if self - .center - .panes() - .iter() - .all(|pane| pane.read(cx).items_len() == 0) - { - return Some(1.0); - } - let pane = self.last_active_center_pane.clone()?.upgrade()?; let pane_fraction = self.center.width_fraction_for_pane(&pane).unwrap_or(1.0); Some((pane_fraction / (1.0 + pane_fraction)).clamp(0.0, 1.0)) @@ -12268,15 +12259,6 @@ mod tests { let panel = cx.new(|cx| TestPanel::new_flexible(DockPosition::Right, 100, cx)); workspace.add_panel(panel, window, cx); workspace.toggle_dock(DockPosition::Right, window, cx); - - let dock = workspace.right_dock().read(cx); - let workspace_width = workspace.bounds.size.width; - let expanded_width = dock - .active_panel() - .map(|panel| workspace.resolved_dock_panel_size(&dock, panel.as_ref(), window, cx)) - .expect("flexible dock should fill the center when there are no tabs"); - - assert_eq!(expanded_width, workspace_width); }); let (panel, resized_width, ratio_basis_width) =