diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rs index 947322e9d58..c4fd72ca113 100644 --- a/crates/agent_ui/src/agent_panel.rs +++ b/crates/agent_ui/src/agent_panel.rs @@ -5363,37 +5363,28 @@ impl AgentPanel { ) .into_any_element() } else { + let focus_active_thread = { + let conversation_view = conversation_view.downgrade(); + move |window: &mut Window, cx: &mut App| { + if let Some(conversation_view) = conversation_view.upgrade() + && let Some(thread) = + conversation_view.read(cx).active_thread().cloned() + { + thread + .read(cx) + .activation_focus_handle(cx) + .focus(window, cx); + } + } + }; let editable_title = div() .flex_1() .on_action({ - let conversation_view = conversation_view.downgrade(); - move |_: &menu::Confirm, window, cx| { - if let Some(conversation_view) = conversation_view.upgrade() { - let thread = - conversation_view.read(cx).active_thread().cloned(); - if let Some(thread) = thread { - thread - .read(cx) - .activation_focus_handle(cx) - .focus(window, cx); - } - } - } + let focus_active_thread = focus_active_thread.clone(); + move |_: &menu::Confirm, window, cx| focus_active_thread(window, cx) }) - .on_action({ - let conversation_view = conversation_view.downgrade(); - move |_: &editor::actions::Cancel, window, cx| { - if let Some(conversation_view) = conversation_view.upgrade() { - let thread = - conversation_view.read(cx).active_thread().cloned(); - if let Some(thread) = thread { - thread - .read(cx) - .activation_focus_handle(cx) - .focus(window, cx); - } - } - } + .on_action(move |_: &editor::actions::Cancel, window, cx| { + focus_active_thread(window, cx) }) .child(title_editor); @@ -7121,7 +7112,9 @@ mod tests { let thread_view = panel.read_with(cx, |panel, cx| panel.active_thread_view(cx).unwrap()); thread_view.update(cx, |thread_view, cx| { - thread_view.expanded_tool_calls.insert(tool_call_id); + thread_view.entry_view_state.update(cx, |state, _cx| { + state.expand_tool_call(tool_call_id); + }); cx.notify(); }); diff --git a/crates/debugger_ui/src/debugger_panel.rs b/crates/debugger_ui/src/debugger_panel.rs index ee14546bc53..c034363bcd9 100644 --- a/crates/debugger_ui/src/debugger_panel.rs +++ b/crates/debugger_ui/src/debugger_panel.rs @@ -1536,10 +1536,6 @@ impl Focusable for DebugPanel { } impl Panel for DebugPanel { - fn activation_focus_handle(&self, cx: &App) -> FocusHandle { - self.focus_handle(cx) - } - fn persistent_name() -> &'static str { "DebugPanel" } diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 82d4e2da217..8b23423a973 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -7517,10 +7517,6 @@ impl EventEmitter for ProjectPanel {} impl EventEmitter for ProjectPanel {} impl Panel for ProjectPanel { - fn activation_focus_handle(&self, cx: &App) -> FocusHandle { - self.focus_handle(cx) - } - fn position(&self, _: &Window, cx: &App) -> DockPosition { match ProjectPanelSettings::get_global(cx).dock { DockSide::Left => DockPosition::Left, diff --git a/crates/terminal_view/src/terminal_panel.rs b/crates/terminal_view/src/terminal_panel.rs index 2cb31b1ee89..e1f31c3614c 100644 --- a/crates/terminal_view/src/terminal_panel.rs +++ b/crates/terminal_view/src/terminal_panel.rs @@ -1526,10 +1526,6 @@ impl Focusable for TerminalPanel { } impl Panel for TerminalPanel { - fn activation_focus_handle(&self, cx: &App) -> FocusHandle { - self.focus_handle(cx) - } - fn position(&self, _window: &Window, cx: &App) -> DockPosition { TerminalSettings::get_global(cx).dock.into() } diff --git a/crates/workspace/src/dock.rs b/crates/workspace/src/dock.rs index 5700d6953c3..b6c2f419876 100644 --- a/crates/workspace/src/dock.rs +++ b/crates/workspace/src/dock.rs @@ -36,7 +36,9 @@ pub use proto::PanelId; pub trait Panel: Focusable + EventEmitter + Render + Sized { fn persistent_name() -> &'static str; fn panel_key() -> &'static str; - fn activation_focus_handle(&self, cx: &App) -> FocusHandle; + fn activation_focus_handle(&self, cx: &App) -> FocusHandle { + self.focus_handle(cx) + } fn position(&self, window: &Window, cx: &App) -> DockPosition; fn position_is_valid(&self, position: DockPosition) -> bool; fn set_position(&mut self, position: DockPosition, window: &mut Window, cx: &mut Context); @@ -1479,10 +1481,6 @@ pub mod test { } impl Panel for TestPanel { - fn activation_focus_handle(&self, cx: &App) -> FocusHandle { - self.focus_handle(cx) - } - fn persistent_name() -> &'static str { "TestPanel" }