From 6cc6e4d4b36a0310b282ec98395829ed0311715f Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Wed, 7 May 2025 21:18:51 -0400 Subject: [PATCH] agent: Rename a number of constructs from Assistant to Agent (#30196) This PR renames a number of constructs in the `agent` crate from the "Assistant" terminology to "Agent". Not comprehensive, but it's a start. Release Notes: - N/A --- crates/agent/Cargo.toml | 2 +- crates/agent/src/active_thread.rs | 13 ++- crates/agent/src/{assistant.rs => agent.rs} | 12 +-- ...onfiguration.rs => agent_configuration.rs} | 12 +-- .../add_context_server_modal.rs | 0 .../configure_context_server_modal.rs | 0 .../manage_profiles_modal.rs | 8 +- .../profile_modal_header.rs | 0 .../tool_picker.rs | 0 ...el_selector.rs => agent_model_selector.rs} | 6 +- .../{assistant_panel.rs => agent_panel.rs} | 92 +++++++++---------- crates/agent/src/context_picker.rs | 4 +- .../agent/src/context_server_configuration.rs | 2 +- crates/agent/src/context_strip.rs | 4 +- crates/agent/src/inline_assistant.rs | 29 +++--- crates/agent/src/inline_prompt_editor.rs | 12 +-- crates/agent/src/message_editor.rs | 6 +- crates/agent/src/thread_history.rs | 62 ++++++------- crates/agent/src/ui/onboarding_modal.rs | 4 +- .../src/context_editor.rs | 26 +++--- .../src/context_history.rs | 8 +- crates/rules_library/src/rules_library.rs | 6 +- crates/zed/src/zed.rs | 10 +- 23 files changed, 155 insertions(+), 163 deletions(-) rename crates/agent/src/{assistant.rs => agent.rs} (96%) rename crates/agent/src/{assistant_configuration.rs => agent_configuration.rs} (99%) rename crates/agent/src/{assistant_configuration => agent_configuration}/add_context_server_modal.rs (100%) rename crates/agent/src/{assistant_configuration => agent_configuration}/configure_context_server_modal.rs (100%) rename crates/agent/src/{assistant_configuration => agent_configuration}/manage_profiles_modal.rs (99%) rename crates/agent/src/{assistant_configuration => agent_configuration}/manage_profiles_modal/profile_modal_header.rs (100%) rename crates/agent/src/{assistant_configuration => agent_configuration}/tool_picker.rs (100%) rename crates/agent/src/{assistant_model_selector.rs => agent_model_selector.rs} (97%) rename crates/agent/src/{assistant_panel.rs => agent_panel.rs} (97%) diff --git a/crates/agent/Cargo.toml b/crates/agent/Cargo.toml index 7cf72bd78c..71f66fe72b 100644 --- a/crates/agent/Cargo.toml +++ b/crates/agent/Cargo.toml @@ -9,7 +9,7 @@ license = "GPL-3.0-or-later" workspace = true [lib] -path = "src/assistant.rs" +path = "src/agent.rs" doctest = false [features] diff --git a/crates/agent/src/active_thread.rs b/crates/agent/src/active_thread.rs index bb88f20947..015d96f0d7 100644 --- a/crates/agent/src/active_thread.rs +++ b/crates/agent/src/active_thread.rs @@ -1,4 +1,4 @@ -use crate::AssistantPanel; +use crate::AgentPanel; use crate::context::{AgentContextHandle, RULES_ICON}; use crate::context_picker::{ContextPicker, MentionLink}; use crate::context_store::ContextStore; @@ -712,7 +712,7 @@ fn open_markdown_link( .detach_and_log_err(cx); } Some(MentionLink::Thread(thread_id)) => workspace.update(cx, |workspace, cx| { - if let Some(panel) = workspace.panel::(cx) { + if let Some(panel) = workspace.panel::(cx) { panel.update(cx, |panel, cx| { panel .open_thread_by_id(&thread_id, window, cx) @@ -721,7 +721,7 @@ fn open_markdown_link( } }), Some(MentionLink::TextThread(path)) => workspace.update(cx, |workspace, cx| { - if let Some(panel) = workspace.panel::(cx) { + if let Some(panel) = workspace.panel::(cx) { panel.update(cx, |panel, cx| { panel .open_saved_prompt_editor(path, window, cx) @@ -1211,8 +1211,7 @@ impl ActiveThread { if let Some(workspace) = workspace_handle.upgrade() { workspace.update(_cx, |workspace, cx| { - workspace - .focus_panel::(window, cx); + workspace.focus_panel::(window, cx); }); } }) @@ -3524,7 +3523,7 @@ pub(crate) fn open_context( } AgentContextHandle::Thread(thread_context) => workspace.update(cx, |workspace, cx| { - if let Some(panel) = workspace.panel::(cx) { + if let Some(panel) = workspace.panel::(cx) { panel.update(cx, |panel, cx| { panel.open_thread(thread_context.thread.clone(), window, cx); }); @@ -3533,7 +3532,7 @@ pub(crate) fn open_context( AgentContextHandle::TextThread(text_thread_context) => { workspace.update(cx, |workspace, cx| { - if let Some(panel) = workspace.panel::(cx) { + if let Some(panel) = workspace.panel::(cx) { panel.update(cx, |panel, cx| { panel.open_prompt_editor(text_thread_context.context.clone(), window, cx) }); diff --git a/crates/agent/src/assistant.rs b/crates/agent/src/agent.rs similarity index 96% rename from crates/agent/src/assistant.rs rename to crates/agent/src/agent.rs index 1a589b62d9..9bf99b0a87 100644 --- a/crates/agent/src/assistant.rs +++ b/crates/agent/src/agent.rs @@ -1,8 +1,8 @@ mod active_thread; +mod agent_configuration; mod agent_diff; -mod assistant_configuration; -mod assistant_model_selector; -mod assistant_panel; +mod agent_model_selector; +mod agent_panel; mod buffer_codegen; mod context; mod context_picker; @@ -43,8 +43,8 @@ use settings::{Settings as _, SettingsStore}; use thread::ThreadId; pub use crate::active_thread::ActiveThread; -use crate::assistant_configuration::{AddContextServerModal, ManageProfilesModal}; -pub use crate::assistant_panel::{AssistantPanel, ConcreteAssistantPanelDelegate}; +use crate::agent_configuration::{AddContextServerModal, ManageProfilesModal}; +pub use crate::agent_panel::{AgentPanel, ConcreteAssistantPanelDelegate}; pub use crate::context::{ContextLoadResult, LoadedContext}; pub use crate::inline_assistant::InlineAssistant; use crate::slash_command_settings::SlashCommandSettings; @@ -126,7 +126,7 @@ pub fn init( init_language_model_settings(cx); assistant_slash_command::init(cx); thread_store::init(cx); - assistant_panel::init(cx); + agent_panel::init(cx); context_server_configuration::init(language_registry, cx); register_slash_commands(cx); diff --git a/crates/agent/src/assistant_configuration.rs b/crates/agent/src/agent_configuration.rs similarity index 99% rename from crates/agent/src/assistant_configuration.rs rename to crates/agent/src/agent_configuration.rs index f089506223..253066b551 100644 --- a/crates/agent/src/assistant_configuration.rs +++ b/crates/agent/src/agent_configuration.rs @@ -30,7 +30,7 @@ pub(crate) use manage_profiles_modal::ManageProfilesModal; use crate::AddContextServer; -pub struct AssistantConfiguration { +pub struct AgentConfiguration { fs: Arc, focus_handle: FocusHandle, configuration_views_by_provider: HashMap, @@ -42,7 +42,7 @@ pub struct AssistantConfiguration { scrollbar_state: ScrollbarState, } -impl AssistantConfiguration { +impl AgentConfiguration { pub fn new( fs: Arc, context_server_store: Entity, @@ -110,7 +110,7 @@ impl AssistantConfiguration { } } -impl Focusable for AssistantConfiguration { +impl Focusable for AgentConfiguration { fn focus_handle(&self, _: &App) -> FocusHandle { self.focus_handle.clone() } @@ -120,9 +120,9 @@ pub enum AssistantConfigurationEvent { NewThread(Arc), } -impl EventEmitter for AssistantConfiguration {} +impl EventEmitter for AgentConfiguration {} -impl AssistantConfiguration { +impl AgentConfiguration { fn render_provider_configuration_block( &mut self, provider: &Arc, @@ -571,7 +571,7 @@ impl AssistantConfiguration { } } -impl Render for AssistantConfiguration { +impl Render for AgentConfiguration { fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { v_flex() .id("assistant-configuration") diff --git a/crates/agent/src/assistant_configuration/add_context_server_modal.rs b/crates/agent/src/agent_configuration/add_context_server_modal.rs similarity index 100% rename from crates/agent/src/assistant_configuration/add_context_server_modal.rs rename to crates/agent/src/agent_configuration/add_context_server_modal.rs diff --git a/crates/agent/src/assistant_configuration/configure_context_server_modal.rs b/crates/agent/src/agent_configuration/configure_context_server_modal.rs similarity index 100% rename from crates/agent/src/assistant_configuration/configure_context_server_modal.rs rename to crates/agent/src/agent_configuration/configure_context_server_modal.rs diff --git a/crates/agent/src/assistant_configuration/manage_profiles_modal.rs b/crates/agent/src/agent_configuration/manage_profiles_modal.rs similarity index 99% rename from crates/agent/src/assistant_configuration/manage_profiles_modal.rs rename to crates/agent/src/agent_configuration/manage_profiles_modal.rs index 6e4bafc154..5e883fa02b 100644 --- a/crates/agent/src/assistant_configuration/manage_profiles_modal.rs +++ b/crates/agent/src/agent_configuration/manage_profiles_modal.rs @@ -18,9 +18,9 @@ use ui::{ use util::ResultExt as _; use workspace::{ModalView, Workspace}; -use crate::assistant_configuration::manage_profiles_modal::profile_modal_header::ProfileModalHeader; -use crate::assistant_configuration::tool_picker::{ToolPicker, ToolPickerDelegate}; -use crate::{AssistantPanel, ManageProfiles, ThreadStore}; +use crate::agent_configuration::manage_profiles_modal::profile_modal_header::ProfileModalHeader; +use crate::agent_configuration::tool_picker::{ToolPicker, ToolPickerDelegate}; +use crate::{AgentPanel, ManageProfiles, ThreadStore}; use super::tool_picker::ToolPickerMode; @@ -115,7 +115,7 @@ impl ManageProfilesModal { _cx: &mut Context, ) { workspace.register_action(|workspace, action: &ManageProfiles, window, cx| { - if let Some(panel) = workspace.panel::(cx) { + if let Some(panel) = workspace.panel::(cx) { let fs = workspace.app_state().fs.clone(); let thread_store = panel.read(cx).thread_store(); let tools = thread_store.read(cx).tools(); diff --git a/crates/agent/src/assistant_configuration/manage_profiles_modal/profile_modal_header.rs b/crates/agent/src/agent_configuration/manage_profiles_modal/profile_modal_header.rs similarity index 100% rename from crates/agent/src/assistant_configuration/manage_profiles_modal/profile_modal_header.rs rename to crates/agent/src/agent_configuration/manage_profiles_modal/profile_modal_header.rs diff --git a/crates/agent/src/assistant_configuration/tool_picker.rs b/crates/agent/src/agent_configuration/tool_picker.rs similarity index 100% rename from crates/agent/src/assistant_configuration/tool_picker.rs rename to crates/agent/src/agent_configuration/tool_picker.rs diff --git a/crates/agent/src/assistant_model_selector.rs b/crates/agent/src/agent_model_selector.rs similarity index 97% rename from crates/agent/src/assistant_model_selector.rs rename to crates/agent/src/agent_model_selector.rs index 67c701bb0d..148c5a2a81 100644 --- a/crates/agent/src/assistant_model_selector.rs +++ b/crates/agent/src/agent_model_selector.rs @@ -17,13 +17,13 @@ pub enum ModelType { InlineAssistant, } -pub struct AssistantModelSelector { +pub struct AgentModelSelector { selector: Entity, menu_handle: PopoverMenuHandle, focus_handle: FocusHandle, } -impl AssistantModelSelector { +impl AgentModelSelector { pub(crate) fn new( fs: Arc, menu_handle: PopoverMenuHandle, @@ -99,7 +99,7 @@ impl AssistantModelSelector { } } -impl Render for AssistantModelSelector { +impl Render for AgentModelSelector { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { let focus_handle = self.focus_handle.clone(); diff --git a/crates/agent/src/assistant_panel.rs b/crates/agent/src/agent_panel.rs similarity index 97% rename from crates/agent/src/assistant_panel.rs rename to crates/agent/src/agent_panel.rs index 6ce121dea7..ee2c42c7e9 100644 --- a/crates/agent/src/assistant_panel.rs +++ b/crates/agent/src/agent_panel.rs @@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize}; use anyhow::{Result, anyhow}; use assistant_context_editor::{ - AssistantContext, AssistantPanelDelegate, ConfigurationError, ContextEditor, ContextEvent, + AgentPanelDelegate, AssistantContext, ConfigurationError, ContextEditor, ContextEvent, SlashCommandCompletionProvider, humanize_token_count, make_lsp_adapter_delegate, render_remaining_tokens, }; @@ -53,8 +53,8 @@ use zed_actions::{DecreaseBufferFontSize, IncreaseBufferFontSize, ResetBufferFon use zed_llm_client::UsageLimit; use crate::active_thread::{self, ActiveThread, ActiveThreadEvent}; +use crate::agent_configuration::{AgentConfiguration, AssistantConfigurationEvent}; use crate::agent_diff::AgentDiff; -use crate::assistant_configuration::{AssistantConfiguration, AssistantConfigurationEvent}; use crate::history_store::{HistoryEntry, HistoryStore, RecentEntry}; use crate::message_editor::{MessageEditor, MessageEditorEvent}; use crate::thread::{Thread, ThreadError, ThreadId, TokenUsageRatio}; @@ -71,7 +71,7 @@ use crate::{ const AGENT_PANEL_KEY: &str = "agent_panel"; #[derive(Serialize, Deserialize)] -struct SerializedAssistantPanel { +struct SerializedAgentPanel { width: Option, } @@ -80,40 +80,40 @@ pub fn init(cx: &mut App) { |workspace: &mut Workspace, _window, _cx: &mut Context| { workspace .register_action(|workspace, action: &NewThread, window, cx| { - if let Some(panel) = workspace.panel::(cx) { + if let Some(panel) = workspace.panel::(cx) { panel.update(cx, |panel, cx| panel.new_thread(action, window, cx)); - workspace.focus_panel::(window, cx); + workspace.focus_panel::(window, cx); } }) .register_action(|workspace, _: &OpenHistory, window, cx| { - if let Some(panel) = workspace.panel::(cx) { - workspace.focus_panel::(window, cx); + if let Some(panel) = workspace.panel::(cx) { + workspace.focus_panel::(window, cx); panel.update(cx, |panel, cx| panel.open_history(window, cx)); } }) .register_action(|workspace, _: &OpenConfiguration, window, cx| { - if let Some(panel) = workspace.panel::(cx) { - workspace.focus_panel::(window, cx); + if let Some(panel) = workspace.panel::(cx) { + workspace.focus_panel::(window, cx); panel.update(cx, |panel, cx| panel.open_configuration(window, cx)); } }) .register_action(|workspace, _: &NewTextThread, window, cx| { - if let Some(panel) = workspace.panel::(cx) { - workspace.focus_panel::(window, cx); + if let Some(panel) = workspace.panel::(cx) { + workspace.focus_panel::(window, cx); panel.update(cx, |panel, cx| panel.new_prompt_editor(window, cx)); } }) .register_action(|workspace, action: &OpenRulesLibrary, window, cx| { - if let Some(panel) = workspace.panel::(cx) { - workspace.focus_panel::(window, cx); + if let Some(panel) = workspace.panel::(cx) { + workspace.focus_panel::(window, cx); panel.update(cx, |panel, cx| { panel.deploy_rules_library(action, window, cx) }); } }) .register_action(|workspace, _: &OpenAgentDiff, window, cx| { - if let Some(panel) = workspace.panel::(cx) { - workspace.focus_panel::(window, cx); + if let Some(panel) = workspace.panel::(cx) { + workspace.focus_panel::(window, cx); let thread = panel.read(cx).thread.read(cx).thread().clone(); AgentDiffPane::deploy_in_workspace(thread, workspace, window, cx); } @@ -122,8 +122,8 @@ pub fn init(cx: &mut App) { workspace.follow(CollaboratorId::Agent, window, cx); }) .register_action(|workspace, _: &ExpandMessageEditor, window, cx| { - if let Some(panel) = workspace.panel::(cx) { - workspace.focus_panel::(window, cx); + if let Some(panel) = workspace.panel::(cx) { + workspace.focus_panel::(window, cx); panel.update(cx, |panel, cx| { panel.message_editor.update(cx, |editor, cx| { editor.expand_message_editor(&ExpandMessageEditor, window, cx); @@ -132,16 +132,16 @@ pub fn init(cx: &mut App) { } }) .register_action(|workspace, _: &ToggleNavigationMenu, window, cx| { - if let Some(panel) = workspace.panel::(cx) { - workspace.focus_panel::(window, cx); + if let Some(panel) = workspace.panel::(cx) { + workspace.focus_panel::(window, cx); panel.update(cx, |panel, cx| { panel.toggle_navigation_menu(&ToggleNavigationMenu, window, cx); }); } }) .register_action(|workspace, _: &ToggleOptionsMenu, window, cx| { - if let Some(panel) = workspace.panel::(cx) { - workspace.focus_panel::(window, cx); + if let Some(panel) = workspace.panel::(cx) { + workspace.focus_panel::(window, cx); panel.update(cx, |panel, cx| { panel.toggle_options_menu(&ToggleOptionsMenu, window, cx); }); @@ -335,7 +335,7 @@ impl ActiveView { } } -pub struct AssistantPanel { +pub struct AgentPanel { workspace: WeakEntity, user_store: Entity, project: Entity, @@ -349,7 +349,7 @@ pub struct AssistantPanel { context_store: Entity, prompt_store: Option>, inline_assist_context_store: Entity, - configuration: Option>, + configuration: Option>, configuration_subscription: Option, local_timezone: UtcOffset, active_view: ActiveView, @@ -366,14 +366,14 @@ pub struct AssistantPanel { _trial_markdown: Entity, } -impl AssistantPanel { +impl AgentPanel { fn serialize(&mut self, cx: &mut Context) { let width = self.width; self.pending_serialization = Some(cx.background_spawn(async move { KEY_VALUE_STORE .write_kvp( AGENT_PANEL_KEY.into(), - serde_json::to_string(&SerializedAssistantPanel { width })?, + serde_json::to_string(&SerializedAgentPanel { width })?, ) .await?; anyhow::Ok(()) @@ -423,7 +423,7 @@ impl AssistantPanel { .log_err() .flatten() { - Some(serde_json::from_str::(&panel)?) + Some(serde_json::from_str::(&panel)?) } else { None }; @@ -1163,15 +1163,13 @@ impl AssistantPanel { self.set_active_view(ActiveView::Configuration, window, cx); self.configuration = - Some(cx.new(|cx| { - AssistantConfiguration::new(fs, context_server_store, tools, window, cx) - })); + Some(cx.new(|cx| AgentConfiguration::new(fs, context_server_store, tools, window, cx))); if let Some(configuration) = self.configuration.as_ref() { self.configuration_subscription = Some(cx.subscribe_in( configuration, window, - Self::handle_assistant_configuration_event, + Self::handle_agent_configuration_event, )); configuration.focus_handle(cx).focus(window); @@ -1201,9 +1199,9 @@ impl AssistantPanel { .detach_and_log_err(cx); } - fn handle_assistant_configuration_event( + fn handle_agent_configuration_event( &mut self, - _entity: &Entity, + _entity: &Entity, event: &AssistantConfigurationEvent, window: &mut Window, cx: &mut Context, @@ -1316,7 +1314,7 @@ impl AssistantPanel { } } -impl Focusable for AssistantPanel { +impl Focusable for AgentPanel { fn focus_handle(&self, cx: &App) -> FocusHandle { match &self.active_view { ActiveView::Thread { .. } => self.message_editor.focus_handle(cx), @@ -1341,9 +1339,9 @@ fn agent_panel_dock_position(cx: &App) -> DockPosition { } } -impl EventEmitter for AssistantPanel {} +impl EventEmitter for AgentPanel {} -impl Panel for AssistantPanel { +impl Panel for AgentPanel { fn persistent_name() -> &'static str { "AgentPanel" } @@ -1418,7 +1416,7 @@ impl Panel for AssistantPanel { } } -impl AssistantPanel { +impl AgentPanel { fn render_title_view(&self, _window: &mut Window, cx: &Context) -> AnyElement { const LOADING_SUMMARY_PLACEHOLDER: &str = "Loading Summary…"; @@ -1977,9 +1975,9 @@ impl AssistantPanel { .style(ButtonStyle::Transparent) .color(Color::Muted) .on_click({ - let assistant_panel = cx.entity(); + let agent_panel = cx.entity(); move |_, _, cx| { - assistant_panel.update( + agent_panel.update( cx, |this, cx| { let hidden = @@ -2744,7 +2742,7 @@ impl AssistantPanel { } } -impl Render for AssistantPanel { +impl Render for AgentPanel { fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { let content = match &self.active_view { ActiveView::Thread { .. } => v_flex() @@ -2855,28 +2853,26 @@ impl rules_library::InlineAssistDelegate for PromptLibraryInlineAssist { }) } - fn focus_assistant_panel( + fn focus_agent_panel( &self, workspace: &mut Workspace, window: &mut Window, cx: &mut Context, ) -> bool { - workspace - .focus_panel::(window, cx) - .is_some() + workspace.focus_panel::(window, cx).is_some() } } pub struct ConcreteAssistantPanelDelegate; -impl AssistantPanelDelegate for ConcreteAssistantPanelDelegate { +impl AgentPanelDelegate for ConcreteAssistantPanelDelegate { fn active_context_editor( &self, workspace: &mut Workspace, _window: &mut Window, cx: &mut Context, ) -> Option> { - let panel = workspace.panel::(cx)?; + let panel = workspace.panel::(cx)?; panel.read(cx).active_context_editor() } @@ -2887,7 +2883,7 @@ impl AssistantPanelDelegate for ConcreteAssistantPanelDelegate { window: &mut Window, cx: &mut Context, ) -> Task> { - let Some(panel) = workspace.panel::(cx) else { + let Some(panel) = workspace.panel::(cx) else { return Task::ready(Err(anyhow!("Agent panel not found"))); }; @@ -2914,12 +2910,12 @@ impl AssistantPanelDelegate for ConcreteAssistantPanelDelegate { window: &mut Window, cx: &mut Context, ) { - let Some(panel) = workspace.panel::(cx) else { + let Some(panel) = workspace.panel::(cx) else { return; }; if !panel.focus_handle(cx).contains_focused(window, cx) { - workspace.toggle_panel_focus::(window, cx); + workspace.toggle_panel_focus::(window, cx); } panel.update(cx, |_, cx| { diff --git a/crates/agent/src/context_picker.rs b/crates/agent/src/context_picker.rs index a9cf7889ca..6d82ea60d8 100644 --- a/crates/agent/src/context_picker.rs +++ b/crates/agent/src/context_picker.rs @@ -36,7 +36,7 @@ use ui::{ use uuid::Uuid; use workspace::{Workspace, notifications::NotifyResultExt}; -use crate::AssistantPanel; +use crate::AgentPanel; use crate::context::RULES_ICON; use crate::context_store::ContextStore; use crate::thread::ThreadId; @@ -648,7 +648,7 @@ fn recent_context_picker_entries( let current_threads = context_store.read(cx).thread_ids(); let active_thread_id = workspace - .panel::(cx) + .panel::(cx) .and_then(|panel| Some(panel.read(cx).active_thread()?.read(cx).id())); if let Some((thread_store, text_thread_store)) = thread_store diff --git a/crates/agent/src/context_server_configuration.rs b/crates/agent/src/context_server_configuration.rs index 0daa04f463..363d2ef047 100644 --- a/crates/agent/src/context_server_configuration.rs +++ b/crates/agent/src/context_server_configuration.rs @@ -10,7 +10,7 @@ use ui::prelude::*; use util::ResultExt; use workspace::Workspace; -use crate::assistant_configuration::ConfigureContextServerModal; +use crate::agent_configuration::ConfigureContextServerModal; pub(crate) fn init(language_registry: Arc, cx: &mut App) { cx.observe_new(move |_: &mut Workspace, window, cx| { diff --git a/crates/agent/src/context_strip.rs b/crates/agent/src/context_strip.rs index a0c22de66b..54a967b9b6 100644 --- a/crates/agent/src/context_strip.rs +++ b/crates/agent/src/context_strip.rs @@ -22,7 +22,7 @@ use crate::thread::Thread; use crate::thread_store::{TextThreadStore, ThreadStore}; use crate::ui::{AddedContext, ContextPill}; use crate::{ - AcceptSuggestedContext, AssistantPanel, FocusDown, FocusLeft, FocusRight, FocusUp, + AcceptSuggestedContext, AgentPanel, FocusDown, FocusLeft, FocusRight, FocusUp, RemoveAllContext, RemoveFocusedContext, ToggleContextPicker, }; @@ -144,7 +144,7 @@ impl ContextStrip { } let workspace = self.workspace.upgrade()?; - let panel = workspace.read(cx).panel::(cx)?.read(cx); + let panel = workspace.read(cx).panel::(cx)?.read(cx); if let Some(active_thread) = panel.active_thread() { let weak_active_thread = active_thread.downgrade(); diff --git a/crates/agent/src/inline_assistant.rs b/crates/agent/src/inline_assistant.rs index 8679f76177..075d5a588c 100644 --- a/crates/agent/src/inline_assistant.rs +++ b/crates/agent/src/inline_assistant.rs @@ -43,7 +43,7 @@ use util::ResultExt; use workspace::{ItemHandle, Toast, Workspace, dock::Panel, notifications::NotificationId}; use zed_actions::agent::OpenConfiguration; -use crate::AssistantPanel; +use crate::AgentPanel; use crate::buffer_codegen::{BufferCodegen, CodegenAlternative, CodegenEvent}; use crate::context_store::ContextStore; use crate::inline_prompt_editor::{CodegenStatus, InlineAssistId, PromptEditor, PromptEditorEvent}; @@ -182,13 +182,12 @@ impl InlineAssistant { if let Some(editor) = item.act_as::(cx) { editor.update(cx, |editor, cx| { if is_assistant2_enabled { - let panel = workspace.read(cx).panel::(cx); + let panel = workspace.read(cx).panel::(cx); let thread_store = panel .as_ref() - .map(|assistant_panel| assistant_panel.read(cx).thread_store().downgrade()); - let text_thread_store = panel.map(|assistant_panel| { - assistant_panel.read(cx).text_thread_store().downgrade() - }); + .map(|agent_panel| agent_panel.read(cx).thread_store().downgrade()); + let text_thread_store = panel + .map(|agent_panel| agent_panel.read(cx).text_thread_store().downgrade()); editor.add_code_action_provider( Rc::new(AssistantCodeActionProvider { @@ -227,7 +226,7 @@ impl InlineAssistant { let Some(inline_assist_target) = Self::resolve_inline_assist_target( workspace, - workspace.panel::(cx), + workspace.panel::(cx), window, cx, ) else { @@ -240,15 +239,15 @@ impl InlineAssistant { .map_or(false, |model| model.provider.is_authenticated(cx)) }; - let Some(assistant_panel) = workspace.panel::(cx) else { + let Some(agent_panel) = workspace.panel::(cx) else { return; }; - let assistant_panel = assistant_panel.read(cx); + let agent_panel = agent_panel.read(cx); - let prompt_store = assistant_panel.prompt_store().as_ref().cloned(); - let thread_store = Some(assistant_panel.thread_store().downgrade()); - let text_thread_store = Some(assistant_panel.text_thread_store().downgrade()); - let context_store = assistant_panel.inline_assist_context_store().clone(); + let prompt_store = agent_panel.prompt_store().as_ref().cloned(); + let thread_store = Some(agent_panel.thread_store().downgrade()); + let text_thread_store = Some(agent_panel.text_thread_store().downgrade()); + let context_store = agent_panel.inline_assist_context_store().clone(); let handle_assist = |window: &mut Window, cx: &mut Context| match inline_assist_target { @@ -1454,7 +1453,7 @@ impl InlineAssistant { fn resolve_inline_assist_target( workspace: &mut Workspace, - assistant_panel: Option>, + agent_panel: Option>, window: &mut Window, cx: &mut App, ) -> Option { @@ -1474,7 +1473,7 @@ impl InlineAssistant { } } - let context_editor = assistant_panel + let context_editor = agent_panel .and_then(|panel| panel.read(cx).active_context_editor()) .and_then(|editor| { let editor = &editor.read(cx).editor().clone(); diff --git a/crates/agent/src/inline_prompt_editor.rs b/crates/agent/src/inline_prompt_editor.rs index b5e4233ed3..9ccc265509 100644 --- a/crates/agent/src/inline_prompt_editor.rs +++ b/crates/agent/src/inline_prompt_editor.rs @@ -1,4 +1,4 @@ -use crate::assistant_model_selector::{AssistantModelSelector, ModelType}; +use crate::agent_model_selector::{AgentModelSelector, ModelType}; use crate::buffer_codegen::BufferCodegen; use crate::context::ContextCreasesAddon; use crate::context_picker::{ContextPicker, ContextPickerCompletionProvider}; @@ -42,7 +42,7 @@ pub struct PromptEditor { context_store: Entity, context_strip: Entity, context_picker_menu_handle: PopoverMenuHandle, - model_selector: Entity, + model_selector: Entity, edited_since_done: bool, prompt_history: VecDeque, prompt_history_ix: Option, @@ -290,12 +290,12 @@ impl PromptEditor { PromptEditorMode::Terminal { .. } => "Generate", }; - let assistant_panel_keybinding = + let agent_panel_keybinding = ui::text_for_action(&zed_actions::assistant::ToggleFocus, window, cx) .map(|keybinding| format!("{keybinding} to chat ― ")) .unwrap_or_default(); - format!("{action}… ({assistant_panel_keybinding}↓↑ for history)") + format!("{action}… ({agent_panel_keybinding}↓↑ for history)") } pub fn prompt(&self, cx: &App) -> String { @@ -927,7 +927,7 @@ impl PromptEditor { context_strip, context_picker_menu_handle, model_selector: cx.new(|cx| { - AssistantModelSelector::new( + AgentModelSelector::new( fs, model_selector_menu_handle, prompt_editor.focus_handle(cx), @@ -1098,7 +1098,7 @@ impl PromptEditor { context_strip, context_picker_menu_handle, model_selector: cx.new(|cx| { - AssistantModelSelector::new( + AgentModelSelector::new( fs, model_selector_menu_handle.clone(), prompt_editor.focus_handle(cx), diff --git a/crates/agent/src/message_editor.rs b/crates/agent/src/message_editor.rs index f15ca504ba..ccfa42a63d 100644 --- a/crates/agent/src/message_editor.rs +++ b/crates/agent/src/message_editor.rs @@ -1,7 +1,7 @@ use std::collections::BTreeMap; use std::sync::Arc; -use crate::assistant_model_selector::{AssistantModelSelector, ModelType}; +use crate::agent_model_selector::{AgentModelSelector, ModelType}; use crate::context::{AgentContextKey, ContextCreasesAddon, ContextLoadResult, load_context}; use crate::tool_compatibility::{IncompatibleToolsState, IncompatibleToolsTooltip}; use crate::ui::{ @@ -65,7 +65,7 @@ pub struct MessageEditor { prompt_store: Option>, context_strip: Entity, context_picker_menu_handle: PopoverMenuHandle, - model_selector: Entity, + model_selector: Entity, last_loaded_context: Option, load_context_task: Option>>, profile_selector: Entity, @@ -189,7 +189,7 @@ impl MessageEditor { ]; let model_selector = cx.new(|cx| { - AssistantModelSelector::new( + AgentModelSelector::new( fs.clone(), model_selector_menu_handle, editor.focus_handle(cx), diff --git a/crates/agent/src/thread_history.rs b/crates/agent/src/thread_history.rs index 87b67a60a5..2fab40ebbd 100644 --- a/crates/agent/src/thread_history.rs +++ b/crates/agent/src/thread_history.rs @@ -19,10 +19,10 @@ use util::ResultExt; use crate::history_store::{HistoryEntry, HistoryStore}; use crate::thread_store::SerializedThreadMetadata; -use crate::{AssistantPanel, RemoveSelectedThread}; +use crate::{AgentPanel, RemoveSelectedThread}; pub struct ThreadHistory { - assistant_panel: WeakEntity, + agent_panel: WeakEntity, history_store: Entity, scroll_handle: UniformListScrollHandle, selected_index: usize, @@ -69,7 +69,7 @@ impl HistoryListItem { impl ThreadHistory { pub(crate) fn new( - assistant_panel: WeakEntity, + agent_panel: WeakEntity, history_store: Entity, window: &mut Window, cx: &mut Context, @@ -96,7 +96,7 @@ impl ThreadHistory { let scrollbar_state = ScrollbarState::new(scroll_handle.clone()); let mut this = Self { - assistant_panel, + agent_panel, history_store, scroll_handle, selected_index: 0, @@ -380,14 +380,12 @@ impl ThreadHistory { fn confirm(&mut self, _: &menu::Confirm, window: &mut Window, cx: &mut Context) { if let Some(entry) = self.get_match(self.selected_index) { let task_result = match entry { - HistoryEntry::Thread(thread) => self.assistant_panel.update(cx, move |this, cx| { + HistoryEntry::Thread(thread) => self.agent_panel.update(cx, move |this, cx| { this.open_thread_by_id(&thread.id, window, cx) }), - HistoryEntry::Context(context) => { - self.assistant_panel.update(cx, move |this, cx| { - this.open_saved_prompt_editor(context.path.clone(), window, cx) - }) - } + HistoryEntry::Context(context) => self.agent_panel.update(cx, move |this, cx| { + this.open_saved_prompt_editor(context.path.clone(), window, cx) + }), }; if let Some(task) = task_result.log_err() { @@ -407,10 +405,10 @@ impl ThreadHistory { if let Some(entry) = self.get_match(self.selected_index) { let task_result = match entry { HistoryEntry::Thread(thread) => self - .assistant_panel + .agent_panel .update(cx, |this, cx| this.delete_thread(&thread.id, cx)), HistoryEntry::Context(context) => self - .assistant_panel + .agent_panel .update(cx, |this, cx| this.delete_context(context.path.clone(), cx)), }; @@ -506,7 +504,7 @@ impl ThreadHistory { match entry { HistoryEntry::Thread(thread) => PastThread::new( thread.clone(), - self.assistant_panel.clone(), + self.agent_panel.clone(), is_active, highlight_positions, format, @@ -514,7 +512,7 @@ impl ThreadHistory { .into_any_element(), HistoryEntry::Context(context) => PastContext::new( context.clone(), - self.assistant_panel.clone(), + self.agent_panel.clone(), is_active, highlight_positions, format, @@ -605,7 +603,7 @@ impl Render for ThreadHistory { #[derive(IntoElement)] pub struct PastThread { thread: SerializedThreadMetadata, - assistant_panel: WeakEntity, + agent_panel: WeakEntity, selected: bool, highlight_positions: Vec, timestamp_format: EntryTimeFormat, @@ -614,14 +612,14 @@ pub struct PastThread { impl PastThread { pub fn new( thread: SerializedThreadMetadata, - assistant_panel: WeakEntity, + agent_panel: WeakEntity, selected: bool, highlight_positions: Vec, timestamp_format: EntryTimeFormat, ) -> Self { Self { thread, - assistant_panel, + agent_panel, selected, highlight_positions, timestamp_format, @@ -634,7 +632,7 @@ impl RenderOnce for PastThread { let summary = self.thread.summary; let thread_timestamp = self.timestamp_format.format_timestamp( - &self.assistant_panel, + &self.agent_panel, self.thread.updated_at.timestamp(), cx, ); @@ -667,10 +665,10 @@ impl RenderOnce for PastThread { Tooltip::for_action("Delete", &RemoveSelectedThread, window, cx) }) .on_click({ - let assistant_panel = self.assistant_panel.clone(); + let agent_panel = self.agent_panel.clone(); let id = self.thread.id.clone(); move |_event, _window, cx| { - assistant_panel + agent_panel .update(cx, |this, cx| { this.delete_thread(&id, cx).detach_and_log_err(cx); }) @@ -680,10 +678,10 @@ impl RenderOnce for PastThread { ), ) .on_click({ - let assistant_panel = self.assistant_panel.clone(); + let agent_panel = self.agent_panel.clone(); let id = self.thread.id.clone(); move |_event, window, cx| { - assistant_panel + agent_panel .update(cx, |this, cx| { this.open_thread_by_id(&id, window, cx) .detach_and_log_err(cx); @@ -697,7 +695,7 @@ impl RenderOnce for PastThread { #[derive(IntoElement)] pub struct PastContext { context: SavedContextMetadata, - assistant_panel: WeakEntity, + agent_panel: WeakEntity, selected: bool, highlight_positions: Vec, timestamp_format: EntryTimeFormat, @@ -706,14 +704,14 @@ pub struct PastContext { impl PastContext { pub fn new( context: SavedContextMetadata, - assistant_panel: WeakEntity, + agent_panel: WeakEntity, selected: bool, highlight_positions: Vec, timestamp_format: EntryTimeFormat, ) -> Self { Self { context, - assistant_panel, + agent_panel, selected, highlight_positions, timestamp_format, @@ -725,7 +723,7 @@ impl RenderOnce for PastContext { fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement { let summary = self.context.title; let context_timestamp = self.timestamp_format.format_timestamp( - &self.assistant_panel, + &self.agent_panel, self.context.mtime.timestamp(), cx, ); @@ -760,10 +758,10 @@ impl RenderOnce for PastContext { Tooltip::for_action("Delete", &RemoveSelectedThread, window, cx) }) .on_click({ - let assistant_panel = self.assistant_panel.clone(); + let agent_panel = self.agent_panel.clone(); let path = self.context.path.clone(); move |_event, _window, cx| { - assistant_panel + agent_panel .update(cx, |this, cx| { this.delete_context(path.clone(), cx) .detach_and_log_err(cx); @@ -774,10 +772,10 @@ impl RenderOnce for PastContext { ), ) .on_click({ - let assistant_panel = self.assistant_panel.clone(); + let agent_panel = self.agent_panel.clone(); let path = self.context.path.clone(); move |_event, window, cx| { - assistant_panel + agent_panel .update(cx, |this, cx| { this.open_saved_prompt_editor(path.clone(), window, cx) .detach_and_log_err(cx); @@ -797,12 +795,12 @@ pub enum EntryTimeFormat { impl EntryTimeFormat { fn format_timestamp( &self, - assistant_panel: &WeakEntity, + agent_panel: &WeakEntity, timestamp: i64, cx: &App, ) -> String { let timestamp = OffsetDateTime::from_unix_timestamp(timestamp).unwrap(); - let timezone = assistant_panel + let timezone = agent_panel .read_with(cx, |this, _cx| this.local_timezone()) .unwrap_or(UtcOffset::UTC); diff --git a/crates/agent/src/ui/onboarding_modal.rs b/crates/agent/src/ui/onboarding_modal.rs index 8665059a3d..9e04171ec9 100644 --- a/crates/agent/src/ui/onboarding_modal.rs +++ b/crates/agent/src/ui/onboarding_modal.rs @@ -4,7 +4,7 @@ use gpui::{ use ui::{TintColor, Vector, VectorName, prelude::*}; use workspace::{ModalView, Workspace}; -use crate::assistant_panel::AssistantPanel; +use crate::agent_panel::AgentPanel; macro_rules! agent_onboarding_event { ($name:expr) => { @@ -31,7 +31,7 @@ impl AgentOnboardingModal { fn open_panel(&mut self, _: &ClickEvent, window: &mut Window, cx: &mut Context) { self.workspace.update(cx, |workspace, cx| { - workspace.focus_panel::(window, cx); + workspace.focus_panel::(window, cx); }); cx.emit(DismissEvent); diff --git a/crates/assistant_context_editor/src/context_editor.rs b/crates/assistant_context_editor/src/context_editor.rs index a25783afca..c78e09464a 100644 --- a/crates/assistant_context_editor/src/context_editor.rs +++ b/crates/assistant_context_editor/src/context_editor.rs @@ -137,7 +137,7 @@ pub enum ThoughtProcessStatus { Completed, } -pub trait AssistantPanelDelegate { +pub trait AgentPanelDelegate { fn active_context_editor( &self, workspace: &mut Workspace, @@ -171,7 +171,7 @@ pub trait AssistantPanelDelegate { ); } -impl dyn AssistantPanelDelegate { +impl dyn AgentPanelDelegate { /// Returns the global [`AssistantPanelDelegate`], if it exists. pub fn try_global(cx: &App) -> Option> { cx.try_global::() @@ -184,7 +184,7 @@ impl dyn AssistantPanelDelegate { } } -struct GlobalAssistantPanelDelegate(Arc); +struct GlobalAssistantPanelDelegate(Arc); impl Global for GlobalAssistantPanelDelegate {} @@ -1666,11 +1666,11 @@ impl ContextEditor { window: &mut Window, cx: &mut Context, ) { - let Some(assistant_panel_delegate) = ::try_global(cx) else { + let Some(agent_panel_delegate) = ::try_global(cx) else { return; }; let Some(context_editor_view) = - assistant_panel_delegate.active_context_editor(workspace, window, cx) + agent_panel_delegate.active_context_editor(workspace, window, cx) else { return; }; @@ -1696,9 +1696,9 @@ impl ContextEditor { cx: &mut Context, ) { let result = maybe!({ - let assistant_panel_delegate = ::try_global(cx)?; + let agent_panel_delegate = ::try_global(cx)?; let context_editor_view = - assistant_panel_delegate.active_context_editor(workspace, window, cx)?; + agent_panel_delegate.active_context_editor(workspace, window, cx)?; Self::get_selection_or_code_block(&context_editor_view, cx) }); let Some((text, is_code_block)) = result else { @@ -1731,11 +1731,11 @@ impl ContextEditor { window: &mut Window, cx: &mut Context, ) { - let Some(assistant_panel_delegate) = ::try_global(cx) else { + let Some(agent_panel_delegate) = ::try_global(cx) else { return; }; let Some(context_editor_view) = - assistant_panel_delegate.active_context_editor(workspace, window, cx) + agent_panel_delegate.active_context_editor(workspace, window, cx) else { return; }; @@ -1821,7 +1821,7 @@ impl ContextEditor { window: &mut Window, cx: &mut Context, ) { - let Some(assistant_panel_delegate) = ::try_global(cx) else { + let Some(agent_panel_delegate) = ::try_global(cx) else { return; }; @@ -1852,7 +1852,7 @@ impl ContextEditor { return; } - assistant_panel_delegate.quote_selection(workspace, selections, buffer, window, cx); + agent_panel_delegate.quote_selection(workspace, selections, buffer, window, cx); } pub fn quote_ranges( @@ -3361,10 +3361,10 @@ impl FollowableItem for ContextEditor { let editor_state = state.editor?; let project = workspace.read(cx).project().clone(); - let assistant_panel_delegate = ::try_global(cx)?; + let agent_panel_delegate = ::try_global(cx)?; let context_editor_task = workspace.update(cx, |workspace, cx| { - assistant_panel_delegate.open_remote_context(workspace, context_id, window, cx) + agent_panel_delegate.open_remote_context(workspace, context_id, window, cx) }); Some(window.spawn(cx, async move |cx| { diff --git a/crates/assistant_context_editor/src/context_history.rs b/crates/assistant_context_editor/src/context_history.rs index 560033be34..2851ba8d3a 100644 --- a/crates/assistant_context_editor/src/context_history.rs +++ b/crates/assistant_context_editor/src/context_history.rs @@ -8,7 +8,7 @@ use ui::{Avatar, ListItem, ListItemSpacing, prelude::*}; use workspace::{Item, Workspace}; use crate::{ - AssistantPanelDelegate, ContextStore, DEFAULT_TAB_TITLE, RemoteContextMetadata, + AgentPanelDelegate, ContextStore, DEFAULT_TAB_TITLE, RemoteContextMetadata, SavedContextMetadata, }; @@ -70,19 +70,19 @@ impl ContextHistory { ) { let SavedContextPickerEvent::Confirmed(context) = event; - let Some(assistant_panel_delegate) = ::try_global(cx) else { + let Some(agent_panel_delegate) = ::try_global(cx) else { return; }; self.workspace .update(cx, |workspace, cx| match context { ContextMetadata::Remote(metadata) => { - assistant_panel_delegate + agent_panel_delegate .open_remote_context(workspace, metadata.id.clone(), window, cx) .detach_and_log_err(cx); } ContextMetadata::Saved(metadata) => { - assistant_panel_delegate + agent_panel_delegate .open_saved_context(workspace, metadata.path.clone(), window, cx) .detach_and_log_err(cx); } diff --git a/crates/rules_library/src/rules_library.rs b/crates/rules_library/src/rules_library.rs index 8f5fb4f953..954d2b23af 100644 --- a/crates/rules_library/src/rules_library.rs +++ b/crates/rules_library/src/rules_library.rs @@ -52,8 +52,8 @@ pub trait InlineAssistDelegate { cx: &mut Context, ); - /// Returns whether the Assistant panel was focused. - fn focus_assistant_panel( + /// Returns whether the Agent panel was focused. + fn focus_agent_panel( &self, workspace: &mut Workspace, window: &mut Window, @@ -814,7 +814,7 @@ impl RulesLibrary { .update(cx, |workspace, window, cx| { window.activate_window(); self.inline_assist_delegate - .focus_assistant_panel(workspace, window, cx) + .focus_agent_panel(workspace, window, cx) }) .ok(); if panel == Some(true) { diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index c75dbeb2c6..410b8ff204 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -12,7 +12,7 @@ use agent::AgentDiffToolbar; use anyhow::Context as _; pub use app_menus::*; use assets::Assets; -use assistant_context_editor::AssistantPanelDelegate; +use assistant_context_editor::AgentPanelDelegate; use breadcrumbs::Breadcrumbs; use client::zed_urls; use collections::VecDeque; @@ -435,7 +435,7 @@ fn initialize_panels( let is_assistant2_enabled = !cfg!(test); let agent_panel = if is_assistant2_enabled { let agent_panel = - agent::AssistantPanel::load(workspace_handle.clone(), prompt_builder, cx.clone()) + agent::AgentPanel::load(workspace_handle.clone(), prompt_builder, cx.clone()) .await?; Some(agent_panel) @@ -453,15 +453,15 @@ fn initialize_panels( // We need to do this here instead of within the individual `init` // functions so that we only register the actions once. // - // Once we ship `assistant2` we can push this back down into `agent::assistant_panel::init`. + // Once we ship `assistant2` we can push this back down into `agent::agent_panel::init`. if is_assistant2_enabled { - ::set_global( + ::set_global( Arc::new(agent::ConcreteAssistantPanelDelegate), cx, ); workspace - .register_action(agent::AssistantPanel::toggle_focus) + .register_action(agent::AgentPanel::toggle_focus) .register_action(agent::InlineAssistant::inline_assist); } })?;