From 3c1b1039c33bd9052c80de35e854e78d4af3fa9c Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 11 Mar 2026 14:46:03 -0700 Subject: [PATCH] Return an element directly from PanelHandle::flex_content Co-authored-by: Eric Holk --- crates/agent_ui/src/agent_panel.rs | 6 +----- crates/workspace/src/dock.rs | 25 ++++++------------------- crates/workspace/src/pane_group.rs | 15 +++++++-------- 3 files changed, 14 insertions(+), 32 deletions(-) diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rs index ef659b26d2d7a155fda126c4d947520c146bb3ae..32b72cc983d8ab09129be1cc0acfa9d9f45c31ee 100644 --- a/crates/agent_ui/src/agent_panel.rs +++ b/crates/agent_ui/src/agent_panel.rs @@ -3706,11 +3706,7 @@ impl AgentPanel { let is_agent_selected = move |agent_type: AgentType| selected_agent == agent_type; let workspace = self.workspace.clone(); - let is_via_collab = workspace - .update(cx, |workspace, cx| { - workspace.project().read(cx).is_via_collab() - }) - .unwrap_or_default(); + let is_via_collab = self.project.read(cx).is_via_collab(); let focus_handle = focus_handle.clone(); let agent_server_store = agent_server_store; diff --git a/crates/workspace/src/dock.rs b/crates/workspace/src/dock.rs index 2af8d2e161a8b79effb63a0c25ae6fae5b68c8ed..06af263d3c7e3fcb4ff6a73cfebc02829f4b95eb 100644 --- a/crates/workspace/src/dock.rs +++ b/crates/workspace/src/dock.rs @@ -96,7 +96,7 @@ pub trait PanelHandle: Send + Sync { fn to_any(&self) -> AnyView; fn activation_priority(&self, cx: &App) -> u32; fn enabled(&self, cx: &App) -> bool; - fn flex_content(&self, window: &Window, cx: &mut App) -> Option; + fn flex_content(&self, window: &mut Window, cx: &mut App) -> Option; fn has_flex_content(&self, window: &Window, cx: &App) -> bool; fn has_panel_content(&self, window: &Window, cx: &App) -> bool; fn move_to_next_position(&self, window: &mut Window, cx: &mut App) { @@ -204,11 +204,14 @@ where self.read(cx).enabled(cx) } - fn flex_content(&self, window: &Window, cx: &mut App) -> Option { + fn flex_content(&self, window: &mut Window, cx: &mut App) -> Option { if !self.read(cx).has_flex_content(window, cx) { return None; } - Some(cx.new(|_| PanelCenterView(self.clone())).into()) + Some( + self.update(cx, |this, cx| this.render_flex_content(window, cx)) + .unwrap_or_else(|| gpui::Empty.into_any_element()), + ) } fn has_flex_content(&self, window: &Window, cx: &App) -> bool { @@ -220,17 +223,6 @@ where } } -struct PanelCenterView(Entity); - -impl Render for PanelCenterView { - fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { - self.0.update(cx, |this, cx| { - this.render_flex_content(window, cx) - .unwrap_or_else(|| gpui::Empty.into_any_element()) - }) - } -} - impl From<&dyn PanelHandle> for AnyView { fn from(val: &dyn PanelHandle) -> Self { val.to_any() @@ -732,11 +724,6 @@ impl Dock { Some(&entry.panel) } - pub fn visible_panel_flex_element(&self, window: &Window, cx: &mut App) -> Option { - let entry = self.visible_entry()?; - entry.panel.flex_content(window, cx) - } - pub fn active_panel(&self) -> Option<&Arc> { let panel_entry = self.active_panel_entry()?; Some(&panel_entry.panel) diff --git a/crates/workspace/src/pane_group.rs b/crates/workspace/src/pane_group.rs index 05ab37a1364e3071bf9e2475821920cb861bdf2c..55e517152a09937b1766b3232b057d59b81c2c73 100644 --- a/crates/workspace/src/pane_group.rs +++ b/crates/workspace/src/pane_group.rs @@ -223,8 +223,8 @@ impl PaneGroup { pub fn render( &self, zoomed: Option<&AnyWeakView>, - left_content: Option, - right_content: Option, + left_content: Option, + right_content: Option, render_cx: &dyn PaneLeaderDecorator, window: &mut Window, cx: &mut App, @@ -546,8 +546,8 @@ impl Member { &self, basis: usize, zoomed: Option<&AnyWeakView>, - left_content: Option, - right_content: Option, + left_content: Option, + right_content: Option, pane_group_state: Option, render_cx: &dyn PaneLeaderDecorator, window: &mut Window, @@ -1086,8 +1086,8 @@ impl PaneAxis { basis: usize, zoomed: Option<&AnyWeakView>, pane_group_state: Option, - left_content: Option, - right_content: Option, + left_content: Option, + right_content: Option, render_cx: &dyn PaneLeaderDecorator, window: &mut Window, cx: &mut App, @@ -1098,7 +1098,6 @@ impl PaneAxis { let mut is_leaf_pane = vec![false; self.members.len()]; let rendered_children = left_content - .map(|view| view.into_any_element()) .into_iter() .chain(self.members.iter().enumerate().map(|(ix, member)| { match member { @@ -1129,7 +1128,7 @@ impl PaneAxis { } result.element.into_any_element() })) - .chain(right_content.map(|view| view.into_any_element())) + .chain(right_content) .collect::>(); let element = pane_axis(