From 90cf81cb00a85204bffeb28b9aae1b3493731399 Mon Sep 17 00:00:00 2001 From: Ben Brandt Date: Thu, 26 Feb 2026 13:47:20 +0100 Subject: [PATCH] agent_ui: Unify ui elements (#50201) The ACP monikers are left over from when we had two versions of everything. Now that all agents, including our own, use the same UI components, it seems silly to have all of this separation. Flattens files and removes unneeded Acp prefixes Release Notes: - N/A --- crates/agent_ui/src/acp.rs | 14 --- crates/agent_ui/src/agent_panel.rs | 36 ++++--- crates/agent_ui/src/agent_ui.rs | 14 ++- crates/agent_ui/src/completion_provider.rs | 6 +- .../agent_ui/src/{acp => }/config_options.rs | 0 .../thread_view.rs => connection_view.rs} | 96 +++++++++---------- .../thread_view.rs} | 36 +++---- .../src/{acp => }/entry_view_state.rs | 14 +-- crates/agent_ui/src/inline_assistant.rs | 10 +- crates/agent_ui/src/inline_prompt_editor.rs | 8 +- .../agent_ui/src/{acp => }/message_editor.rs | 66 ++++++------- .../agent_ui/src/{acp => }/mode_selector.rs | 0 .../agent_ui/src/{acp => }/model_selector.rs | 73 +++++++------- .../src/{acp => }/model_selector_popover.rs | 14 +-- .../agent_ui/src/terminal_inline_assistant.rs | 4 +- crates/agent_ui/src/text_thread_editor.rs | 2 +- .../agent_ui/src/{acp => }/thread_history.rs | 46 ++++----- 17 files changed, 217 insertions(+), 222 deletions(-) delete mode 100644 crates/agent_ui/src/acp.rs rename crates/agent_ui/src/{acp => }/config_options.rs (100%) rename crates/agent_ui/src/{acp/thread_view.rs => connection_view.rs} (98%) rename crates/agent_ui/src/{acp/thread_view/active_thread.rs => connection_view/thread_view.rs} (99%) rename crates/agent_ui/src/{acp => }/entry_view_state.rs (97%) rename crates/agent_ui/src/{acp => }/message_editor.rs (98%) rename crates/agent_ui/src/{acp => }/mode_selector.rs (100%) rename crates/agent_ui/src/{acp => }/model_selector.rs (92%) rename crates/agent_ui/src/{acp => }/model_selector_popover.rs (90%) rename crates/agent_ui/src/{acp => }/thread_history.rs (97%) diff --git a/crates/agent_ui/src/acp.rs b/crates/agent_ui/src/acp.rs deleted file mode 100644 index f76e64b557e7ee2ec6054bd0fab0afc36b201e2c..0000000000000000000000000000000000000000 --- a/crates/agent_ui/src/acp.rs +++ /dev/null @@ -1,14 +0,0 @@ -mod config_options; -mod entry_view_state; -mod message_editor; -mod mode_selector; -mod model_selector; -mod model_selector_popover; -mod thread_history; -pub(crate) mod thread_view; - -pub use mode_selector::ModeSelector; -pub use model_selector::AcpModelSelector; -pub use model_selector_popover::AcpModelSelectorPopover; -pub use thread_history::*; -pub use thread_view::AcpServerView; diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rs index d6756cdabe4b75f9a3d67b3816dba7297bdfe2a8..5269e3f1b8d03d16577e4aaeea0c258140853cb5 100644 --- a/crates/agent_ui/src/agent_panel.rs +++ b/crates/agent_ui/src/agent_panel.rs @@ -26,11 +26,10 @@ use zed_actions::agent::{OpenClaudeAgentOnboardingModal, ReauthenticateAgent, Re use crate::ui::{AcpOnboardingModal, ClaudeCodeOnboardingModal}; use crate::{ - AddContextServer, AgentDiffPane, CopyThreadToClipboard, Follow, InlineAssistant, - LoadThreadFromClipboard, NewTextThread, NewThread, OpenActiveThreadAsMarkdown, OpenAgentDiff, - OpenHistory, ResetTrialEndUpsell, ResetTrialUpsell, ToggleNavigationMenu, ToggleNewThreadMenu, - ToggleOptionsMenu, - acp::AcpServerView, + AddContextServer, AgentDiffPane, ConnectionView, CopyThreadToClipboard, Follow, + InlineAssistant, LoadThreadFromClipboard, NewTextThread, NewThread, OpenActiveThreadAsMarkdown, + OpenAgentDiff, OpenHistory, ResetTrialEndUpsell, ResetTrialUpsell, ToggleNavigationMenu, + ToggleNewThreadMenu, ToggleOptionsMenu, agent_configuration::{AgentConfiguration, AssistantConfigurationEvent}, slash_command::SlashCommandCompletionProvider, text_thread_editor::{AgentPanelDelegate, TextThreadEditor, make_lsp_adapter_delegate}, @@ -40,11 +39,10 @@ use crate::{ AgentInitialContent, ExternalAgent, NewExternalAgentThread, NewNativeAgentThreadFromSummary, }; use crate::{ - ExpandMessageEditor, - acp::{AcpThreadHistory, ThreadHistoryEvent}, + ExpandMessageEditor, ThreadHistory, ThreadHistoryEvent, text_thread_history::{TextThreadHistory, TextThreadHistoryEvent}, }; -use crate::{ManageProfiles, acp::thread_view::AcpThreadView}; +use crate::{ManageProfiles, connection_view::ThreadView}; use agent_settings::AgentSettings; use ai_onboarding::AgentPanelOnboarding; use anyhow::{Result, anyhow}; @@ -341,7 +339,7 @@ enum HistoryKind { enum ActiveView { Uninitialized, AgentThread { - server_view: Entity, + server_view: Entity, }, TextThread { text_thread_editor: Entity, @@ -504,7 +502,7 @@ pub struct AgentPanel { project: Entity, fs: Arc, language_registry: Arc, - acp_history: Entity, + acp_history: Entity, text_thread_history: Entity, thread_store: Entity, text_thread_store: Entity, @@ -679,7 +677,7 @@ impl AgentPanel { cx.new(|cx| ContextServerRegistry::new(project.read(cx).context_server_store(), cx)); let thread_store = ThreadStore::global(cx); - let acp_history = cx.new(|cx| AcpThreadHistory::new(None, window, cx)); + let acp_history = cx.new(|cx| ThreadHistory::new(None, window, cx)); let text_thread_history = cx.new(|cx| TextThreadHistory::new(text_thread_store.clone(), window, cx)); cx.subscribe_in( @@ -863,7 +861,7 @@ impl AgentPanel { &self.thread_store } - pub fn history(&self) -> &Entity { + pub fn history(&self) -> &Entity { &self.acp_history } @@ -903,7 +901,7 @@ impl AgentPanel { .unwrap_or(false) } - pub(crate) fn active_thread_view(&self) -> Option<&Entity> { + pub(crate) fn active_thread_view(&self) -> Option<&Entity> { match &self.active_view { ActiveView::AgentThread { server_view, .. } => Some(server_view), ActiveView::Uninitialized @@ -1546,14 +1544,14 @@ impl AgentPanel { } } - pub fn as_active_server_view(&self) -> Option<&Entity> { + pub fn as_active_server_view(&self) -> Option<&Entity> { match &self.active_view { ActiveView::AgentThread { server_view } => Some(server_view), _ => None, } } - pub fn as_active_thread_view(&self, cx: &App) -> Option> { + pub fn as_active_thread_view(&self, cx: &App) -> Option> { let server_view = self.as_active_server_view()?; server_view.read(cx).active_thread().cloned() } @@ -1855,7 +1853,7 @@ impl AgentPanel { .then(|| self.thread_store.clone()); let server_view = cx.new(|cx| { - crate::acp::AcpServerView::new( + crate::ConnectionView::new( server, resume_thread, initial_content, @@ -2128,7 +2126,7 @@ impl AgentPanel { .into_any() } - fn handle_regenerate_thread_title(thread_view: Entity, cx: &mut App) { + fn handle_regenerate_thread_title(thread_view: Entity, cx: &mut App) { thread_view.update(cx, |thread_view, cx| { if let Some(thread) = thread_view.as_native_thread(cx) { thread.update(cx, |thread, cx| { @@ -3467,7 +3465,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> { + pub fn active_thread_view_for_tests(&self) -> Option<&Entity> { self.active_thread_view() } } @@ -3475,7 +3473,7 @@ impl AgentPanel { #[cfg(test)] mod tests { use super::*; - use crate::acp::thread_view::tests::{StubAgentServer, init_test}; + use crate::connection_view::tests::{StubAgentServer, init_test}; use assistant_text_thread::TextThreadStore; use feature_flags::FeatureFlagAppExt; use fs::FakeFs; diff --git a/crates/agent_ui/src/agent_ui.rs b/crates/agent_ui/src/agent_ui.rs index 61a8fd8779c125b29772959a4d1947a9a23325ef..1eca5a12c12cfc5e96faa83239735a1a1c9522cd 100644 --- a/crates/agent_ui/src/agent_ui.rs +++ b/crates/agent_ui/src/agent_ui.rs @@ -1,4 +1,3 @@ -pub mod acp; mod agent_configuration; mod agent_diff; mod agent_model_selector; @@ -6,13 +5,20 @@ mod agent_panel; mod agent_registry_ui; mod buffer_codegen; mod completion_provider; +mod config_options; +pub(crate) mod connection_view; mod context; mod context_server_configuration; +mod entry_view_state; mod favorite_models; mod inline_assistant; mod inline_prompt_editor; mod language_model_selector; mod mention_set; +mod message_editor; +mod mode_selector; +mod model_selector; +mod model_selector_popover; mod profile_selector; mod slash_command; mod slash_command_picker; @@ -20,6 +26,7 @@ mod terminal_codegen; mod terminal_inline_assistant; mod text_thread_editor; mod text_thread_history; +mod thread_history; mod ui; use std::rc::Rc; @@ -52,7 +59,12 @@ pub use crate::agent_panel::{AgentPanel, AgentPanelEvent, ConcreteAssistantPanel use crate::agent_registry_ui::AgentRegistryPage; pub use crate::inline_assistant::InlineAssistant; pub use agent_diff::{AgentDiffPane, AgentDiffToolbar}; +pub(crate) use connection_view::ConnectionView; +pub(crate) use mode_selector::ModeSelector; +pub(crate) use model_selector::ModelSelector; +pub(crate) use model_selector_popover::ModelSelectorPopover; pub use text_thread_editor::{AgentPanelDelegate, TextThreadEditor}; +pub(crate) use thread_history::*; use zed_actions; actions!( diff --git a/crates/agent_ui/src/completion_provider.rs b/crates/agent_ui/src/completion_provider.rs index baa57368e50fb7a604138e6158b06349b65b75e6..802af37eb7f6700eec376327c19da8aab9b9416f 100644 --- a/crates/agent_ui/src/completion_provider.rs +++ b/crates/agent_ui/src/completion_provider.rs @@ -4,7 +4,7 @@ use std::path::PathBuf; use std::sync::Arc; use std::sync::atomic::AtomicBool; -use crate::acp::AcpThreadHistory; +use crate::ThreadHistory; use acp_thread::{AgentSessionInfo, MentionUri}; use anyhow::Result; use editor::{ @@ -206,7 +206,7 @@ pub struct PromptCompletionProvider { source: Arc, editor: WeakEntity, mention_set: Entity, - history: WeakEntity, + history: WeakEntity, prompt_store: Option>, workspace: WeakEntity, } @@ -216,7 +216,7 @@ impl PromptCompletionProvider { source: T, editor: WeakEntity, mention_set: Entity, - history: WeakEntity, + history: WeakEntity, prompt_store: Option>, workspace: WeakEntity, ) -> Self { diff --git a/crates/agent_ui/src/acp/config_options.rs b/crates/agent_ui/src/config_options.rs similarity index 100% rename from crates/agent_ui/src/acp/config_options.rs rename to crates/agent_ui/src/config_options.rs diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/connection_view.rs similarity index 98% rename from crates/agent_ui/src/acp/thread_view.rs rename to crates/agent_ui/src/connection_view.rs index f4291ba5ce168aff4466bb9d5f5bc29194b302a8..8d38a15544f193e6b8a7aa458a24720d19163cd5 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/connection_view.rs @@ -62,12 +62,12 @@ use zed_actions::assistant::OpenRulesLibrary; use super::config_options::ConfigOptionsView; use super::entry_view_state::EntryViewState; -use super::thread_history::AcpThreadHistory; -use crate::acp::AcpModelSelectorPopover; -use crate::acp::ModeSelector; -use crate::acp::entry_view_state::{EntryViewEvent, ViewEvent}; -use crate::acp::message_editor::{MessageEditor, MessageEditorEvent}; +use super::thread_history::ThreadHistory; +use crate::ModeSelector; +use crate::ModelSelectorPopover; use crate::agent_diff::AgentDiff; +use crate::entry_view_state::{EntryViewEvent, ViewEvent}; +use crate::message_editor::{MessageEditor, MessageEditorEvent}; use crate::profile_selector::{ProfileProvider, ProfileSelector}; use crate::ui::{AgentNotification, AgentNotificationEvent}; use crate::{ @@ -82,8 +82,8 @@ use crate::{ const STOPWATCH_THRESHOLD: Duration = Duration::from_secs(30); const TOKEN_THRESHOLD: u64 = 250; -mod active_thread; -pub use active_thread::*; +mod thread_view; +pub use thread_view::*; pub struct QueuedMessage { pub content: Vec, @@ -269,7 +269,7 @@ impl Conversation { } } -pub struct AcpServerView { +pub struct ConnectionView { agent: Rc, agent_server_store: Entity, workspace: WeakEntity, @@ -277,7 +277,7 @@ pub struct AcpServerView { thread_store: Option>, prompt_store: Option>, server_state: ServerState, - history: Entity, + history: Entity, focus_handle: FocusHandle, notifications: Vec>, notification_subscriptions: HashMap, Vec>, @@ -285,14 +285,14 @@ pub struct AcpServerView { _subscriptions: Vec, } -impl AcpServerView { +impl ConnectionView { pub fn has_auth_methods(&self) -> bool { self.as_connected().map_or(false, |connected| { !connected.connection.auth_methods().is_empty() }) } - pub fn active_thread(&self) -> Option<&Entity> { + pub fn active_thread(&self) -> Option<&Entity> { match &self.server_state { ServerState::Connected(connected) => connected.active_view(), _ => None, @@ -310,7 +310,7 @@ impl AcpServerView { .pending_tool_call(id, cx) } - pub fn parent_thread(&self, cx: &App) -> Option> { + pub fn parent_thread(&self, cx: &App) -> Option> { match &self.server_state { ServerState::Connected(connected) => { let mut current = connected.active_view()?; @@ -327,7 +327,7 @@ impl AcpServerView { } } - pub fn thread_view(&self, session_id: &acp::SessionId) -> Option> { + pub fn thread_view(&self, session_id: &acp::SessionId) -> Option> { let connected = self.as_connected()?; connected.threads.get(session_id).cloned() } @@ -375,7 +375,7 @@ enum ServerState { pub struct ConnectedServerState { auth_state: AuthState, active_id: Option, - threads: HashMap>, + threads: HashMap>, connection: Rc, conversation: Entity, } @@ -403,7 +403,7 @@ struct LoadingView { } impl ConnectedServerState { - pub fn active_view(&self) -> Option<&Entity> { + pub fn active_view(&self) -> Option<&Entity> { self.active_id.as_ref().and_then(|id| self.threads.get(id)) } @@ -430,7 +430,7 @@ impl ConnectedServerState { } } -impl AcpServerView { +impl ConnectionView { pub fn new( agent: Rc, resume_thread: Option, @@ -439,7 +439,7 @@ impl AcpServerView { project: Entity, thread_store: Option>, prompt_store: Option>, - history: Entity, + history: Entity, window: &mut Window, cx: &mut Context, ) -> Self { @@ -761,7 +761,7 @@ impl AcpServerView { initial_content: Option, window: &mut Window, cx: &mut Context, - ) -> Entity { + ) -> Entity { let agent_name = self.agent.name(); let prompt_capabilities = Rc::new(RefCell::new(acp::PromptCapabilities::default())); let available_commands = Rc::new(RefCell::new(vec![])); @@ -833,7 +833,7 @@ impl AcpServerView { let agent_server = self.agent.clone(); let fs = self.project.read(cx).fs().clone(); cx.new(|cx| { - AcpModelSelectorPopover::new( + ModelSelectorPopover::new( selector, agent_server, fs, @@ -910,7 +910,7 @@ impl AcpServerView { let weak = cx.weak_entity(); cx.new(|cx| { - AcpThreadView::new( + ThreadView::new( parent_id, thread, conversation, @@ -2190,7 +2190,7 @@ impl AcpServerView { fn render_markdown(&self, markdown: Entity, style: MarkdownStyle) -> MarkdownElement { let workspace = self.workspace.clone(); MarkdownElement::new(markdown, style).on_url_click(move |text, window, cx| { - crate::acp::thread_view::active_thread::open_link(text, &workspace, window, cx); + crate::connection_view::thread_view::open_link(text, &workspace, window, cx); }) } @@ -2513,7 +2513,7 @@ fn placeholder_text(agent_name: &str, has_commands: bool) -> String { } } -impl Focusable for AcpServerView { +impl Focusable for ConnectionView { fn focus_handle(&self, cx: &App) -> FocusHandle { match self.active_thread() { Some(thread) => thread.read(cx).focus_handle(cx), @@ -2523,7 +2523,7 @@ impl Focusable for AcpServerView { } #[cfg(any(test, feature = "test-support"))] -impl AcpServerView { +impl ConnectionView { /// Expands a tool call so its content is visible. /// This is primarily useful for visual testing. pub fn expand_tool_call(&mut self, tool_call_id: acp::ToolCallId, cx: &mut Context) { @@ -2536,7 +2536,7 @@ impl AcpServerView { } } -impl Render for AcpServerView { +impl Render for ConnectionView { fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { self.sync_queued_message_editors(window, cx); @@ -2715,11 +2715,11 @@ pub(crate) mod tests { let thread_store = cx.update(|_window, cx| cx.new(|cx| ThreadStore::new(cx))); // Create history without an initial session list - it will be set after connection - let history = cx.update(|window, cx| cx.new(|cx| AcpThreadHistory::new(None, window, cx))); + let history = cx.update(|window, cx| cx.new(|cx| ThreadHistory::new(None, window, cx))); let thread_view = cx.update(|window, cx| { cx.new(|cx| { - AcpServerView::new( + ConnectionView::new( Rc::new(StubAgentServer::default_response()), None, None, @@ -2787,11 +2787,11 @@ pub(crate) mod tests { let workspace = multi_workspace.read_with(cx, |mw, _| mw.workspace().clone()); let thread_store = cx.update(|_window, cx| cx.new(|cx| ThreadStore::new(cx))); - let history = cx.update(|window, cx| cx.new(|cx| AcpThreadHistory::new(None, window, cx))); + let history = cx.update(|window, cx| cx.new(|cx| ThreadHistory::new(None, window, cx))); let thread_view = cx.update(|window, cx| { cx.new(|cx| { - AcpServerView::new( + ConnectionView::new( Rc::new(StubAgentServer::new(ResumeOnlyAgentConnection)), Some(session), None, @@ -2841,11 +2841,11 @@ pub(crate) mod tests { session.cwd = Some(PathBuf::from("/project/subdir")); let thread_store = cx.update(|_window, cx| cx.new(|cx| ThreadStore::new(cx))); - let history = cx.update(|window, cx| cx.new(|cx| AcpThreadHistory::new(None, window, cx))); + let history = cx.update(|window, cx| cx.new(|cx| ThreadHistory::new(None, window, cx))); let _thread_view = cx.update(|window, cx| { cx.new(|cx| { - AcpServerView::new( + ConnectionView::new( Rc::new(StubAgentServer::new(connection)), Some(session), None, @@ -2893,11 +2893,11 @@ pub(crate) mod tests { session.cwd = Some(PathBuf::from("/some/other/path")); let thread_store = cx.update(|_window, cx| cx.new(|cx| ThreadStore::new(cx))); - let history = cx.update(|window, cx| cx.new(|cx| AcpThreadHistory::new(None, window, cx))); + let history = cx.update(|window, cx| cx.new(|cx| ThreadHistory::new(None, window, cx))); let _thread_view = cx.update(|window, cx| { cx.new(|cx| { - AcpServerView::new( + ConnectionView::new( Rc::new(StubAgentServer::new(connection)), Some(session), None, @@ -2945,11 +2945,11 @@ pub(crate) mod tests { session.cwd = Some(PathBuf::from("/project/../outside")); let thread_store = cx.update(|_window, cx| cx.new(|cx| ThreadStore::new(cx))); - let history = cx.update(|window, cx| cx.new(|cx| AcpThreadHistory::new(None, window, cx))); + let history = cx.update(|window, cx| cx.new(|cx| ThreadHistory::new(None, window, cx))); let _thread_view = cx.update(|window, cx| { cx.new(|cx| { - AcpServerView::new( + ConnectionView::new( Rc::new(StubAgentServer::new(connection)), Some(session), None, @@ -3065,7 +3065,7 @@ pub(crate) mod tests { ); }); - // Authenticate using the real authenticate flow on AcpServerView. + // Authenticate using the real authenticate flow on ConnectionView. // This calls connection.authenticate(), which flips the internal flag, // then on success triggers reset() -> new_session() which now succeeds. thread_view.update_in(cx, |view, window, cx| { @@ -3252,12 +3252,12 @@ pub(crate) mod tests { // Set up thread view in workspace 1 let thread_store = cx.update(|_window, cx| cx.new(|cx| ThreadStore::new(cx))); - let history = cx.update(|window, cx| cx.new(|cx| AcpThreadHistory::new(None, window, cx))); + let history = cx.update(|window, cx| cx.new(|cx| ThreadHistory::new(None, window, cx))); let agent = StubAgentServer::default_response(); let thread_view = cx.update(|window, cx| { cx.new(|cx| { - AcpServerView::new( + ConnectionView::new( Rc::new(agent), None, None, @@ -3421,7 +3421,7 @@ pub(crate) mod tests { async fn setup_thread_view( agent: impl AgentServer + 'static, cx: &mut TestAppContext, - ) -> (Entity, &mut VisualTestContext) { + ) -> (Entity, &mut VisualTestContext) { let fs = FakeFs::new(cx.executor()); let project = Project::test(fs, [], cx).await; let (multi_workspace, cx) = @@ -3429,11 +3429,11 @@ pub(crate) mod tests { let workspace = multi_workspace.read_with(cx, |mw, _| mw.workspace().clone()); let thread_store = cx.update(|_window, cx| cx.new(|cx| ThreadStore::new(cx))); - let history = cx.update(|window, cx| cx.new(|cx| AcpThreadHistory::new(None, window, cx))); + let history = cx.update(|window, cx| cx.new(|cx| ThreadHistory::new(None, window, cx))); let thread_view = cx.update(|window, cx| { cx.new(|cx| { - AcpServerView::new( + ConnectionView::new( Rc::new(agent), None, None, @@ -3451,7 +3451,7 @@ pub(crate) mod tests { (thread_view, cx) } - fn add_to_workspace(thread_view: Entity, cx: &mut VisualTestContext) { + fn add_to_workspace(thread_view: Entity, cx: &mut VisualTestContext) { let workspace = thread_view.read_with(cx, |thread_view, _cx| thread_view.workspace.clone()); workspace @@ -3467,7 +3467,7 @@ pub(crate) mod tests { .unwrap(); } - struct ThreadViewItem(Entity); + struct ThreadViewItem(Entity); impl Item for ThreadViewItem { type Event = (); @@ -4030,9 +4030,9 @@ pub(crate) mod tests { } fn active_thread( - thread_view: &Entity, + thread_view: &Entity, cx: &TestAppContext, - ) -> Entity { + ) -> Entity { cx.read(|cx| { thread_view .read(cx) @@ -4043,7 +4043,7 @@ pub(crate) mod tests { } fn message_editor( - thread_view: &Entity, + thread_view: &Entity, cx: &TestAppContext, ) -> Entity { let thread = active_thread(thread_view, cx); @@ -4069,12 +4069,12 @@ pub(crate) mod tests { let workspace = multi_workspace.read_with(cx, |mw, _| mw.workspace().clone()); let thread_store = cx.update(|_window, cx| cx.new(|cx| ThreadStore::new(cx))); - let history = cx.update(|window, cx| cx.new(|cx| AcpThreadHistory::new(None, window, cx))); + let history = cx.update(|window, cx| cx.new(|cx| ThreadHistory::new(None, window, cx))); let connection = Rc::new(StubAgentConnection::new()); let thread_view = cx.update(|window, cx| { cx.new(|cx| { - AcpServerView::new( + ConnectionView::new( Rc::new(StubAgentServer::new(connection.as_ref().clone())), None, None, @@ -4601,7 +4601,7 @@ pub(crate) mod tests { } struct GeneratingThreadSetup { - thread_view: Entity, + thread_view: Entity, thread: Entity, message_editor: Entity, } diff --git a/crates/agent_ui/src/acp/thread_view/active_thread.rs b/crates/agent_ui/src/connection_view/thread_view.rs similarity index 99% rename from crates/agent_ui/src/acp/thread_view/active_thread.rs rename to crates/agent_ui/src/connection_view/thread_view.rs index 2a98e528238edd4763d1a14e09e6f8916776fa7f..ac605c7990359c90d172d083388be39476cd9656 100644 --- a/crates/agent_ui/src/acp/thread_view/active_thread.rs +++ b/crates/agent_ui/src/connection_view/thread_view.rs @@ -186,12 +186,12 @@ impl DiffStats { } } -pub struct AcpThreadView { +pub struct ThreadView { pub id: acp::SessionId, pub parent_id: Option, pub thread: Entity, pub(crate) conversation: Entity, - pub server_view: WeakEntity, + pub server_view: WeakEntity, pub agent_icon: IconName, pub agent_name: SharedString, pub focus_handle: FocusHandle, @@ -200,7 +200,7 @@ pub struct AcpThreadView { pub title_editor: Entity, pub config_options_view: Option>, pub mode_selector: Option>, - pub model_selector: Option>, + pub model_selector: Option>, pub profile_selector: Option>, pub permission_dropdown_handle: PopoverMenuHandle, pub thread_retry_status: Option, @@ -252,10 +252,10 @@ pub struct AcpThreadView { pub recent_history_entries: Vec, pub hovered_recent_history_item: Option, pub show_codex_windows_warning: bool, - pub history: Entity, + pub history: Entity, pub _history_subscription: Subscription, } -impl Focusable for AcpThreadView { +impl Focusable for ThreadView { fn focus_handle(&self, cx: &App) -> FocusHandle { if self.parent_id.is_some() { self.focus_handle.clone() @@ -275,12 +275,12 @@ pub struct TurnFields { pub turn_tokens: Option, } -impl AcpThreadView { +impl ThreadView { pub(crate) fn new( parent_id: Option, thread: Entity, conversation: Entity, - server_view: WeakEntity, + server_view: WeakEntity, agent_icon: IconName, agent_name: SharedString, agent_display_name: SharedString, @@ -288,7 +288,7 @@ impl AcpThreadView { entry_view_state: Entity, config_options_view: Option>, mode_selector: Option>, - model_selector: Option>, + model_selector: Option>, profile_selector: Option>, list_state: ListState, prompt_capabilities: Rc>, @@ -297,7 +297,7 @@ impl AcpThreadView { resume_thread_metadata: Option, project: WeakEntity, thread_store: Option>, - history: Entity, + history: Entity, prompt_store: Option>, initial_content: Option, mut subscriptions: Vec, @@ -671,7 +671,7 @@ impl AcpThreadView { let agent_name = self.agent_name.clone(); let server_view = self.server_view.clone(); move |window, cx| { - AcpServerView::handle_auth_required( + ConnectionView::handle_auth_required( server_view.clone(), AuthRequired::new(), agent_name, @@ -1504,7 +1504,7 @@ impl AcpThreadView { pub fn sync_thread( &mut self, project: Entity, - server_view: Entity, + server_view: Entity, window: &mut Window, cx: &mut Context, ) { @@ -3429,7 +3429,7 @@ impl AcpThreadView { } } -impl AcpThreadView { +impl ThreadView { pub(crate) fn render_entries(&mut self, cx: &mut Context) -> List { list( self.list_state.clone(), @@ -6130,7 +6130,7 @@ impl AcpThreadView { &self, active_session_id: &acp::SessionId, entry_ix: usize, - thread_view: Option<&Entity>, + thread_view: Option<&Entity>, tool_call: &ToolCall, focus_handle: &FocusHandle, window: &Window, @@ -6400,7 +6400,7 @@ impl AcpThreadView { &self, active_session_id: &acp::SessionId, entry_ix: usize, - thread_view: &Entity, + thread_view: &Entity, is_running: bool, tool_call: &ToolCall, focus_handle: &FocusHandle, @@ -6734,7 +6734,7 @@ impl AcpThreadView { } let connection = this.thread.read(cx).connection().clone(); window.defer(cx, |window, cx| { - AcpServerView::handle_auth_required( + ConnectionView::handle_auth_required( server_view, AuthRequired::new(), agent_name, @@ -6853,7 +6853,7 @@ impl AcpThreadView { fn update_recent_history_from_cache( &mut self, - history: &Entity, + history: &Entity, cx: &mut Context, ) { self.recent_history_entries = history.read(cx).get_recent_sessions(3); @@ -6926,7 +6926,7 @@ impl AcpThreadView { // TODO: Add keyboard navigation. let is_hovered = self.hovered_recent_history_item == Some(index); - crate::acp::thread_history::AcpHistoryEntryElement::new( + crate::thread_history::HistoryEntryElement::new( entry, self.server_view.clone(), ) @@ -7148,7 +7148,7 @@ impl AcpThreadView { } } -impl Render for AcpThreadView { +impl Render for ThreadView { fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { let has_messages = self.list_state.item_count() > 0; diff --git a/crates/agent_ui/src/acp/entry_view_state.rs b/crates/agent_ui/src/entry_view_state.rs similarity index 97% rename from crates/agent_ui/src/acp/entry_view_state.rs rename to crates/agent_ui/src/entry_view_state.rs index 353e1168c8a685bd1822ebe83e7ea2d52733a728..ea794cd5234c60b0932f1a26813854fdb28dcc95 100644 --- a/crates/agent_ui/src/acp/entry_view_state.rs +++ b/crates/agent_ui/src/entry_view_state.rs @@ -1,6 +1,6 @@ use std::{cell::RefCell, ops::Range, rc::Rc}; -use super::thread_history::AcpThreadHistory; +use super::thread_history::ThreadHistory; use acp_thread::{AcpThread, AgentThreadEntry}; use agent::ThreadStore; use agent_client_protocol::{self as acp, ToolCallId}; @@ -19,13 +19,13 @@ use theme::ThemeSettings; use ui::{Context, TextSize}; use workspace::Workspace; -use crate::acp::message_editor::{MessageEditor, MessageEditorEvent}; +use crate::message_editor::{MessageEditor, MessageEditorEvent}; pub struct EntryViewState { workspace: WeakEntity, project: WeakEntity, thread_store: Option>, - history: WeakEntity, + history: WeakEntity, prompt_store: Option>, entries: Vec, prompt_capabilities: Rc>, @@ -38,7 +38,7 @@ impl EntryViewState { workspace: WeakEntity, project: WeakEntity, thread_store: Option>, - history: WeakEntity, + history: WeakEntity, prompt_store: Option>, prompt_capabilities: Rc>, available_commands: Rc>>, @@ -412,7 +412,7 @@ mod tests { use fs::FakeFs; use gpui::{AppContext as _, TestAppContext}; - use crate::acp::entry_view_state::EntryViewState; + use crate::entry_view_state::EntryViewState; use multi_buffer::MultiBufferRow; use pretty_assertions::assert_matches; use project::Project; @@ -459,8 +459,8 @@ mod tests { }); let thread_store = None; - let history = cx - .update(|window, cx| cx.new(|cx| crate::acp::AcpThreadHistory::new(None, window, cx))); + let history = + cx.update(|window, cx| cx.new(|cx| crate::ThreadHistory::new(None, window, cx))); let view_state = cx.new(|_cx| { EntryViewState::new( diff --git a/crates/agent_ui/src/inline_assistant.rs b/crates/agent_ui/src/inline_assistant.rs index f2221675764db228199e8f809d2b6ddf20b46d9e..79d9a4052a6502412f82a9d614f118b8ecbaa2c9 100644 --- a/crates/agent_ui/src/inline_assistant.rs +++ b/crates/agent_ui/src/inline_assistant.rs @@ -7,7 +7,7 @@ use std::rc::Rc; use std::sync::Arc; use uuid::Uuid; -use crate::acp::AcpThreadHistory; +use crate::ThreadHistory; use crate::context::load_context; use crate::mention_set::MentionSet; use crate::{ @@ -487,7 +487,7 @@ impl InlineAssistant { project: WeakEntity, thread_store: Entity, prompt_store: Option>, - history: WeakEntity, + history: WeakEntity, initial_prompt: Option, window: &mut Window, codegen_ranges: &[Range], @@ -626,7 +626,7 @@ impl InlineAssistant { project: WeakEntity, thread_store: Entity, prompt_store: Option>, - history: WeakEntity, + history: WeakEntity, initial_prompt: Option, window: &mut Window, cx: &mut App, @@ -671,7 +671,7 @@ impl InlineAssistant { workspace: Entity, thread_store: Entity, prompt_store: Option>, - history: WeakEntity, + history: WeakEntity, window: &mut Window, cx: &mut App, ) -> InlineAssistId { @@ -2154,7 +2154,7 @@ pub mod test { }); let thread_store = cx.new(|cx| ThreadStore::new(cx)); - let history = cx.new(|cx| crate::acp::AcpThreadHistory::new(None, window, cx)); + let history = cx.new(|cx| crate::ThreadHistory::new(None, window, cx)); // Add editor to workspace workspace.update(cx, |workspace, cx| { diff --git a/crates/agent_ui/src/inline_prompt_editor.rs b/crates/agent_ui/src/inline_prompt_editor.rs index 2066a7ad886614373b200f4e45dd3bb0034f72a2..11e8e59999c59f2ca4eeaccb17a5674a9c1757d9 100644 --- a/crates/agent_ui/src/inline_prompt_editor.rs +++ b/crates/agent_ui/src/inline_prompt_editor.rs @@ -1,4 +1,4 @@ -use crate::acp::AcpThreadHistory; +use crate::ThreadHistory; use agent::ThreadStore; use agent_settings::AgentSettings; use collections::{HashMap, VecDeque}; @@ -64,7 +64,7 @@ pub struct PromptEditor { pub editor: Entity, mode: PromptEditorMode, mention_set: Entity, - history: WeakEntity, + history: WeakEntity, prompt_store: Option>, workspace: WeakEntity, model_selector: Entity, @@ -1225,7 +1225,7 @@ impl PromptEditor { fs: Arc, thread_store: Entity, prompt_store: Option>, - history: WeakEntity, + history: WeakEntity, project: WeakEntity, workspace: WeakEntity, window: &mut Window, @@ -1384,7 +1384,7 @@ impl PromptEditor { fs: Arc, thread_store: Entity, prompt_store: Option>, - history: WeakEntity, + history: WeakEntity, project: WeakEntity, workspace: WeakEntity, window: &mut Window, diff --git a/crates/agent_ui/src/acp/message_editor.rs b/crates/agent_ui/src/message_editor.rs similarity index 98% rename from crates/agent_ui/src/acp/message_editor.rs rename to crates/agent_ui/src/message_editor.rs index 6710969bd89b3ec7307ee13c4efa0df9fa8bcab8..bf6e753c884fa2434b4fa0f95ff7530cb0ab31bd 100644 --- a/crates/agent_ui/src/acp/message_editor.rs +++ b/crates/agent_ui/src/message_editor.rs @@ -1,5 +1,5 @@ use crate::SendImmediately; -use crate::acp::AcpThreadHistory; +use crate::ThreadHistory; use crate::{ ChatWithFollow, completion_provider::{ @@ -107,7 +107,7 @@ impl MessageEditor { workspace: WeakEntity, project: WeakEntity, thread_store: Option>, - history: WeakEntity, + history: WeakEntity, prompt_store: Option>, prompt_capabilities: Rc>, available_commands: Rc>>, @@ -1490,11 +1490,11 @@ mod tests { use util::{path, paths::PathStyle, rel_path::rel_path}; use workspace::{AppState, Item, MultiWorkspace}; - use crate::acp::{ + use crate::completion_provider::{PromptCompletionProviderDelegate, PromptContextType}; + use crate::{ + connection_view::tests::init_test, message_editor::{Mention, MessageEditor, parse_mention_links}, - thread_view::tests::init_test, }; - use crate::completion_provider::{PromptCompletionProviderDelegate, PromptContextType}; #[test] fn test_parse_mention_links() { @@ -1601,8 +1601,8 @@ mod tests { let workspace = multi_workspace.read_with(cx, |mw, _| mw.workspace().clone()); let thread_store = None; - let history = cx - .update(|window, cx| cx.new(|cx| crate::acp::AcpThreadHistory::new(None, window, cx))); + let history = + cx.update(|window, cx| cx.new(|cx| crate::ThreadHistory::new(None, window, cx))); let message_editor = cx.update(|window, cx| { cx.new(|cx| { @@ -1715,8 +1715,8 @@ mod tests { let (multi_workspace, cx) = cx.add_window_view(|window, cx| MultiWorkspace::test_new(project.clone(), window, cx)); let workspace = multi_workspace.read_with(cx, |mw, _| mw.workspace().clone()); - let history = cx - .update(|window, cx| cx.new(|cx| crate::acp::AcpThreadHistory::new(None, window, cx))); + let history = + cx.update(|window, cx| cx.new(|cx| crate::ThreadHistory::new(None, window, cx))); let workspace_handle = workspace.downgrade(); let message_editor = workspace.update_in(cx, |_, window, cx| { cx.new(|cx| { @@ -1871,8 +1871,8 @@ mod tests { let mut cx = VisualTestContext::from_window(window.into(), cx); let thread_store = None; - let history = cx - .update(|window, cx| cx.new(|cx| crate::acp::AcpThreadHistory::new(None, window, cx))); + let history = + cx.update(|window, cx| cx.new(|cx| crate::ThreadHistory::new(None, window, cx))); let prompt_capabilities = Rc::new(RefCell::new(acp::PromptCapabilities::default())); let available_commands = Rc::new(RefCell::new(vec![ acp::AvailableCommand::new("quick-math", "2 + 2 = 4 - 1 = 3"), @@ -2106,8 +2106,8 @@ mod tests { } let thread_store = cx.new(|cx| ThreadStore::new(cx)); - let history = cx - .update(|window, cx| cx.new(|cx| crate::acp::AcpThreadHistory::new(None, window, cx))); + let history = + cx.update(|window, cx| cx.new(|cx| crate::ThreadHistory::new(None, window, cx))); let prompt_capabilities = Rc::new(RefCell::new(acp::PromptCapabilities::default())); let (message_editor, editor) = workspace.update_in(&mut cx, |workspace, window, cx| { @@ -2602,8 +2602,8 @@ mod tests { let workspace = multi_workspace.read_with(cx, |mw, _| mw.workspace().clone()); let thread_store = Some(cx.new(|cx| ThreadStore::new(cx))); - let history = cx - .update(|window, cx| cx.new(|cx| crate::acp::AcpThreadHistory::new(None, window, cx))); + let history = + cx.update(|window, cx| cx.new(|cx| crate::ThreadHistory::new(None, window, cx))); let message_editor = cx.update(|window, cx| { cx.new(|cx| { @@ -2703,8 +2703,8 @@ mod tests { let workspace = multi_workspace.read_with(cx, |mw, _| mw.workspace().clone()); let thread_store = Some(cx.new(|cx| ThreadStore::new(cx))); - let history = cx - .update(|window, cx| cx.new(|cx| crate::acp::AcpThreadHistory::new(None, window, cx))); + let history = + cx.update(|window, cx| cx.new(|cx| crate::ThreadHistory::new(None, window, cx))); // Create a thread metadata to insert as summary let thread_metadata = AgentSessionInfo { @@ -2785,8 +2785,8 @@ mod tests { let workspace = multi_workspace.read_with(cx, |mw, _| mw.workspace().clone()); let thread_store = None; - let history = cx - .update(|window, cx| cx.new(|cx| crate::acp::AcpThreadHistory::new(None, window, cx))); + let history = + cx.update(|window, cx| cx.new(|cx| crate::ThreadHistory::new(None, window, cx))); let thread_metadata = AgentSessionInfo { session_id: acp::SessionId::new("thread-123"), @@ -2845,8 +2845,8 @@ mod tests { let workspace = multi_workspace.read_with(cx, |mw, _| mw.workspace().clone()); let thread_store = None; - let history = cx - .update(|window, cx| cx.new(|cx| crate::acp::AcpThreadHistory::new(None, window, cx))); + let history = + cx.update(|window, cx| cx.new(|cx| crate::ThreadHistory::new(None, window, cx))); let message_editor = cx.update(|window, cx| { cx.new(|cx| { @@ -2900,8 +2900,8 @@ mod tests { let workspace = multi_workspace.read_with(cx, |mw, _| mw.workspace().clone()); let thread_store = Some(cx.new(|cx| ThreadStore::new(cx))); - let history = cx - .update(|window, cx| cx.new(|cx| crate::acp::AcpThreadHistory::new(None, window, cx))); + let history = + cx.update(|window, cx| cx.new(|cx| crate::ThreadHistory::new(None, window, cx))); let message_editor = cx.update(|window, cx| { cx.new(|cx| { @@ -2956,8 +2956,8 @@ mod tests { let workspace = multi_workspace.read_with(cx, |mw, _| mw.workspace().clone()); let thread_store = Some(cx.new(|cx| ThreadStore::new(cx))); - let history = cx - .update(|window, cx| cx.new(|cx| crate::acp::AcpThreadHistory::new(None, window, cx))); + let history = + cx.update(|window, cx| cx.new(|cx| crate::ThreadHistory::new(None, window, cx))); let message_editor = cx.update(|window, cx| { cx.new(|cx| { @@ -3021,8 +3021,8 @@ mod tests { let workspace = multi_workspace.read_with(cx, |mw, _| mw.workspace().clone()); let thread_store = Some(cx.new(|cx| ThreadStore::new(cx))); - let history = cx - .update(|window, cx| cx.new(|cx| crate::acp::AcpThreadHistory::new(None, window, cx))); + let history = + cx.update(|window, cx| cx.new(|cx| crate::ThreadHistory::new(None, window, cx))); let (message_editor, editor) = workspace.update_in(cx, |workspace, window, cx| { let workspace_handle = cx.weak_entity(); @@ -3181,8 +3181,8 @@ mod tests { }); let thread_store = Some(cx.new(|cx| ThreadStore::new(cx))); - let history = cx - .update(|window, cx| cx.new(|cx| crate::acp::AcpThreadHistory::new(None, window, cx))); + let history = + cx.update(|window, cx| cx.new(|cx| crate::ThreadHistory::new(None, window, cx))); // Create a new `MessageEditor`. The `EditorMode::full()` has to be used // to ensure we have a fixed viewport, so we can eventually actually @@ -3302,8 +3302,8 @@ mod tests { let mut cx = VisualTestContext::from_window(window.into(), cx); let thread_store = cx.new(|cx| ThreadStore::new(cx)); - let history = cx - .update(|window, cx| cx.new(|cx| crate::acp::AcpThreadHistory::new(None, window, cx))); + let history = + cx.update(|window, cx| cx.new(|cx| crate::ThreadHistory::new(None, window, cx))); let (message_editor, editor) = workspace.update_in(&mut cx, |workspace, window, cx| { let workspace_handle = cx.weak_entity(); @@ -3385,8 +3385,8 @@ mod tests { let mut cx = VisualTestContext::from_window(window.into(), cx); let thread_store = cx.new(|cx| ThreadStore::new(cx)); - let history = cx - .update(|window, cx| cx.new(|cx| crate::acp::AcpThreadHistory::new(None, window, cx))); + let history = + cx.update(|window, cx| cx.new(|cx| crate::ThreadHistory::new(None, window, cx))); let (message_editor, editor) = workspace.update_in(&mut cx, |workspace, window, cx| { let workspace_handle = cx.weak_entity(); diff --git a/crates/agent_ui/src/acp/mode_selector.rs b/crates/agent_ui/src/mode_selector.rs similarity index 100% rename from crates/agent_ui/src/acp/mode_selector.rs rename to crates/agent_ui/src/mode_selector.rs diff --git a/crates/agent_ui/src/acp/model_selector.rs b/crates/agent_ui/src/model_selector.rs similarity index 92% rename from crates/agent_ui/src/acp/model_selector.rs rename to crates/agent_ui/src/model_selector.rs index 43a39e61088219605d2ee7ab65e610b43137576c..307eda507410a060f551741a998779c44b303b60 100644 --- a/crates/agent_ui/src/acp/model_selector.rs +++ b/crates/agent_ui/src/model_selector.rs @@ -23,7 +23,7 @@ use zed_actions::agent::OpenSettings; use crate::ui::{HoldForDefault, ModelSelectorFooter, ModelSelectorHeader, ModelSelectorListItem}; -pub type AcpModelSelector = Picker; +pub type ModelSelector = Picker; pub fn acp_model_selector( selector: Rc, @@ -31,26 +31,25 @@ pub fn acp_model_selector( fs: Arc, focus_handle: FocusHandle, window: &mut Window, - cx: &mut Context, -) -> AcpModelSelector { - let delegate = - AcpModelPickerDelegate::new(selector, agent_server, fs, focus_handle, window, cx); + cx: &mut Context, +) -> ModelSelector { + let delegate = ModelPickerDelegate::new(selector, agent_server, fs, focus_handle, window, cx); Picker::list(delegate, window, cx) .show_scrollbar(true) .width(rems(20.)) .max_height(Some(rems(20.).into())) } -enum AcpModelPickerEntry { +enum ModelPickerEntry { Separator(SharedString), Model(AgentModelInfo, bool), } -pub struct AcpModelPickerDelegate { +pub struct ModelPickerDelegate { selector: Rc, agent_server: Rc, fs: Arc, - filtered_entries: Vec, + filtered_entries: Vec, models: Option, selected_index: usize, selected_description: Option<(usize, SharedString, bool)>, @@ -61,21 +60,21 @@ pub struct AcpModelPickerDelegate { focus_handle: FocusHandle, } -impl AcpModelPickerDelegate { +impl ModelPickerDelegate { fn new( selector: Rc, agent_server: Rc, fs: Arc, focus_handle: FocusHandle, window: &mut Window, - cx: &mut Context, + cx: &mut Context, ) -> Self { let rx = selector.watch(cx); let refresh_models_task = { cx.spawn_in(window, { async move |this, cx| { async fn refresh( - this: &WeakEntity>, + this: &WeakEntity>, cx: &mut AsyncWindowContext, ) -> Result<()> { let (models_task, selected_model_task) = this.update(cx, |this, cx| { @@ -188,7 +187,7 @@ impl AcpModelPickerDelegate { // Keep the picker selection aligned with the newly-selected model if let Some(new_index) = self.filtered_entries.iter().position(|entry| { - matches!(entry, AcpModelPickerEntry::Model(model_info, _) if self.selected_model.as_ref().is_some_and(|selected| model_info.id == selected.id)) + matches!(entry, ModelPickerEntry::Model(model_info, _) if self.selected_model.as_ref().is_some_and(|selected| model_info.id == selected.id)) }) { self.set_selected_index(new_index, window, cx); } else { @@ -197,7 +196,7 @@ impl AcpModelPickerDelegate { } } -impl PickerDelegate for AcpModelPickerDelegate { +impl PickerDelegate for ModelPickerDelegate { type ListItem = AnyElement; fn match_count(&self) -> usize { @@ -220,8 +219,8 @@ impl PickerDelegate for AcpModelPickerDelegate { _cx: &mut Context>, ) -> bool { match self.filtered_entries.get(ix) { - Some(AcpModelPickerEntry::Model(_, _)) => true, - Some(AcpModelPickerEntry::Separator(_)) | None => false, + Some(ModelPickerEntry::Model(_, _)) => true, + Some(ModelPickerEntry::Separator(_)) | None => false, } } @@ -261,7 +260,7 @@ impl PickerDelegate for AcpModelPickerDelegate { .as_ref() .and_then(|selected| { this.delegate.filtered_entries.iter().position(|entry| { - if let AcpModelPickerEntry::Model(model_info, _) = entry { + if let ModelPickerEntry::Model(model_info, _) = entry { model_info.id == selected.id } else { false @@ -277,7 +276,7 @@ impl PickerDelegate for AcpModelPickerDelegate { } fn confirm(&mut self, _secondary: bool, window: &mut Window, cx: &mut Context>) { - if let Some(AcpModelPickerEntry::Model(model_info, _)) = + if let Some(ModelPickerEntry::Model(model_info, _)) = self.filtered_entries.get(self.selected_index) { if window.modifiers().secondary() { @@ -320,10 +319,10 @@ impl PickerDelegate for AcpModelPickerDelegate { cx: &mut Context>, ) -> Option { match self.filtered_entries.get(ix)? { - AcpModelPickerEntry::Separator(title) => { + ModelPickerEntry::Separator(title) => { Some(ModelSelectorHeader::new(title, ix > 1).into_any_element()) } - AcpModelPickerEntry::Model(model_info, is_favorite) => { + ModelPickerEntry::Model(model_info, is_favorite) => { let is_selected = Some(model_info) == self.selected_model.as_ref(); let default_model = self.agent_server.default_model(cx); let is_default = default_model.as_ref() == Some(&model_info.id); @@ -434,7 +433,7 @@ impl PickerDelegate for AcpModelPickerDelegate { fn info_list_to_picker_entries( model_list: AgentModelList, favorites: &HashSet, -) -> Vec { +) -> Vec { let mut entries = Vec::new(); let all_models: Vec<_> = match &model_list { @@ -450,28 +449,28 @@ fn info_list_to_picker_entries( let has_favorites = !favorite_models.is_empty(); if has_favorites { - entries.push(AcpModelPickerEntry::Separator("Favorite".into())); + entries.push(ModelPickerEntry::Separator("Favorite".into())); for model in favorite_models { - entries.push(AcpModelPickerEntry::Model((*model).clone(), true)); + entries.push(ModelPickerEntry::Model((*model).clone(), true)); } } match model_list { AgentModelList::Flat(list) => { if has_favorites { - entries.push(AcpModelPickerEntry::Separator("All".into())); + entries.push(ModelPickerEntry::Separator("All".into())); } for model in list { let is_favorite = favorites.contains(&model.id); - entries.push(AcpModelPickerEntry::Model(model, is_favorite)); + entries.push(ModelPickerEntry::Model(model, is_favorite)); } } AgentModelList::Grouped(index_map) => { for (group_name, models) in index_map { - entries.push(AcpModelPickerEntry::Separator(group_name.0)); + entries.push(ModelPickerEntry::Separator(group_name.0)); for model in models { let is_favorite = favorites.contains(&model.id); - entries.push(AcpModelPickerEntry::Model(model, is_favorite)); + entries.push(ModelPickerEntry::Model(model, is_favorite)); } } } @@ -608,22 +607,22 @@ mod tests { .collect() } - fn get_entry_model_ids(entries: &[AcpModelPickerEntry]) -> Vec<&str> { + fn get_entry_model_ids(entries: &[ModelPickerEntry]) -> Vec<&str> { entries .iter() .filter_map(|entry| match entry { - AcpModelPickerEntry::Model(info, _) => Some(info.id.0.as_ref()), + ModelPickerEntry::Model(info, _) => Some(info.id.0.as_ref()), _ => None, }) .collect() } - fn get_entry_labels(entries: &[AcpModelPickerEntry]) -> Vec<&str> { + fn get_entry_labels(entries: &[ModelPickerEntry]) -> Vec<&str> { entries .iter() .map(|entry| match entry { - AcpModelPickerEntry::Model(info, _) => info.id.0.as_ref(), - AcpModelPickerEntry::Separator(s) => &s, + ModelPickerEntry::Model(info, _) => info.id.0.as_ref(), + ModelPickerEntry::Separator(s) => &s, }) .collect() } @@ -671,7 +670,7 @@ mod tests { assert!(matches!( entries.first(), - Some(AcpModelPickerEntry::Separator(s)) if s == "Favorite" + Some(ModelPickerEntry::Separator(s)) if s == "Favorite" )); let model_ids = get_entry_model_ids(&entries); @@ -687,7 +686,7 @@ mod tests { assert!(matches!( entries.first(), - Some(AcpModelPickerEntry::Separator(s)) if s == "zed" + Some(ModelPickerEntry::Separator(s)) if s == "zed" )); } @@ -702,7 +701,7 @@ mod tests { let entries = info_list_to_picker_entries(models, &favorites); for entry in &entries { - if let AcpModelPickerEntry::Model(info, is_favorite) = entry { + if let ModelPickerEntry::Model(info, is_favorite) = entry { if info.id.0.as_ref() == "zed/claude" { assert!(is_favorite, "zed/claude should be a favorite"); } else { @@ -789,12 +788,12 @@ mod tests { assert!(matches!( entries.first(), - Some(AcpModelPickerEntry::Separator(s)) if s == "Favorite" + Some(ModelPickerEntry::Separator(s)) if s == "Favorite" )); assert!(entries.iter().any(|e| matches!( e, - AcpModelPickerEntry::Separator(s) if s == "All" + ModelPickerEntry::Separator(s) if s == "All" ))); } @@ -838,7 +837,7 @@ mod tests { let entries = info_list_to_picker_entries(models, &favorites); for entry in &entries { - if let AcpModelPickerEntry::Model(info, is_favorite) = entry { + if let ModelPickerEntry::Model(info, is_favorite) = entry { if info.id.0.as_ref() == "favorite-model" { assert!(*is_favorite, "favorite-model should have is_favorite=true"); } else if info.id.0.as_ref() == "regular-model" { diff --git a/crates/agent_ui/src/acp/model_selector_popover.rs b/crates/agent_ui/src/model_selector_popover.rs similarity index 90% rename from crates/agent_ui/src/acp/model_selector_popover.rs rename to crates/agent_ui/src/model_selector_popover.rs index 941a84faa8782603eb448b3296b99b7d41ab77a0..257337b6b0b8a39645bc38b4d814b250d7b5e1f9 100644 --- a/crates/agent_ui/src/acp/model_selector_popover.rs +++ b/crates/agent_ui/src/model_selector_popover.rs @@ -7,20 +7,20 @@ use gpui::{Entity, FocusHandle}; use picker::popover_menu::PickerPopoverMenu; use ui::{ButtonLike, PopoverMenuHandle, TintColor, Tooltip, prelude::*}; -use crate::acp::{AcpModelSelector, model_selector::acp_model_selector}; use crate::ui::ModelSelectorTooltip; +use crate::{ModelSelector, model_selector::acp_model_selector}; -pub struct AcpModelSelectorPopover { - selector: Entity, - menu_handle: PopoverMenuHandle, +pub struct ModelSelectorPopover { + selector: Entity, + menu_handle: PopoverMenuHandle, } -impl AcpModelSelectorPopover { +impl ModelSelectorPopover { pub(crate) fn new( selector: Rc, agent_server: Rc, fs: Arc, - menu_handle: PopoverMenuHandle, + menu_handle: PopoverMenuHandle, focus_handle: FocusHandle, window: &mut Window, cx: &mut Context, @@ -48,7 +48,7 @@ impl AcpModelSelectorPopover { } } -impl Render for AcpModelSelectorPopover { +impl Render for ModelSelectorPopover { fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { let selector = self.selector.read(cx); let model = selector.delegate.active_model(); diff --git a/crates/agent_ui/src/terminal_inline_assistant.rs b/crates/agent_ui/src/terminal_inline_assistant.rs index 8ee59a0a096172ad9a81983f3517226e824c43e7..2d424c3e1a8ffd33c6933bd50991596bb07a44b2 100644 --- a/crates/agent_ui/src/terminal_inline_assistant.rs +++ b/crates/agent_ui/src/terminal_inline_assistant.rs @@ -1,5 +1,5 @@ use crate::{ - acp::AcpThreadHistory, + ThreadHistory, context::load_context, inline_prompt_editor::{ CodegenStatus, PromptEditor, PromptEditorEvent, TerminalInlineAssistId, @@ -64,7 +64,7 @@ impl TerminalInlineAssistant { project: WeakEntity, thread_store: Entity, prompt_store: Option>, - history: WeakEntity, + history: WeakEntity, initial_prompt: Option, window: &mut Window, cx: &mut App, diff --git a/crates/agent_ui/src/text_thread_editor.rs b/crates/agent_ui/src/text_thread_editor.rs index b878be82e3896733f1eef8d6442cac901366c4a2..13764bd655c23176b3aa016f36eae193e16f92de 100644 --- a/crates/agent_ui/src/text_thread_editor.rs +++ b/crates/agent_ui/src/text_thread_editor.rs @@ -1495,7 +1495,7 @@ impl TextThreadEditor { return; }; - // Get buffer info for the delegate call (even if empty, AcpThreadView ignores these + // Get buffer info for the delegate call (even if empty, ThreadView ignores these // params and calls insert_selections which handles both terminal and buffer) if let Some((selections, buffer)) = maybe!({ let editor = workspace diff --git a/crates/agent_ui/src/acp/thread_history.rs b/crates/agent_ui/src/thread_history.rs similarity index 97% rename from crates/agent_ui/src/acp/thread_history.rs rename to crates/agent_ui/src/thread_history.rs index 76f981b8847a191d66c173df000fdbf619d62239..8f8488cb94f94e036b37ef31c9c588740cd6cf02 100644 --- a/crates/agent_ui/src/acp/thread_history.rs +++ b/crates/agent_ui/src/thread_history.rs @@ -1,4 +1,4 @@ -use crate::acp::AcpServerView; +use crate::ConnectionView; use crate::{AgentPanel, RemoveHistory, RemoveSelectedThread}; use acp_thread::{AgentSessionInfo, AgentSessionList, AgentSessionListRequest, SessionListUpdate}; use agent_client_protocol as acp; @@ -27,7 +27,7 @@ fn thread_title(entry: &AgentSessionInfo) -> &SharedString { .unwrap_or(DEFAULT_TITLE) } -pub struct AcpThreadHistory { +pub struct ThreadHistory { session_list: Option>, sessions: Vec, scroll_handle: UniformListScrollHandle, @@ -70,9 +70,9 @@ pub enum ThreadHistoryEvent { Open(AgentSessionInfo), } -impl EventEmitter for AcpThreadHistory {} +impl EventEmitter for ThreadHistory {} -impl AcpThreadHistory { +impl ThreadHistory { pub fn new( session_list: Option>, window: &mut Window, @@ -720,13 +720,13 @@ impl AcpThreadHistory { } } -impl Focusable for AcpThreadHistory { +impl Focusable for ThreadHistory { fn focus_handle(&self, cx: &App) -> FocusHandle { self.search_editor.focus_handle(cx) } } -impl Render for AcpThreadHistory { +impl Render for ThreadHistory { fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { let has_no_history = self.is_empty(); @@ -860,17 +860,17 @@ impl Render for AcpThreadHistory { } #[derive(IntoElement)] -pub struct AcpHistoryEntryElement { +pub struct HistoryEntryElement { entry: AgentSessionInfo, - thread_view: WeakEntity, + thread_view: WeakEntity, selected: bool, hovered: bool, supports_delete: bool, on_hover: Box, } -impl AcpHistoryEntryElement { - pub fn new(entry: AgentSessionInfo, thread_view: WeakEntity) -> Self { +impl HistoryEntryElement { + pub fn new(entry: AgentSessionInfo, thread_view: WeakEntity) -> Self { Self { entry, thread_view, @@ -897,7 +897,7 @@ impl AcpHistoryEntryElement { } } -impl RenderOnce for AcpHistoryEntryElement { +impl RenderOnce for HistoryEntryElement { fn render(self, _window: &mut Window, _cx: &mut App) -> impl IntoElement { let id = ElementId::Name(self.entry.session_id.0.clone().into()); let title = thread_title(&self.entry).clone(); @@ -1240,7 +1240,7 @@ mod tests { )); let (history, cx) = cx.add_window_view(|window, cx| { - AcpThreadHistory::new(Some(session_list.clone()), window, cx) + ThreadHistory::new(Some(session_list.clone()), window, cx) }); cx.run_until_parked(); @@ -1264,7 +1264,7 @@ mod tests { )); let (history, cx) = cx.add_window_view(|window, cx| { - AcpThreadHistory::new(Some(session_list.clone()), window, cx) + ThreadHistory::new(Some(session_list.clone()), window, cx) }); cx.run_until_parked(); session_list.clear_requested_cursors(); @@ -1301,7 +1301,7 @@ mod tests { )); let (history, cx) = cx.add_window_view(|window, cx| { - AcpThreadHistory::new(Some(session_list.clone()), window, cx) + ThreadHistory::new(Some(session_list.clone()), window, cx) }); cx.run_until_parked(); @@ -1334,7 +1334,7 @@ mod tests { )); let (history, cx) = cx.add_window_view(|window, cx| { - AcpThreadHistory::new(Some(session_list.clone()), window, cx) + ThreadHistory::new(Some(session_list.clone()), window, cx) }); cx.run_until_parked(); @@ -1365,7 +1365,7 @@ mod tests { )); let (history, cx) = cx.add_window_view(|window, cx| { - AcpThreadHistory::new(Some(session_list.clone()), window, cx) + ThreadHistory::new(Some(session_list.clone()), window, cx) }); cx.run_until_parked(); @@ -1410,7 +1410,7 @@ mod tests { ); let (history, cx) = cx.add_window_view(|window, cx| { - AcpThreadHistory::new(Some(session_list.clone()), window, cx) + ThreadHistory::new(Some(session_list.clone()), window, cx) }); cx.run_until_parked(); session_list.clear_requested_cursors(); @@ -1442,7 +1442,7 @@ mod tests { let session_list = Rc::new(TestSessionList::new(sessions)); let (history, cx) = cx.add_window_view(|window, cx| { - AcpThreadHistory::new(Some(session_list.clone()), window, cx) + ThreadHistory::new(Some(session_list.clone()), window, cx) }); cx.run_until_parked(); @@ -1478,7 +1478,7 @@ mod tests { let session_list = Rc::new(TestSessionList::new(sessions)); let (history, cx) = cx.add_window_view(|window, cx| { - AcpThreadHistory::new(Some(session_list.clone()), window, cx) + ThreadHistory::new(Some(session_list.clone()), window, cx) }); cx.run_until_parked(); @@ -1511,7 +1511,7 @@ mod tests { let session_list = Rc::new(TestSessionList::new(sessions)); let (history, cx) = cx.add_window_view(|window, cx| { - AcpThreadHistory::new(Some(session_list.clone()), window, cx) + ThreadHistory::new(Some(session_list.clone()), window, cx) }); cx.run_until_parked(); @@ -1547,7 +1547,7 @@ mod tests { let session_list = Rc::new(TestSessionList::new(sessions)); let (history, cx) = cx.add_window_view(|window, cx| { - AcpThreadHistory::new(Some(session_list.clone()), window, cx) + ThreadHistory::new(Some(session_list.clone()), window, cx) }); cx.run_until_parked(); @@ -1587,7 +1587,7 @@ mod tests { let session_list = Rc::new(TestSessionList::new(sessions)); let (history, cx) = cx.add_window_view(|window, cx| { - AcpThreadHistory::new(Some(session_list.clone()), window, cx) + ThreadHistory::new(Some(session_list.clone()), window, cx) }); cx.run_until_parked(); @@ -1624,7 +1624,7 @@ mod tests { let session_list = Rc::new(TestSessionList::new(sessions)); let (history, cx) = cx.add_window_view(|window, cx| { - AcpThreadHistory::new(Some(session_list.clone()), window, cx) + ThreadHistory::new(Some(session_list.clone()), window, cx) }); cx.run_until_parked();