From 8cc077d285e62846feb56614880653e938528ac9 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 10 Mar 2026 10:59:17 -0700 Subject: [PATCH] WIP --- crates/workspace/src/multi_workspace.rs | 7 ++++ crates/workspace/src/pane_group.rs | 20 +++++----- crates/workspace/src/workspace.rs | 53 +++++++++++++------------ crates/zed/src/zed.rs | 8 +--- 4 files changed, 46 insertions(+), 42 deletions(-) diff --git a/crates/workspace/src/multi_workspace.rs b/crates/workspace/src/multi_workspace.rs index f9e0bb13047eb6a1f1393b21289515e677679b0a..45f0e7e54b652253b22635e0034539817e14f38e 100644 --- a/crates/workspace/src/multi_workspace.rs +++ b/crates/workspace/src/multi_workspace.rs @@ -215,6 +215,13 @@ impl MultiWorkspace { cx.notify(); } + pub fn set_left_dock_expanded_mode(&mut self, agent_mode: bool, cx: &mut Context) { + self.workspace().update(cx, |workspace, cx| { + workspace.set_left_dock_expanded_mode(agent_mode, cx); + }); + cx.notify(); + } + pub fn toggle_sidebar(&mut self, window: &mut Window, cx: &mut Context) { if !self.multi_workspace_enabled(cx) || self.is_singleton { return; diff --git a/crates/workspace/src/pane_group.rs b/crates/workspace/src/pane_group.rs index aecd1aeeb087e8c241ed5069bfa69accf81ca461..fad3495b2acccceadb8e9ad7920ef51b2d6ebc64 100644 --- a/crates/workspace/src/pane_group.rs +++ b/crates/workspace/src/pane_group.rs @@ -29,8 +29,8 @@ const VERTICAL_MIN_SIZE: f32 = 100.; pub struct PaneGroup { pub root: Member, pub is_center: bool, - left_item_flexes: Arc>>, - left_item_bounding_boxes: Arc>>>>, + root_axis_flexes: Arc>>, + root_axis_bounding_boxes: Arc>>>>, } pub struct PaneRenderResult { @@ -43,8 +43,8 @@ impl PaneGroup { Self { root, is_center: false, - left_item_flexes: Arc::new(Mutex::new(Vec::new())), - left_item_bounding_boxes: Arc::new(Mutex::new(Vec::new())), + root_axis_flexes: Arc::new(Mutex::new(Vec::new())), + root_axis_bounding_boxes: Arc::new(Mutex::new(Vec::new())), } } @@ -52,8 +52,8 @@ impl PaneGroup { Self { root: Member::Pane(pane), is_center: false, - left_item_flexes: Arc::new(Mutex::new(Vec::new())), - left_item_bounding_boxes: Arc::new(Mutex::new(Vec::new())), + root_axis_flexes: Arc::new(Mutex::new(Vec::new())), + root_axis_bounding_boxes: Arc::new(Mutex::new(Vec::new())), } } @@ -266,13 +266,13 @@ impl PaneGroup { let child_count = children.len(); { - let mut flexes = self.left_item_flexes.lock(); + let mut flexes = self.root_axis_flexes.lock(); if flexes.len() != child_count { *flexes = vec![1.0; child_count]; } } { - let mut bounding_boxes = self.left_item_bounding_boxes.lock(); + let mut bounding_boxes = self.root_axis_bounding_boxes.lock(); if bounding_boxes.len() != child_count { *bounding_boxes = vec![None; child_count]; } @@ -281,8 +281,8 @@ impl PaneGroup { pane_axis( Axis::Horizontal, usize::MAX / 2, - self.left_item_flexes.clone(), - self.left_item_bounding_boxes.clone(), + self.root_axis_flexes.clone(), + self.root_axis_bounding_boxes.clone(), render_cx.workspace().clone(), ) .with_is_leaf_pane_mask(is_leaf_pane_mask) diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index e055471859a101105cecb3c81f16b4553526c4a3..0c36fbebeefe2aaf11b078f45081f470669b2bb0 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -1336,7 +1336,7 @@ pub struct Workspace { last_open_dock_positions: Vec, removing: bool, _panels_task: Option>>, - left_item: Option>, + left_dock_expanded_mode: bool, } impl EventEmitter for Workspace {} @@ -1742,7 +1742,6 @@ impl Workspace { scheduled_tasks: Vec::new(), last_open_dock_positions: Vec::new(), removing: false, - left_item: None, } } @@ -2011,19 +2010,15 @@ impl Workspace { &self.left_dock } - pub fn set_left_item(&mut self, view: Option>, cx: &mut Context) { - self.left_item = view; - cx.notify(); - } - - pub fn left_item(&self) -> Option> { - self.left_item.clone() - } - pub fn bottom_dock(&self) -> &Entity { &self.bottom_dock } + pub fn set_left_dock_expanded_mode(&mut self, is_expanded_mode: bool, cx: &mut Context) { + self.left_dock_expanded_mode = is_expanded_mode; + cx.notify(); + } + pub fn set_bottom_dock_layout( &mut self, layout: BottomDockLayout, @@ -7664,8 +7659,13 @@ impl Render for Workspace { (None, None) }; let ui_font = theme::setup_ui_font(window, cx); - let left_item = self.left_item.as_ref().map(|v| v.to_any()); - let render_left_dock = left_item.is_none(); + let expanded_left_panel = self + .left_dock + .read(cx) + .active_panel() + .filter(|_| self.left_dock_expanded_mode) + .map(|p| p.to_any()); + let render_left_dock_with_pixel_width = expanded_left_panel.is_none(); let Self { ref mut center, @@ -7681,7 +7681,7 @@ impl Render for Workspace { let active_call = active_call.as_ref().map(|(call, _)| &*call.0); let center_element = center.render( zoomed.as_ref(), - left_item, + expanded_left_panel, &PaneRenderContext { follower_states, active_call, @@ -7832,7 +7832,7 @@ impl Render for Workspace { .flex_row() .flex_1() .overflow_hidden() - .when(render_left_dock, |this| { + .when(render_left_dock_with_pixel_width, |this| { this.children(self.render_dock( DockPosition::Left, &self.left_dock, @@ -7890,14 +7890,17 @@ impl Render for Workspace { .flex() .flex_row() .flex_1() - .when(render_left_dock, |this| { - this.children(self.render_dock( - DockPosition::Left, - &self.left_dock, - window, - cx, - )) - }) + .when( + render_left_dock_with_pixel_width, + |this| { + this.children(self.render_dock( + DockPosition::Left, + &self.left_dock, + window, + cx, + )) + }, + ) .child( div() .flex() @@ -7945,7 +7948,7 @@ impl Render for Workspace { .flex() .flex_row() .h_full() - .when(render_left_dock, |this| { + .when(render_left_dock_with_pixel_width, |this| { this.children(self.render_dock( DockPosition::Left, &self.left_dock, @@ -8011,7 +8014,7 @@ impl Render for Workspace { .flex() .flex_row() .h_full() - .when(render_left_dock, |this| { + .when(render_left_dock_with_pixel_width, |this| { this.children(self.render_dock( DockPosition::Left, &self.left_dock, diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index 8659990183a3996e45c792bda721607c9184f675..6f1bc083aea10c5e2f6c256f57be1f36dc48bc5e 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -319,6 +319,7 @@ fn toggle_agent_mode( } is_singleton = !is_singleton; let agent_mode = !is_singleton; + multi_workspace.set_left_dock_expanded_mode(agent_mode, cx); let workspace = multi_workspace.workspace(); workspace.update(cx, |workspace, cx| { update_panel_positions(workspace, window, agent_mode, cx); @@ -763,13 +764,6 @@ fn update_panel_positions( agent_mode: bool, cx: &mut Context, ) { - if agent_mode { - let agent_panel_view = find_agent_panel_view(workspace, cx); - workspace.set_left_item(agent_panel_view, cx); - } else { - workspace.set_left_item(None, cx); - } - let panels_and_positions = workspace.all_panel_ids_and_positions(cx); for (panel_id, current_position) in panels_and_positions { let panel_handle = workspace