diff --git a/crates/agent_ui/src/threads_panel.rs b/crates/agent_ui/src/threads_panel.rs index 904dc6b368690dcdf88a00027db6bf7bc9357b31..fd001f0a96b5d32929873f561291c4cd92aa5f9e 100644 --- a/crates/agent_ui/src/threads_panel.rs +++ b/crates/agent_ui/src/threads_panel.rs @@ -2113,12 +2113,21 @@ impl Panel for ThreadsPanel { } } - fn secondary_button(&self, _window: &Window, _cx: &App) -> Option { - Some(PanelIconButton { - icon: IconName::ZedAssistant, - tooltip: "Agent Drawer", - action: Box::new(ToggleAgentDrawer), - }) + fn secondary_button(&self, _window: &Window, cx: &App) -> Option<(PanelIconButton, bool)> { + let is_active = self + .multi_workspace + .read_with(cx, |mw, cx| { + mw.workspace().read(cx).drawer_is_open::() + }) + .unwrap_or(false); + Some(( + PanelIconButton { + icon: IconName::ZedAssistant, + tooltip: "Agent Drawer", + action: Box::new(ToggleAgentDrawer), + }, + is_active, + )) } fn activation_priority(&self) -> u32 { diff --git a/crates/workspace/src/dock.rs b/crates/workspace/src/dock.rs index 91cc15def50c0c30ef663492ee4342bf449b5380..7d0dc9a11f1fa60d6d26976dd2e2dfcbe0886cab 100644 --- a/crates/workspace/src/dock.rs +++ b/crates/workspace/src/dock.rs @@ -41,7 +41,7 @@ pub trait Panel: Focusable + EventEmitter + Render + Sized { fn size(&self, window: &Window, cx: &App) -> Pixels; fn set_size(&mut self, size: Option, window: &mut Window, cx: &mut Context); fn icon_button(&self, window: &Window, cx: &App) -> PanelIconButton; - fn secondary_button(&self, _window: &Window, _cx: &App) -> Option { + fn secondary_button(&self, _window: &Window, _cx: &App) -> Option<(PanelIconButton, bool)> { None } fn is_zoomed(&self, _window: &Window, _cx: &App) -> bool { @@ -79,7 +79,7 @@ pub trait PanelHandle: Send + Sync { fn size(&self, window: &Window, cx: &App) -> Pixels; fn set_size(&self, size: Option, window: &mut Window, cx: &mut App); fn icon_button(&self, window: &Window, cx: &App) -> PanelIconButton; - fn secondary_button(&self, window: &Window, cx: &App) -> Option; + fn secondary_button(&self, window: &Window, cx: &App) -> Option<(PanelIconButton, bool)>; fn panel_focus_handle(&self, cx: &App) -> FocusHandle; fn to_any(&self) -> AnyView; fn activation_priority(&self, cx: &App) -> u32; @@ -161,7 +161,7 @@ where self.read(cx).icon_button(window, cx) } - fn secondary_button(&self, window: &Window, cx: &App) -> Option { + fn secondary_button(&self, window: &Window, cx: &App) -> Option<(PanelIconButton, bool)> { self.read(cx).secondary_button(window, cx) } @@ -982,12 +982,12 @@ impl Render for PanelButtons { }); match secondary_button { - Some(secondary_button) => { + Some((secondary_button, secondary_button_is_active)) => { let action = secondary_button.action.boxed_clone(); let secondary_button = IconButton::new("secondary-button", secondary_button.icon) .icon_size(IconSize::Small) - .toggle_state(false) // todo! show active when drawer is open + .toggle_state(secondary_button_is_active) .on_click({ let action = action.boxed_clone(); move |_, window, cx| {