diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rs index ddee8e8d43839b4fea0aa35b9fcfedf3fc6f9673..3724f738827e747356ebd58e6834237d2ef48c50 100644 --- a/crates/agent_ui/src/agent_panel.rs +++ b/crates/agent_ui/src/agent_panel.rs @@ -222,7 +222,7 @@ pub fn init(cx: &mut App) { .register_action(|workspace, _: &OpenAgentDiff, window, cx| { let thread = workspace .panel::(cx) - .and_then(|panel| panel.read(cx).active_conversation().cloned()) + .and_then(|panel| panel.read(cx).active_conversation_view().cloned()) .and_then(|conversation| { conversation .read(cx) @@ -1188,18 +1188,6 @@ impl AgentPanel { .unwrap_or(false) } - pub fn active_conversation(&self) -> Option<&Entity> { - match &self.active_view { - ActiveView::AgentThread { - conversation_view, .. - } => Some(conversation_view), - ActiveView::Uninitialized - | ActiveView::TextThread { .. } - | ActiveView::History { .. } - | ActiveView::Configuration => None, - } - } - pub fn new_thread(&mut self, _action: &NewThread, window: &mut Window, cx: &mut Context) { self.new_agent_thread(AgentType::NativeAgent, window, cx); } @@ -1411,7 +1399,7 @@ impl AgentPanel { } fn expand_message_editor(&mut self, window: &mut Window, cx: &mut Context) { - let Some(conversation_view) = self.active_conversation() else { + let Some(conversation_view) = self.active_conversation_view() else { return; }; @@ -1737,7 +1725,7 @@ impl AgentPanel { cx: &mut Context, ) { if let Some(workspace) = self.workspace.upgrade() - && let Some(conversation_view) = self.active_conversation() + && let Some(conversation_view) = self.active_conversation_view() && let Some(active_thread) = conversation_view.read(cx).active_thread().cloned() { active_thread.update(cx, |thread, cx| { @@ -2542,7 +2530,7 @@ impl AgentPanel { } pub fn active_thread_is_draft(&self, cx: &App) -> bool { - self.active_conversation().is_some() && !self.active_thread_has_messages(cx) + self.active_conversation_view().is_some() && !self.active_thread_has_messages(cx) } fn handle_first_send_requested( @@ -3936,7 +3924,7 @@ impl AgentPanel { }; let is_thread_loading = self - .active_conversation() + .active_conversation_view() .map(|thread| thread.read(cx).is_loading()) .unwrap_or(false); @@ -4601,7 +4589,7 @@ impl Render for AgentPanel { .on_action(cx.listener(Self::reset_font_size)) .on_action(cx.listener(Self::toggle_zoom)) .on_action(cx.listener(|this, _: &ReauthenticateAgent, window, cx| { - if let Some(conversation_view) = this.active_conversation() { + if let Some(conversation_view) = this.active_conversation_view() { conversation_view.update(cx, |conversation_view, cx| { conversation_view.reauthenticate(window, cx) }) @@ -4797,7 +4785,7 @@ impl AgentPanelDelegate for ConcreteAssistantPanelDelegate { // Wait to create a new context until the workspace is no longer // being updated. cx.defer_in(window, move |panel, window, cx| { - if let Some(conversation_view) = panel.active_conversation() { + if let Some(conversation_view) = panel.active_conversation_view() { conversation_view.update(cx, |conversation_view, cx| { conversation_view.insert_selections(window, cx); }); @@ -4835,7 +4823,7 @@ impl AgentPanelDelegate for ConcreteAssistantPanelDelegate { // Wait to create a new context until the workspace is no longer // being updated. cx.defer_in(window, move |panel, window, cx| { - if let Some(conversation_view) = panel.active_conversation() { + if let Some(conversation_view) = panel.active_conversation_view() { conversation_view.update(cx, |conversation_view, cx| { conversation_view.insert_terminal_text(text, window, cx); }); @@ -4901,7 +4889,7 @@ impl AgentPanel { /// This is a test-only accessor that exposes the private `active_thread_view()` /// method for test assertions. Not compiled into production builds. pub fn active_thread_view_for_tests(&self) -> Option<&Entity> { - self.active_conversation() + self.active_conversation_view() } /// Sets the start_thread_in value directly, bypassing validation. @@ -5091,7 +5079,7 @@ mod tests { "workspace A agent type should be restored" ); assert!( - panel.active_conversation().is_some(), + panel.active_conversation_view().is_some(), "workspace A should have its active thread restored" ); }); @@ -5111,7 +5099,7 @@ mod tests { "workspace B agent type should be restored" ); assert!( - panel.active_conversation().is_none(), + panel.active_conversation_view().is_none(), "workspace B should have no active thread" ); }); @@ -5563,7 +5551,7 @@ mod tests { send_message(&panel, &mut cx); let weak_view_a = panel.read_with(&cx, |panel, _cx| { - panel.active_conversation().unwrap().downgrade() + panel.active_conversation_view().unwrap().downgrade() }); let session_id_a = active_session_id(&panel, &cx); diff --git a/crates/sidebar/src/sidebar.rs b/crates/sidebar/src/sidebar.rs index 9761c9f0ad835cf4cc103700c5f70b715f1b9427..9d979ffde2a56b7bfaec3c89597eb6cfa2c95c9f 100644 --- a/crates/sidebar/src/sidebar.rs +++ b/crates/sidebar/src/sidebar.rs @@ -432,7 +432,7 @@ impl Sidebar { AgentPanelEvent::ActiveViewChanged => { let is_new_draft = agent_panel .read(cx) - .active_conversation() + .active_conversation_view() .is_some_and(|cv| cv.read(cx).parent_id(cx).is_none()); if is_new_draft { this.focused_thread = None; @@ -483,7 +483,7 @@ impl Sidebar { ws.read(cx).panel::(cx) }) .and_then(|panel| { - let cv = panel.read(cx).active_conversation()?; + let cv = panel.read(cx).active_conversation_view()?; let tv = cv.read(cx).active_thread()?; Some(tv.read(cx).message_editor.clone()) }) @@ -498,7 +498,7 @@ impl Sidebar { let mw = self.multi_workspace.upgrade()?; let workspace = mw.read(cx).workspace(); let panel = workspace.read(cx).panel::(cx)?; - let conversation_view = panel.read(cx).active_conversation()?; + let conversation_view = panel.read(cx).active_conversation_view()?; let thread_view = conversation_view.read(cx).active_thread()?; let raw = thread_view.read(cx).message_editor.read(cx).text(cx); let cleaned = Self::clean_mention_links(&raw); @@ -629,7 +629,7 @@ impl Sidebar { .and_then(|panel| { panel .read(cx) - .active_conversation() + .active_conversation_view() .and_then(|cv| cv.read(cx).parent_id(cx)) }); if panel_focused.is_some() && !self.active_thread_is_draft {