Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

agent_ui: Remove unused rule APIs (#58080)

Bennet Bo Fenner18051ab3999e
diff --git a/Cargo.lock b/Cargo.lock
index 677ed3796ed..58d81f58bd0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -109,7 +109,6 @@ dependencies = [
"parking_lot",
"portable-pty",
"project",
- "prompt_store",
"rand 0.9.4",
"sandbox",
"serde",
@@ -14483,7 +14482,6 @@ dependencies = [
"db",
"fs",
"futures 0.3.32",
- "fuzzy",
"gpui",
"handlebars 4.5.0",
"heed",
@@ -14491,7 +14489,6 @@ dependencies = [
"log",
"parking_lot",
"paths",
- "rope",
"serde",
"serde_json",
"strum 0.27.2",
diff --git a/crates/acp_thread/Cargo.toml b/crates/acp_thread/Cargo.toml
index d115b29b1f6..c22259f94b1 100644
--- a/crates/acp_thread/Cargo.toml
+++ b/crates/acp_thread/Cargo.toml
@@ -38,7 +38,6 @@ parking_lot = { workspace = true, optional = true }
image.workspace = true
portable-pty.workspace = true
project.workspace = true
-prompt_store.workspace = true
sandbox.workspace = true
serde.workspace = true
serde_json.workspace = true
diff --git a/crates/acp_thread/src/mention.rs b/crates/acp_thread/src/mention.rs
index cb96de34813..f2423858523 100644
--- a/crates/acp_thread/src/mention.rs
+++ b/crates/acp_thread/src/mention.rs
@@ -1,7 +1,6 @@
use agent_client_protocol::schema as acp;
use anyhow::{Context as _, Result, bail};
use file_icons::FileIcons;
-use prompt_store::{PromptId, UserPromptId};
use serde::{Deserialize, Serialize};
use std::{
borrow::Cow,
@@ -37,10 +36,6 @@ pub enum MentionUri {
id: acp::SessionId,
name: String,
},
- Rule {
- id: PromptId,
- name: String,
- },
Diagnostics {
#[serde(default = "default_include_errors")]
include_errors: bool,
@@ -205,13 +200,6 @@ impl MentionUri {
id: acp::SessionId::new(thread_id),
name,
})
- } else if let Some(rule_id) = path.strip_prefix("/agent/rule/") {
- let name = single_query_param(&url, "name")?.context("Missing rule name")?;
- let rule_id = UserPromptId(rule_id.parse()?);
- Ok(Self::Rule {
- id: rule_id.into(),
- name,
- })
} else if path == "/agent/diagnostics" {
let mut include_errors = default_include_errors();
let mut include_warnings = false;
@@ -342,7 +330,6 @@ impl MentionUri {
MentionUri::PastedImage { name } => name.clone(),
MentionUri::Symbol { name, .. } => name.clone(),
MentionUri::Thread { name, .. } => name.clone(),
- MentionUri::Rule { name, .. } => name.clone(),
MentionUri::Diagnostics { .. } => "Diagnostics".to_string(),
MentionUri::TerminalSelection { line_count } => {
if *line_count == 1 {
@@ -443,7 +430,6 @@ impl MentionUri {
.unwrap_or_else(|| IconName::Folder.path().into()),
MentionUri::Symbol { .. } => IconName::Code.path().into(),
MentionUri::Thread { .. } => IconName::Thread.path().into(),
- MentionUri::Rule { .. } => IconName::Reader.path().into(),
MentionUri::Diagnostics { .. } => IconName::Warning.path().into(),
MentionUri::TerminalSelection { .. } => IconName::Terminal.path().into(),
MentionUri::Selection { .. } => IconName::Reader.path().into(),
@@ -526,12 +512,6 @@ impl MentionUri {
url.query_pairs_mut().append_pair("name", name);
url
}
- MentionUri::Rule { name, id } => {
- let mut url = Url::parse("zed:///").unwrap();
- url.set_path(&format!("/agent/rule/{id}"));
- url.query_pairs_mut().append_pair("name", name);
- url
- }
MentionUri::Diagnostics {
include_errors,
include_warnings,
@@ -811,20 +791,6 @@ mod tests {
assert_eq!(parsed.to_uri().to_string(), thread_uri);
}
- #[test]
- fn test_parse_rule_uri() {
- let rule_uri = "zed:///agent/rule/d8694ff2-90d5-4b6f-be33-33c1763acd52?name=Some+rule";
- let parsed = MentionUri::parse(rule_uri, PathStyle::local()).unwrap();
- match &parsed {
- MentionUri::Rule { id, name } => {
- assert_eq!(id.to_string(), "d8694ff2-90d5-4b6f-be33-33c1763acd52");
- assert_eq!(name, "Some rule");
- }
- _ => panic!("Expected Rule variant"),
- }
- assert_eq!(parsed.to_uri().to_string(), rule_uri);
- }
-
#[test]
fn test_parse_skill_uri_round_trip() {
let skill_uri = MentionUri::Skill {
diff --git a/crates/agent/src/thread.rs b/crates/agent/src/thread.rs
index 5eb2c170a12..4a5efc2e1cc 100644
--- a/crates/agent/src/thread.rs
+++ b/crates/agent/src/thread.rs
@@ -316,17 +316,6 @@ impl UserMessage {
MentionUri::Thread { .. } => {
write!(&mut thread_context, "\n{}\n", content).ok();
}
- MentionUri::Rule { .. } => {
- write!(
- &mut rules_context,
- "\n{}",
- MarkdownCodeBlock {
- tag: "",
- text: content
- }
- )
- .ok();
- }
MentionUri::Fetch { url } => {
write!(&mut fetch_context, "\nFetch: {}\n\n{}", url, content).ok();
}
diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rs
index 91b17a91a79..45aa0014b1a 100644
--- a/crates/agent_ui/src/agent_panel.rs
+++ b/crates/agent_ui/src/agent_panel.rs
@@ -78,7 +78,6 @@ use gpui::{
use language::LanguageRegistry;
use language_model::LanguageModelRegistry;
use project::{Project, ProjectPath, Worktree};
-use prompt_store::PromptStore;
use settings::TerminalDockPosition;
use settings::{NotifyWhenAgentWaiting, Settings, update_settings_file};
use skill_creator::{SkillCreatorOpenMode, is_supported_skill_url, open_skill_creator};
@@ -1049,7 +1048,6 @@ pub struct AgentPanel {
fs: Arc<dyn Fs>,
language_registry: Arc<LanguageRegistry>,
thread_store: Entity<ThreadStore>,
- prompt_store: Option<Entity<PromptStore>>,
connection_store: Entity<AgentConnectionStore>,
context_server_registry: Entity<ContextServerRegistry>,
configuration: Option<Entity<AgentConfiguration>>,
@@ -1170,13 +1168,8 @@ impl AgentPanel {
workspace: WeakEntity<Workspace>,
mut cx: AsyncWindowContext,
) -> Task<Result<Entity<Self>>> {
- let prompt_store = cx.update(|_window, cx| PromptStore::global(cx));
let kvp = cx.update(|_window, cx| KeyValueStore::global(cx)).ok();
cx.spawn(async move |cx| {
- let prompt_store = match prompt_store {
- Ok(prompt_store) => prompt_store.await.ok(),
- Err(_) => None,
- };
let workspace_id = workspace
.read_with(cx, |workspace, _| workspace.database_id())
.ok()
@@ -1301,7 +1294,7 @@ impl AgentPanel {
};
let panel = workspace.update_in(cx, |workspace, window, cx| {
- let panel = cx.new(|cx| Self::new(workspace, prompt_store, window, cx));
+ let panel = cx.new(|cx| Self::new(workspace, window, cx));
panel.update(cx, |panel, cx| {
let is_via_collab = panel.project.read(cx).is_via_collab();
@@ -1381,12 +1374,7 @@ impl AgentPanel {
})
}
- pub(crate) fn new(
- workspace: &Workspace,
- prompt_store: Option<Entity<PromptStore>>,
- _window: &mut Window,
- cx: &mut Context<Self>,
- ) -> Self {
+ pub(crate) fn new(workspace: &Workspace, _window: &mut Window, cx: &mut Context<Self>) -> Self {
let fs = workspace.app_state().fs.clone();
let user_store = workspace.app_state().user_store.clone();
let project = workspace.project();
@@ -1468,7 +1456,6 @@ impl AgentPanel {
project: project.clone(),
fs: fs.clone(),
language_registry,
- prompt_store,
connection_store,
configuration: None,
configuration_subscription: None,
@@ -1547,10 +1534,6 @@ impl AgentPanel {
}
}
- pub(crate) fn prompt_store(&self) -> &Option<Entity<PromptStore>> {
- &self.prompt_store
- }
-
pub fn thread_store(&self) -> &Entity<ThreadStore> {
&self.thread_store
}
@@ -4395,7 +4378,6 @@ impl AgentPanel {
workspace.clone(),
project,
thread_store,
- self.prompt_store.clone(),
source,
window,
cx,
@@ -6087,7 +6069,7 @@ impl Dismissable for TrialEndUpsell {
#[cfg(any(test, feature = "test-support"))]
impl AgentPanel {
pub fn test_new(workspace: &Workspace, window: &mut Window, cx: &mut Context<Self>) -> Self {
- Self::new(workspace, None, window, cx)
+ Self::new(workspace, window, cx)
}
/// Drops a thread's `ConversationView` from `retained_threads` without
@@ -6594,7 +6576,7 @@ mod tests {
// Set up workspace A: with an active thread.
let panel_a = workspace_a.update_in(cx, |workspace, window, cx| {
- cx.new(|cx| AgentPanel::new(workspace, None, window, cx))
+ cx.new(|cx| AgentPanel::new(workspace, window, cx))
});
panel_a.update_in(cx, |panel, window, cx| {
@@ -6620,7 +6602,7 @@ mod tests {
// Set up workspace B: ClaudeCode, no active thread.
let panel_b = workspace_b.update_in(cx, |workspace, window, cx| {
- cx.new(|cx| AgentPanel::new(workspace, None, window, cx))
+ cx.new(|cx| AgentPanel::new(workspace, window, cx))
});
panel_b.update(cx, |panel, _cx| {
@@ -6723,7 +6705,7 @@ mod tests {
let cx = &mut VisualTestContext::from_window(multi_workspace.into(), cx);
let panel = workspace.update_in(cx, |workspace, window, cx| {
- cx.new(|cx| AgentPanel::new(workspace, None, window, cx))
+ cx.new(|cx| AgentPanel::new(workspace, window, cx))
});
panel.update_in(cx, |panel, window, cx| {
@@ -6918,7 +6900,7 @@ mod tests {
let cx = &mut VisualTestContext::from_window(multi_workspace.into(), cx);
let panel_a = workspace_a.update_in(cx, |workspace, window, cx| {
- cx.new(|cx| AgentPanel::new(workspace, None, window, cx))
+ cx.new(|cx| AgentPanel::new(workspace, window, cx))
});
panel_a
.update_in(cx, |panel, window, cx| {
@@ -6995,7 +6977,7 @@ mod tests {
let cx = &mut VisualTestContext::from_window(multi_workspace.into(), cx);
let panel = workspace.update_in(cx, |workspace, window, cx| {
- cx.new(|cx| AgentPanel::new(workspace, None, window, cx))
+ cx.new(|cx| AgentPanel::new(workspace, window, cx))
});
panel.update_in(cx, |panel, window, cx| {
@@ -7087,7 +7069,7 @@ mod tests {
});
let panel = workspace.update_in(cx, |workspace, window, cx| {
- cx.new(|cx| AgentPanel::new(workspace, None, window, cx))
+ cx.new(|cx| AgentPanel::new(workspace, window, cx))
});
// Open a restored thread using a flaky server so the initial connect
@@ -7186,7 +7168,7 @@ mod tests {
.unwrap();
let cx = &mut VisualTestContext::from_window(multi_workspace.into(), cx);
let panel = workspace.update_in(cx, |workspace, window, cx| {
- let panel = cx.new(|cx| AgentPanel::new(workspace, None, window, cx));
+ let panel = cx.new(|cx| AgentPanel::new(workspace, window, cx));
workspace.add_panel(panel.clone(), window, cx);
panel
});
@@ -7286,12 +7268,12 @@ mod tests {
let cx = &mut VisualTestContext::from_window(multi_workspace.into(), cx);
let panel_a = workspace_a.update_in(cx, |workspace, window, cx| {
- let panel = cx.new(|cx| AgentPanel::new(workspace, None, window, cx));
+ let panel = cx.new(|cx| AgentPanel::new(workspace, window, cx));
workspace.add_panel(panel.clone(), window, cx);
panel
});
let panel_b = workspace_b.update_in(cx, |workspace, window, cx| {
- let panel = cx.new(|cx| AgentPanel::new(workspace, None, window, cx));
+ let panel = cx.new(|cx| AgentPanel::new(workspace, window, cx));
workspace.add_panel(panel.clone(), window, cx);
panel
});
@@ -7666,7 +7648,7 @@ mod tests {
let cx = &mut VisualTestContext::from_window(multi_workspace.into(), cx);
let panel = workspace.update_in(cx, |workspace, window, cx| {
- let panel = cx.new(|cx| AgentPanel::new(workspace, None, window, cx));
+ let panel = cx.new(|cx| AgentPanel::new(workspace, window, cx));
workspace.add_panel(panel.clone(), window, cx);
panel
});
@@ -7853,7 +7835,7 @@ mod tests {
let cx = &mut VisualTestContext::from_window(multi_workspace.into(), cx);
let panel = workspace.update_in(cx, |workspace, window, cx| {
- let panel = cx.new(|cx| AgentPanel::new(workspace, None, window, cx));
+ let panel = cx.new(|cx| AgentPanel::new(workspace, window, cx));
workspace.add_panel(panel.clone(), window, cx);
panel
});
@@ -8082,7 +8064,7 @@ mod tests {
let cx = &mut VisualTestContext::from_window(multi_workspace.into(), cx);
let panel = workspace.update_in(cx, |workspace, window, cx| {
- let panel = cx.new(|cx| AgentPanel::new(workspace, None, window, cx));
+ let panel = cx.new(|cx| AgentPanel::new(workspace, window, cx));
workspace.add_panel(panel.clone(), window, cx);
panel
});
@@ -8168,7 +8150,7 @@ mod tests {
let cx = &mut VisualTestContext::from_window(multi_workspace.into(), cx);
let panel = workspace.update_in(cx, |workspace, window, cx| {
- let panel = cx.new(|cx| AgentPanel::new(workspace, None, window, cx));
+ let panel = cx.new(|cx| AgentPanel::new(workspace, window, cx));
workspace.add_panel(panel.clone(), window, cx);
panel
});
@@ -8258,7 +8240,7 @@ mod tests {
let mut cx = VisualTestContext::from_window(multi_workspace.into(), cx);
let panel = workspace.update_in(&mut cx, |workspace, window, cx| {
- cx.new(|cx| AgentPanel::new(workspace, None, window, cx))
+ cx.new(|cx| AgentPanel::new(workspace, window, cx))
});
(panel, cx)
@@ -8305,7 +8287,7 @@ mod tests {
register_test_sidebar(threads_list_active, &mut cx);
let panel = workspace.update_in(&mut cx, |workspace, window, cx| {
- let panel = cx.new(|cx| AgentPanel::new(workspace, None, window, cx));
+ let panel = cx.new(|cx| AgentPanel::new(workspace, window, cx));
workspace.add_panel(panel.clone(), window, cx);
workspace.focus_panel::<AgentPanel>(window, cx);
panel
@@ -8435,7 +8417,7 @@ mod tests {
let mut cx = VisualTestContext::from_window(multi_workspace.into(), cx);
let panel = workspace.update_in(&mut cx, |workspace, window, cx| {
- let panel = cx.new(|cx| AgentPanel::new(workspace, None, window, cx));
+ let panel = cx.new(|cx| AgentPanel::new(workspace, window, cx));
workspace.add_panel(panel.clone(), window, cx);
panel
});
@@ -8548,7 +8530,7 @@ mod tests {
let mut cx = VisualTestContext::from_window(multi_workspace.into(), cx);
let panel = workspace.update_in(&mut cx, |workspace, window, cx| {
- let panel = cx.new(|cx| AgentPanel::new(workspace, None, window, cx));
+ let panel = cx.new(|cx| AgentPanel::new(workspace, window, cx));
workspace.add_panel(panel.clone(), window, cx);
panel
});
@@ -9791,7 +9773,7 @@ mod tests {
let cx = &mut VisualTestContext::from_window(multi_workspace.into(), cx);
let panel_a = workspace_a.update_in(cx, |workspace, window, cx| {
- let panel = cx.new(|cx| AgentPanel::new(workspace, None, window, cx));
+ let panel = cx.new(|cx| AgentPanel::new(workspace, window, cx));
workspace.add_panel(panel.clone(), window, cx);
panel
});
@@ -10383,7 +10365,7 @@ mod tests {
let mut cx = VisualTestContext::from_window(multi_workspace.into(), cx);
let panel = workspace.update_in(&mut cx, |workspace, window, cx| {
- cx.new(|cx| AgentPanel::new(workspace, None, window, cx))
+ cx.new(|cx| AgentPanel::new(workspace, window, cx))
});
// Open thread A and send a message. With empty next_prompt_updates it
@@ -10652,7 +10634,7 @@ mod tests {
// Set up workspace A with agent_a
let panel_a = workspace_a.update_in(cx, |workspace, window, cx| {
- cx.new(|cx| AgentPanel::new(workspace, None, window, cx))
+ cx.new(|cx| AgentPanel::new(workspace, window, cx))
});
panel_a.update(cx, |panel, _cx| {
panel.selected_agent = agent_a.clone();
@@ -10660,7 +10642,7 @@ mod tests {
// Set up workspace B with agent_b
let panel_b = workspace_b.update_in(cx, |workspace, window, cx| {
- cx.new(|cx| AgentPanel::new(workspace, None, window, cx))
+ cx.new(|cx| AgentPanel::new(workspace, window, cx))
});
panel_b.update(cx, |panel, _cx| {
panel.selected_agent = agent_b.clone();
@@ -10731,7 +10713,7 @@ mod tests {
};
let panel = workspace.update_in(cx, |workspace, window, cx| {
- let panel = cx.new(|cx| AgentPanel::new(workspace, None, window, cx));
+ let panel = cx.new(|cx| AgentPanel::new(workspace, window, cx));
workspace.add_panel(panel.clone(), window, cx);
panel
});
@@ -10788,7 +10770,7 @@ mod tests {
let cx = &mut VisualTestContext::from_window(multi_workspace.into(), cx);
let panel = workspace.update_in(cx, |workspace, window, cx| {
- let panel = cx.new(|cx| AgentPanel::new(workspace, None, window, cx));
+ let panel = cx.new(|cx| AgentPanel::new(workspace, window, cx));
workspace.add_panel(panel.clone(), window, cx);
panel
});
@@ -10878,7 +10860,7 @@ mod tests {
let cx = &mut VisualTestContext::from_window(multi_workspace.into(), cx);
let panel = workspace.update_in(cx, |workspace, window, cx| {
- let panel = cx.new(|cx| AgentPanel::new(workspace, None, window, cx));
+ let panel = cx.new(|cx| AgentPanel::new(workspace, window, cx));
workspace.add_panel(panel.clone(), window, cx);
panel
});
@@ -10966,7 +10948,7 @@ mod tests {
workspace.update(cx, |workspace, _cx| workspace.set_random_database_id());
let cx = &mut VisualTestContext::from_window(multi_workspace.into(), cx);
let panel = workspace.update_in(cx, |workspace, window, cx| {
- let panel = cx.new(|cx| AgentPanel::new(workspace, None, window, cx));
+ let panel = cx.new(|cx| AgentPanel::new(workspace, window, cx));
workspace.add_panel(panel.clone(), window, cx);
panel
});
@@ -11076,7 +11058,7 @@ mod tests {
workspace.update(cx, |workspace, _cx| workspace.set_random_database_id());
let cx = &mut VisualTestContext::from_window(multi_workspace.into(), cx);
let panel = workspace.update_in(cx, |workspace, window, cx| {
- let panel = cx.new(|cx| AgentPanel::new(workspace, None, window, cx));
+ let panel = cx.new(|cx| AgentPanel::new(workspace, window, cx));
workspace.add_panel(panel.clone(), window, cx);
panel
});
@@ -11182,7 +11164,7 @@ mod tests {
let cx = &mut VisualTestContext::from_window(multi_workspace.into(), cx);
let panel = workspace.update_in(cx, |workspace, window, cx| {
- let panel = cx.new(|cx| AgentPanel::new(workspace, None, window, cx));
+ let panel = cx.new(|cx| AgentPanel::new(workspace, window, cx));
workspace.add_panel(panel.clone(), window, cx);
panel
});
@@ -11681,7 +11663,7 @@ mod tests {
let cx = &mut VisualTestContext::from_window(multi_workspace.into(), cx);
let panel = workspace.update_in(cx, |workspace, window, cx| {
- cx.new(|cx| AgentPanel::new(workspace, None, window, cx))
+ cx.new(|cx| AgentPanel::new(workspace, window, cx))
});
cx.run_until_parked();
@@ -11782,7 +11764,7 @@ mod tests {
// Create the agent panel and add it to the workspace.
let panel = workspace.update_in(&mut cx, |workspace, window, cx| {
- let panel = cx.new(|cx| AgentPanel::new(workspace, None, window, cx));
+ let panel = cx.new(|cx| AgentPanel::new(workspace, window, cx));
workspace.add_panel(panel.clone(), window, cx);
panel
});
@@ -11992,7 +11974,7 @@ mod tests {
let mut cx = VisualTestContext::from_window(multi_workspace.into(), cx);
let panel = workspace.update_in(&mut cx, |workspace, window, cx| {
- let panel = cx.new(|cx| AgentPanel::new(workspace, None, window, cx));
+ let panel = cx.new(|cx| AgentPanel::new(workspace, window, cx));
workspace.add_panel(panel.clone(), window, cx);
panel
});
@@ -12229,7 +12211,7 @@ mod tests {
// Set up panel_a with an active thread and type draft text.
let panel_a = workspace_a.update_in(cx, |workspace, window, cx| {
- let panel = cx.new(|cx| AgentPanel::new(workspace, None, window, cx));
+ let panel = cx.new(|cx| AgentPanel::new(workspace, window, cx));
workspace.add_panel(panel.clone(), window, cx);
panel
});
@@ -12253,7 +12235,7 @@ mod tests {
// Set up panel_b on workspace_b — starts as a fresh, empty panel.
let panel_b = workspace_b.update_in(cx, |workspace, window, cx| {
- let panel = cx.new(|cx| AgentPanel::new(workspace, None, window, cx));
+ let panel = cx.new(|cx| AgentPanel::new(workspace, window, cx));
workspace.add_panel(panel.clone(), window, cx);
panel
});
@@ -12323,7 +12305,7 @@ mod tests {
// Set up panel_a with draft text.
let panel_a = workspace_a.update_in(cx, |workspace, window, cx| {
- let panel = cx.new(|cx| AgentPanel::new(workspace, None, window, cx));
+ let panel = cx.new(|cx| AgentPanel::new(workspace, window, cx));
workspace.add_panel(panel.clone(), window, cx);
panel
});
@@ -12347,7 +12329,7 @@ mod tests {
// Set up panel_b with its OWN content — this is a non-fresh panel.
let panel_b = workspace_b.update_in(cx, |workspace, window, cx| {
- let panel = cx.new(|cx| AgentPanel::new(workspace, None, window, cx));
+ let panel = cx.new(|cx| AgentPanel::new(workspace, window, cx));
workspace.add_panel(panel.clone(), window, cx);
panel
});
@@ -12391,42 +12373,4 @@ mod tests {
);
});
}
-
- /// Regression test: NewThread must produce a connected thread even when
- /// the PromptStore fails to initialize (e.g. LMDB permission error).
- /// Before the fix, `NativeAgentServer::connect` propagated the
- /// PromptStore error with `?`, which put every new ConversationView
- /// into LoadError and made it impossible to start any native-agent
- /// thread.
- #[gpui::test]
- async fn test_new_thread_with_prompt_store_error(cx: &mut TestAppContext) {
- let (panel, mut cx) = setup_panel(cx).await;
-
- // NativeAgentServer::connect needs a global Fs.
- let fs = FakeFs::new(cx.executor());
- cx.update(|_, cx| {
- <dyn fs::Fs>::set_global(fs.clone(), cx);
- });
- cx.run_until_parked();
-
- // Dispatch NewThread, which goes through the real NativeAgentServer
- // path. In tests the PromptStore LMDB open fails with
- // "Permission denied"; the fix (.log_err() instead of ?) lets
- // the connection succeed anyway.
- panel.update_in(&mut cx, |panel, window, cx| {
- panel.new_thread(&NewThread, window, cx);
- });
- cx.run_until_parked();
-
- panel.read_with(&cx, |panel, cx| {
- assert!(
- panel.active_conversation_view().is_some(),
- "panel should have a conversation view after NewThread"
- );
- assert!(
- panel.active_agent_thread(cx).is_some(),
- "panel should have an active, connected agent thread"
- );
- });
- }
}
diff --git a/crates/agent_ui/src/conversation_view.rs b/crates/agent_ui/src/conversation_view.rs
index c707fc9f624..755c9629b1f 100644
--- a/crates/agent_ui/src/conversation_view.rs
+++ b/crates/agent_ui/src/conversation_view.rs
@@ -42,7 +42,6 @@ use markdown::{
};
use parking_lot::{Mutex, RwLock};
use project::{AgentId, AgentServerStore, Project, ProjectEntryId, ProjectPath};
-use prompt_store::{PromptId, PromptStore};
use crate::message_editor::SessionCapabilities;
use crate::{AgentThreadSource, DEFAULT_THREAD_TITLE, resolve_agent_image};
@@ -75,7 +74,6 @@ use workspace::{
path_link::sanitize_path_text,
};
use zed_actions::agent::{Chat, ToggleModelSelector};
-use zed_actions::assistant::OpenRulesLibrary;
use super::config_options::ConfigOptionsView;
use super::entry_view_state::EntryViewState;
@@ -531,7 +529,6 @@ pub struct ConversationView {
workspace: WeakEntity<Workspace>,
project: Entity<Project>,
thread_store: Option<Entity<ThreadStore>>,
- prompt_store: Option<Entity<PromptStore>>,
pub(crate) thread_id: ThreadId,
pub(crate) root_session_id: Option<acp::SessionId>,
server_state: ServerState,
@@ -738,7 +735,6 @@ impl ConversationView {
workspace: WeakEntity<Workspace>,
project: Entity<Project>,
thread_store: Option<Entity<ThreadStore>>,
- prompt_store: Option<Entity<PromptStore>>,
source: AgentThreadSource,
window: &mut Window,
cx: &mut Context<Self>,
@@ -795,7 +791,6 @@ impl ConversationView {
workspace,
project: project.clone(),
thread_store,
- prompt_store,
thread_id,
root_session_id: resume_session_id.clone(),
server_state: Self::initial_state(
@@ -1104,7 +1099,6 @@ impl ConversationView {
self.workspace.clone(),
self.project.downgrade(),
self.thread_store.clone(),
- self.prompt_store.clone(),
session_capabilities.clone(),
self.agent.agent_id(),
)
@@ -1273,7 +1267,6 @@ impl ConversationView {
self.project.downgrade(),
self.code_span_resolver.clone(),
self.thread_store.clone(),
- self.prompt_store.clone(),
initial_content,
subscriptions,
window,
@@ -2492,7 +2485,6 @@ impl ConversationView {
workspace.clone(),
project.clone(),
None,
- None,
session_capabilities.clone(),
agent_name.clone(),
"",
@@ -3721,7 +3713,6 @@ pub(crate) mod tests {
workspace.downgrade(),
project,
Some(thread_store),
- None,
AgentThreadSource::AgentPanel,
window,
cx,
@@ -3858,7 +3849,6 @@ pub(crate) mod tests {
workspace.downgrade(),
project,
Some(thread_store),
- None,
AgentThreadSource::AgentPanel,
window,
cx,
@@ -3940,7 +3930,6 @@ pub(crate) mod tests {
workspace.downgrade(),
project,
Some(thread_store),
- None,
AgentThreadSource::AgentPanel,
window,
cx,
@@ -4079,7 +4068,6 @@ pub(crate) mod tests {
workspace.downgrade(),
project.clone(),
Some(thread_store),
- None,
AgentThreadSource::AgentPanel,
window,
cx,
@@ -4364,7 +4352,7 @@ pub(crate) mod tests {
let cx = &mut VisualTestContext::from_window(multi_workspace_handle.into(), cx);
let panel = workspace.update_in(cx, |workspace, window, cx| {
- let panel = cx.new(|cx| crate::AgentPanel::new(workspace, None, window, cx));
+ let panel = cx.new(|cx| crate::AgentPanel::new(workspace, window, cx));
workspace.add_panel(panel.clone(), window, cx);
workspace.focus_panel::<crate::AgentPanel>(window, cx);
panel
@@ -4405,7 +4393,6 @@ pub(crate) mod tests {
workspace.downgrade(),
project.clone(),
Some(thread_store),
- None,
AgentThreadSource::AgentPanel,
window,
cx,
@@ -4504,7 +4491,6 @@ pub(crate) mod tests {
workspace.downgrade(),
project.clone(),
Some(thread_store),
- None,
AgentThreadSource::AgentPanel,
window,
cx,
@@ -4580,7 +4566,6 @@ pub(crate) mod tests {
workspace.downgrade(),
project.clone(),
Some(thread_store),
- None,
AgentThreadSource::AgentPanel,
window,
cx,
@@ -4648,7 +4633,6 @@ pub(crate) mod tests {
workspace.downgrade(),
project.clone(),
Some(thread_store),
- None,
AgentThreadSource::AgentPanel,
window,
cx,
@@ -4724,7 +4708,7 @@ pub(crate) mod tests {
let cx = &mut VisualTestContext::from_window(multi_workspace_handle.into(), cx);
let panel = workspace1.update_in(cx, |workspace, window, cx| {
- let panel = cx.new(|cx| crate::AgentPanel::new(workspace, None, window, cx));
+ let panel = cx.new(|cx| crate::AgentPanel::new(workspace, window, cx));
workspace.add_panel(panel.clone(), window, cx);
// Open the dock and activate the agent panel so it's visible
@@ -4770,7 +4754,6 @@ pub(crate) mod tests {
workspace1.downgrade(),
project1.clone(),
Some(thread_store),
- None,
AgentThreadSource::AgentPanel,
window,
cx,
@@ -4992,7 +4975,6 @@ pub(crate) mod tests {
workspace.downgrade(),
project,
Some(thread_store),
- None,
AgentThreadSource::AgentPanel,
window,
cx,
@@ -5651,7 +5633,6 @@ pub(crate) mod tests {
workspace.downgrade(),
project.clone(),
Some(thread_store.clone()),
- None,
AgentThreadSource::AgentPanel,
window,
cx,
@@ -8627,7 +8608,6 @@ pub(crate) mod tests {
workspace.downgrade(),
project,
Some(thread_store),
- None,
AgentThreadSource::AgentPanel,
window,
cx,
diff --git a/crates/agent_ui/src/conversation_view/thread_view.rs b/crates/agent_ui/src/conversation_view/thread_view.rs
index 32969d76d3d..3eec4c93ff0 100644
--- a/crates/agent_ui/src/conversation_view/thread_view.rs
+++ b/crates/agent_ui/src/conversation_view/thread_view.rs
@@ -683,7 +683,6 @@ impl ThreadView {
project: WeakEntity<Project>,
code_span_resolver: AgentCodeSpanResolver,
thread_store: Option<Entity<ThreadStore>>,
- prompt_store: Option<Entity<PromptStore>>,
initial_content: Option<AgentInitialContent>,
mut subscriptions: Vec<Subscription>,
window: &mut Window,
@@ -703,7 +702,6 @@ impl ThreadView {
workspace.clone(),
project.clone(),
thread_store,
- prompt_store,
session_capabilities.clone(),
agent_id.clone(),
&placeholder,
@@ -10009,17 +10007,6 @@ pub(crate) fn open_link(
});
}
}
- MentionUri::Rule { id, .. } => {
- let PromptId::User { uuid } = id else {
- return;
- };
- window.dispatch_action(
- Box::new(OpenRulesLibrary {
- prompt_to_select: Some(uuid.0),
- }),
- cx,
- )
- }
MentionUri::Fetch { url } => {
cx.open_url(url.as_str());
}
diff --git a/crates/agent_ui/src/entry_view_state.rs b/crates/agent_ui/src/entry_view_state.rs
index a66ac0da7f7..9d2b030638f 100644
--- a/crates/agent_ui/src/entry_view_state.rs
+++ b/crates/agent_ui/src/entry_view_state.rs
@@ -11,7 +11,6 @@ use gpui::{
};
use language::language_settings::SoftWrap;
use project::{AgentId, Project, project_settings::DiagnosticSeverity};
-use prompt_store::PromptStore;
use rope::Point;
use settings::Settings as _;
use terminal_view::TerminalView;
@@ -25,7 +24,6 @@ pub struct EntryViewState {
workspace: WeakEntity<Workspace>,
project: WeakEntity<Project>,
thread_store: Option<Entity<ThreadStore>>,
- prompt_store: Option<Entity<PromptStore>>,
entries: Vec<Entry>,
session_capabilities: SharedSessionCapabilities,
agent_id: AgentId,
@@ -36,7 +34,6 @@ impl EntryViewState {
workspace: WeakEntity<Workspace>,
project: WeakEntity<Project>,
thread_store: Option<Entity<ThreadStore>>,
- prompt_store: Option<Entity<PromptStore>>,
session_capabilities: SharedSessionCapabilities,
agent_id: AgentId,
) -> Self {
@@ -44,7 +41,6 @@ impl EntryViewState {
workspace,
project,
thread_store,
- prompt_store,
entries: Vec::new(),
session_capabilities,
agent_id,
@@ -86,7 +82,6 @@ impl EntryViewState {
self.workspace.clone(),
self.project.clone(),
self.thread_store.clone(),
- self.prompt_store.clone(),
self.session_capabilities.clone(),
self.agent_id.clone(),
"Edit message - @ to include context",
@@ -546,7 +541,6 @@ mod tests {
workspace.downgrade(),
project.downgrade(),
thread_store,
- None,
Arc::new(RwLock::new(SessionCapabilities::default())),
"Test Agent".into(),
)
diff --git a/crates/agent_ui/src/inline_assistant.rs b/crates/agent_ui/src/inline_assistant.rs
index b13a9b615b6..661feabb5f6 100644
--- a/crates/agent_ui/src/inline_assistant.rs
+++ b/crates/agent_ui/src/inline_assistant.rs
@@ -43,7 +43,7 @@ use language_model::{ConfigurationError, ConfiguredModel, LanguageModelRegistry}
use multi_buffer::MultiBufferRow;
use parking_lot::Mutex;
use project::{DisableAiSettings, Project};
-use prompt_store::{PromptBuilder, PromptStore};
+use prompt_store::PromptBuilder;
use settings::{Settings, SettingsStore};
use terminal_view::{TerminalView, terminal_panel::TerminalPanel};
@@ -228,7 +228,6 @@ impl InlineAssistant {
};
let agent_panel = agent_panel.read(cx);
- let prompt_store = agent_panel.prompt_store().as_ref().cloned();
let thread_store = agent_panel.thread_store().clone();
let handle_assist =
@@ -240,7 +239,6 @@ impl InlineAssistant {
cx.entity().downgrade(),
workspace.project().downgrade(),
thread_store,
- prompt_store,
action.prompt.clone(),
window,
cx,
@@ -254,7 +252,6 @@ impl InlineAssistant {
cx.entity().downgrade(),
workspace.project().downgrade(),
thread_store,
- prompt_store,
action.prompt.clone(),
window,
cx,
@@ -437,7 +434,6 @@ impl InlineAssistant {
workspace: WeakEntity<Workspace>,
project: WeakEntity<Project>,
thread_store: Entity<ThreadStore>,
- prompt_store: Option<Entity<PromptStore>>,
initial_prompt: Option<String>,
window: &mut Window,
codegen_ranges: &[Range<Anchor>],
@@ -483,7 +479,6 @@ impl InlineAssistant {
session_id,
self.fs.clone(),
thread_store.clone(),
- prompt_store.clone(),
project.clone(),
workspace.clone(),
window,
@@ -574,7 +569,6 @@ impl InlineAssistant {
workspace: WeakEntity<Workspace>,
project: WeakEntity<Project>,
thread_store: Entity<ThreadStore>,
- prompt_store: Option<Entity<PromptStore>>,
initial_prompt: Option<String>,
window: &mut Window,
cx: &mut App,
@@ -592,7 +586,6 @@ impl InlineAssistant {
workspace,
project,
thread_store,
- prompt_store,
initial_prompt,
window,
&codegen_ranges,
@@ -1915,7 +1908,6 @@ pub mod evals {
workspace.downgrade(),
project.downgrade(),
thread_store,
- None,
Some(prompt),
window,
cx,
diff --git a/crates/agent_ui/src/inline_prompt_editor.rs b/crates/agent_ui/src/inline_prompt_editor.rs
index 31bdf83da16..4860b8b5765 100644
--- a/crates/agent_ui/src/inline_prompt_editor.rs
+++ b/crates/agent_ui/src/inline_prompt_editor.rs
@@ -17,7 +17,6 @@ use language_model::{LanguageModel, LanguageModelRegistry};
use markdown::{HeadingLevelStyles, Markdown, MarkdownElement, MarkdownStyle};
use parking_lot::Mutex;
use project::Project;
-use prompt_store::PromptStore;
use settings::Settings;
use std::cmp;
use std::ops::Range;
@@ -1237,7 +1236,6 @@ impl PromptEditor<BufferCodegen> {
session_id: Uuid,
fs: Arc<dyn Fs>,
thread_store: Entity<ThreadStore>,
- prompt_store: Option<Entity<PromptStore>>,
project: WeakEntity<Project>,
workspace: WeakEntity<Workspace>,
window: &mut Window,
@@ -1276,8 +1274,7 @@ impl PromptEditor<BufferCodegen> {
editor
});
- let mention_set = cx
- .new(|_cx| MentionSet::new(project, Some(thread_store.clone()), prompt_store.clone()));
+ let mention_set = cx.new(|_cx| MentionSet::new(project, Some(thread_store.clone())));
let model_selector_menu_handle = PopoverMenuHandle::default();
@@ -1393,7 +1390,6 @@ impl PromptEditor<TerminalCodegen> {
session_id: Uuid,
fs: Arc<dyn Fs>,
thread_store: Entity<ThreadStore>,
- prompt_store: Option<Entity<PromptStore>>,
project: WeakEntity<Project>,
workspace: WeakEntity<Workspace>,
window: &mut Window,
@@ -1427,8 +1423,7 @@ impl PromptEditor<TerminalCodegen> {
editor
});
- let mention_set = cx
- .new(|_cx| MentionSet::new(project, Some(thread_store.clone()), prompt_store.clone()));
+ let mention_set = cx.new(|_cx| MentionSet::new(project, Some(thread_store.clone())));
let model_selector_menu_handle = PopoverMenuHandle::default();
@@ -1705,7 +1700,6 @@ mod tests {
session_id,
fs,
thread_store,
- None,
project,
workspace.downgrade(),
window,
diff --git a/crates/agent_ui/src/mention_set.rs b/crates/agent_ui/src/mention_set.rs
index beecb840f08..cae882e8c9f 100644
--- a/crates/agent_ui/src/mention_set.rs
+++ b/crates/agent_ui/src/mention_set.rs
@@ -22,7 +22,6 @@ use language_model::{LanguageModelImage, LanguageModelImageExt};
use multi_buffer::MultiBufferRow;
use postage::stream::Stream as _;
use project::{Project, ProjectItem, ProjectPath, Worktree};
-use prompt_store::{PromptId, PromptStore};
use rope::Point;
use std::{
cell::RefCell,
@@ -61,21 +60,15 @@ pub struct MentionImage {
pub struct MentionSet {
project: WeakEntity<Project>,
thread_store: Option<Entity<ThreadStore>>,
- prompt_store: Option<Entity<PromptStore>>,
mentions: HashMap<CreaseId, (MentionUri, MentionTask)>,
crease_entities: HashMap<CreaseId, Entity<LoadingContext>>,
}
impl MentionSet {
- pub fn new(
- project: WeakEntity<Project>,
- thread_store: Option<Entity<ThreadStore>>,
- prompt_store: Option<Entity<PromptStore>>,
- ) -> Self {
+ pub fn new(project: WeakEntity<Project>, thread_store: Option<Entity<ThreadStore>>) -> Self {
Self {
project,
thread_store,
- prompt_store,
mentions: HashMap::default(),
crease_entities: HashMap::default(),
}
@@ -153,7 +146,6 @@ impl MentionSet {
line_range,
..
} => self.confirm_mention_for_symbol(abs_path, line_range, cx),
- MentionUri::Rule { id, .. } => self.confirm_mention_for_rule(id, cx),
MentionUri::Skill {
skill_file_path, ..
} => self.confirm_mention_for_skill(skill_file_path, cx),
@@ -327,7 +319,6 @@ impl MentionSet {
line_range,
..
} => self.confirm_mention_for_symbol(abs_path, line_range, cx),
- MentionUri::Rule { id, .. } => self.confirm_mention_for_rule(id, cx),
MentionUri::Skill {
skill_file_path, ..
} => self.confirm_mention_for_skill(skill_file_path, cx),
@@ -515,24 +506,6 @@ impl MentionSet {
})
}
- fn confirm_mention_for_rule(
- &mut self,
- id: PromptId,
- cx: &mut Context<Self>,
- ) -> Task<Result<Mention>> {
- let Some(prompt_store) = self.prompt_store.as_ref() else {
- return Task::ready(Err(anyhow!("Missing prompt store")));
- };
- let prompt = prompt_store.read(cx).load(id, cx);
- cx.spawn(async move |_, _| {
- let prompt = prompt.await?;
- Ok(Mention::Text {
- content: prompt,
- tracked_buffers: Vec::new(),
- })
- })
- }
-
pub fn confirm_mention_for_selection(
&mut self,
source_range: Range<text::Anchor>,
@@ -773,7 +746,7 @@ mod tests {
fs.insert_tree("/project", json!({"file": ""})).await;
let project = Project::test(fs, [Path::new(path!("/project"))], cx).await;
let thread_store = None;
- let mention_set = cx.new(|_cx| MentionSet::new(project.downgrade(), thread_store, None));
+ let mention_set = cx.new(|_cx| MentionSet::new(project.downgrade(), thread_store));
let task = mention_set.update(cx, |mention_set, cx| {
mention_set.confirm_mention_for_thread(acp::SessionId::new("thread-1"), cx)
@@ -799,7 +772,7 @@ mod tests {
)
.await;
let project = Project::test(fs, [Path::new(path!("/project"))], cx).await;
- let mention_set = cx.new(|_cx| MentionSet::new(project.downgrade(), None, None));
+ let mention_set = cx.new(|_cx| MentionSet::new(project.downgrade(), None));
let mention_task = mention_set.update(cx, |mention_set, cx| {
let http_client = project.read(cx).client().http_client();
diff --git a/crates/agent_ui/src/message_editor.rs b/crates/agent_ui/src/message_editor.rs
index 5b6b8671413..c6e52939d60 100644
--- a/crates/agent_ui/src/message_editor.rs
+++ b/crates/agent_ui/src/message_editor.rs
@@ -33,7 +33,6 @@ use project::AgentId;
use project::{
CompletionIntent, InlayHint, InlayHintLabel, InlayId, Project, ProjectPath, Worktree,
};
-use prompt_store::PromptStore;
use rope::Point;
use settings::Settings;
use std::{cmp::min, fmt::Write, ops::Range, rc::Rc, sync::Arc};
@@ -453,7 +452,6 @@ impl MessageEditor {
workspace: WeakEntity<Workspace>,
project: WeakEntity<Project>,
thread_store: Option<Entity<ThreadStore>>,
- prompt_store: Option<Entity<PromptStore>>,
session_capabilities: SharedSessionCapabilities,
agent_id: AgentId,
placeholder: &str,
@@ -506,8 +504,7 @@ impl MessageEditor {
editor
});
- let mention_set =
- cx.new(|_cx| MentionSet::new(project, thread_store.clone(), prompt_store.clone()));
+ let mention_set = cx.new(|_cx| MentionSet::new(project, thread_store.clone()));
let completion_provider = Rc::new(PromptCompletionProvider::new(
MessageEditorCompletionDelegate {
session_capabilities: session_capabilities.clone(),
@@ -2475,7 +2472,6 @@ mod tests {
workspace.downgrade(),
project.downgrade(),
thread_store.clone(),
- None,
Default::default(),
"Test Agent".into(),
"Test",
@@ -2576,7 +2572,6 @@ mod tests {
workspace_handle.clone(),
project.downgrade(),
thread_store.clone(),
- None,
session_capabilities.clone(),
"Claude Agent".into(),
"Test",
@@ -2742,7 +2737,6 @@ mod tests {
workspace_handle,
project.downgrade(),
thread_store.clone(),
- None,
session_capabilities.clone(),
"Test Agent".into(),
"Test",
@@ -2915,7 +2909,6 @@ mod tests {
workspace_handle,
project.downgrade(),
None,
- None,
session_capabilities.clone(),
"Test Agent".into(),
"Test",
@@ -3064,7 +3057,6 @@ mod tests {
workspace_handle,
project.downgrade(),
Some(thread_store),
- None,
session_capabilities.clone(),
"Test Agent".into(),
"Test",
@@ -3556,7 +3548,6 @@ mod tests {
workspace.downgrade(),
project.downgrade(),
thread_store.clone(),
- None,
Default::default(),
"Test Agent".into(),
"Test",
@@ -3657,7 +3648,6 @@ mod tests {
workspace.downgrade(),
project.downgrade(),
thread_store.clone(),
- None,
Default::default(),
"Test Agent".into(),
"Test",
@@ -3726,7 +3716,6 @@ mod tests {
workspace.downgrade(),
project.downgrade(),
thread_store.clone(),
- None,
Default::default(),
"Test Agent".into(),
"Test",
@@ -3779,7 +3768,6 @@ mod tests {
workspace.downgrade(),
project.downgrade(),
thread_store.clone(),
- None,
Default::default(),
"Test Agent".into(),
"Test",
@@ -3836,7 +3824,6 @@ mod tests {
workspace.downgrade(),
project.downgrade(),
thread_store.clone(),
- None,
Default::default(),
"Test Agent".into(),
"Test",
@@ -3894,7 +3881,6 @@ mod tests {
workspace.downgrade(),
project.downgrade(),
thread_store.clone(),
- None,
Default::default(),
"Test Agent".into(),
"Test",
@@ -3956,7 +3942,6 @@ mod tests {
workspace_handle,
project.downgrade(),
thread_store.clone(),
- None,
Default::default(),
"Test Agent".into(),
"Test",
@@ -4116,7 +4101,6 @@ mod tests {
workspace_handle,
project.downgrade(),
thread_store.clone(),
- None,
Default::default(),
"Test Agent".into(),
"Test",
@@ -4236,7 +4220,6 @@ mod tests {
workspace_handle,
project.downgrade(),
Some(thread_store.clone()),
- None,
Default::default(),
"Test Agent".into(),
"Test",
@@ -4315,7 +4298,6 @@ mod tests {
workspace_handle,
project.downgrade(),
Some(thread_store),
- None,
Default::default(),
"Test Agent".into(),
"Test",
@@ -4493,7 +4475,6 @@ mod tests {
workspace_handle,
project.downgrade(),
Some(thread_store),
- None,
Default::default(),
"Test Agent".into(),
"Test",
@@ -4905,7 +4886,6 @@ mod tests {
workspace_handle,
project.downgrade(),
Some(thread_store),
- None,
Default::default(),
"Test Agent".into(),
"Test",
@@ -5160,7 +5140,6 @@ mod tests {
workspace_handle,
project.downgrade(),
Some(thread_store),
- None,
Default::default(),
"Test Agent".into(),
"Test",
@@ -5253,7 +5232,6 @@ mod tests {
workspace.downgrade(),
project.downgrade(),
None,
- None,
Default::default(),
"Test Agent".into(),
"Test",
@@ -5402,7 +5380,6 @@ mod tests {
workspace.downgrade(),
project.downgrade(),
None,
- None,
Default::default(),
"Test Agent".into(),
"Test",
diff --git a/crates/agent_ui/src/terminal_inline_assistant.rs b/crates/agent_ui/src/terminal_inline_assistant.rs
index c4db6a088da..0524fb2bd29 100644
--- a/crates/agent_ui/src/terminal_inline_assistant.rs
+++ b/crates/agent_ui/src/terminal_inline_assistant.rs
@@ -22,7 +22,7 @@ use language_models::provider::anthropic::telemetry::{
AnthropicCompletionType, AnthropicEventData, AnthropicEventType, report_anthropic_event,
};
use project::Project;
-use prompt_store::{PromptBuilder, PromptStore};
+use prompt_store::PromptBuilder;
use std::sync::Arc;
use terminal_view::TerminalView;
use ui::prelude::*;
@@ -64,7 +64,6 @@ impl TerminalInlineAssistant {
workspace: WeakEntity<Workspace>,
project: WeakEntity<Project>,
thread_store: Entity<ThreadStore>,
- prompt_store: Option<Entity<PromptStore>>,
initial_prompt: Option<String>,
window: &mut Window,
cx: &mut App,
@@ -89,7 +88,6 @@ impl TerminalInlineAssistant {
session_id,
self.fs.clone(),
thread_store.clone(),
- prompt_store.clone(),
project.clone(),
workspace.clone(),
window,
diff --git a/crates/agent_ui/src/thread_metadata_store.rs b/crates/agent_ui/src/thread_metadata_store.rs
index 80bf512147f..5b4b90e4b70 100644
--- a/crates/agent_ui/src/thread_metadata_store.rs
+++ b/crates/agent_ui/src/thread_metadata_store.rs
@@ -1888,7 +1888,7 @@ mod tests {
.unwrap();
let mut vcx = VisualTestContext::from_window(multi_workspace.into(), cx);
let panel = workspace_entity.update_in(&mut vcx, |workspace, window, cx| {
- cx.new(|cx| crate::AgentPanel::new(workspace, None, window, cx))
+ cx.new(|cx| crate::AgentPanel::new(workspace, window, cx))
});
(panel, vcx)
}
diff --git a/crates/agent_ui/src/ui/mention_crease.rs b/crates/agent_ui/src/ui/mention_crease.rs
index 6ce10698b5f..77cfc5512ed 100644
--- a/crates/agent_ui/src/ui/mention_crease.rs
+++ b/crates/agent_ui/src/ui/mention_crease.rs
@@ -8,7 +8,6 @@ use gpui::{
pulsating_between,
};
use language::Buffer;
-use prompt_store::PromptId;
use rope::Point;
use settings::Settings;
use theme_settings::ThemeSettings;
@@ -195,9 +194,6 @@ fn open_mention_uri(
MentionUri::Thread { id, name } => {
open_thread(workspace, id, name, window, cx);
}
- MentionUri::Rule { id, .. } => {
- open_rule(workspace, id, window, cx);
- }
MentionUri::Skill {
skill_file_path, ..
} => {
@@ -360,23 +356,3 @@ fn open_thread(
}
});
}
-
-fn open_rule(
- _workspace: &mut Workspace,
- id: PromptId,
- window: &mut Window,
- cx: &mut Context<Workspace>,
-) {
- use zed_actions::assistant::OpenRulesLibrary;
-
- let PromptId::User { uuid } = id else {
- return;
- };
-
- window.dispatch_action(
- Box::new(OpenRulesLibrary {
- prompt_to_select: Some(uuid.0),
- }),
- cx,
- );
-}
diff --git a/crates/prompt_store/Cargo.toml b/crates/prompt_store/Cargo.toml
index 8c1f296f171..bc4179e5e72 100644
--- a/crates/prompt_store/Cargo.toml
+++ b/crates/prompt_store/Cargo.toml
@@ -21,7 +21,6 @@ db.workspace = true
fs.workspace = true
futures.workspace = true
-fuzzy.workspace = true
gpui.workspace = true
handlebars.workspace = true
heed.workspace = true
@@ -29,7 +28,6 @@ language.workspace = true
log.workspace = true
parking_lot.workspace = true
paths.workspace = true
-rope.workspace = true
serde.workspace = true
serde_json.workspace = true
strum.workspace = true
diff --git a/crates/prompt_store/src/prompt_store.rs b/crates/prompt_store/src/prompt_store.rs
index bf9b2f981bd..df270bb0a42 100644
--- a/crates/prompt_store/src/prompt_store.rs
+++ b/crates/prompt_store/src/prompt_store.rs
@@ -6,24 +6,17 @@ use chrono::{DateTime, Utc};
use collections::HashMap;
use futures::FutureExt as _;
use futures::future::Shared;
-use fuzzy::StringMatchCandidate;
-use gpui::{
- App, AppContext, Context, Entity, EventEmitter, Global, ReadGlobal, SharedString, Task,
-};
+
+use gpui::{App, AppContext, Entity, Global, ReadGlobal, SharedString, Task};
use heed::{
Database, RoTxn,
types::{SerdeBincode, SerdeJson, Str},
};
use parking_lot::RwLock;
pub use prompts::*;
-use rope::Rope;
+
use serde::{Deserialize, Serialize};
-use std::{
- cmp::Reverse,
- future::Future,
- path::PathBuf,
- sync::{Arc, atomic::AtomicBool},
-};
+use std::{future::Future, path::PathBuf, sync::Arc};
use strum::{EnumIter, IntoEnumIterator as _};
use text::LineEnding;
use util::ResultExt;
@@ -122,15 +115,6 @@ impl PromptId {
pub fn is_built_in(&self) -> bool {
matches!(self, Self::BuiltIn { .. })
}
-
- pub fn can_edit(&self) -> bool {
- match self {
- Self::User { .. } => true,
- Self::BuiltIn(builtin) => match builtin {
- BuiltInPrompt::CommitMessage => true,
- },
- }
- }
}
impl From<BuiltInPrompt> for PromptId {
@@ -173,14 +157,9 @@ impl std::fmt::Display for PromptId {
pub struct PromptStore {
env: heed::Env,
metadata_cache: RwLock<MetadataCache>,
- metadata: Database<SerdeJson<PromptId>, SerdeJson<PromptMetadata>>,
bodies: Database<SerdeJson<PromptId>, Str>,
}
-pub struct PromptsUpdatedEvent;
-
-impl EventEmitter<PromptsUpdatedEvent> for PromptStore {}
-
#[derive(Default)]
struct MetadataCache {
metadata: Vec<PromptMetadata>,
@@ -220,21 +199,6 @@ impl MetadataCache {
Ok(cache)
}
- fn insert(&mut self, metadata: PromptMetadata) {
- self.metadata_by_id.insert(metadata.id, metadata.clone());
- if let Some(old_metadata) = self.metadata.iter_mut().find(|m| m.id == metadata.id) {
- *old_metadata = metadata;
- } else {
- self.metadata.push(metadata);
- }
- self.sort();
- }
-
- fn remove(&mut self, id: PromptId) {
- self.metadata.retain(|metadata| metadata.id != id);
- self.metadata_by_id.remove(&id);
- }
-
fn sort(&mut self) {
self.metadata.sort_unstable_by(|a, b| {
a.title
@@ -275,7 +239,6 @@ impl PromptStore {
Ok(PromptStore {
env: db_env,
metadata_cache: RwLock::new(metadata_cache),
- metadata,
bodies,
})
})
@@ -363,219 +326,6 @@ impl PromptStore {
pub fn all_prompt_metadata(&self) -> Vec<PromptMetadata> {
self.metadata_cache.read().metadata.clone()
}
-
- pub fn default_prompt_metadata(&self) -> Vec<PromptMetadata> {
- return self
- .metadata_cache
- .read()
- .metadata
- .iter()
- .filter(|metadata| metadata.default)
- .cloned()
- .collect::<Vec<_>>();
- }
-
- pub fn delete(&self, id: PromptId, cx: &Context<Self>) -> Task<Result<()>> {
- self.metadata_cache.write().remove(id);
-
- let db_connection = self.env.clone();
- let bodies = self.bodies;
- let metadata = self.metadata;
-
- let task = cx.background_spawn(async move {
- let mut txn = db_connection.write_txn()?;
-
- metadata.delete(&mut txn, &id)?;
- bodies.delete(&mut txn, &id)?;
-
- if let PromptId::User { uuid } = id {
- let prompt_id_v1 = PromptIdV1::from(uuid);
-
- if let Some(metadata_v1_db) = db_connection
- .open_database::<SerdeBincode<PromptIdV1>, SerdeBincode<()>>(
- &txn,
- Some("metadata"),
- )?
- {
- metadata_v1_db.delete(&mut txn, &prompt_id_v1)?;
- }
-
- if let Some(bodies_v1_db) = db_connection
- .open_database::<SerdeBincode<PromptIdV1>, SerdeBincode<()>>(
- &txn,
- Some("bodies"),
- )?
- {
- bodies_v1_db.delete(&mut txn, &prompt_id_v1)?;
- }
- }
-
- txn.commit()?;
- anyhow::Ok(())
- });
-
- cx.spawn(async move |this, cx| {
- task.await?;
- this.update(cx, |_, cx| cx.emit(PromptsUpdatedEvent)).ok();
- anyhow::Ok(())
- })
- }
-
- pub fn metadata(&self, id: PromptId) -> Option<PromptMetadata> {
- self.metadata_cache.read().metadata_by_id.get(&id).cloned()
- }
-
- pub fn first(&self) -> Option<PromptMetadata> {
- self.metadata_cache.read().metadata.first().cloned()
- }
-
- pub fn id_for_title(&self, title: &str) -> Option<PromptId> {
- let metadata_cache = self.metadata_cache.read();
- let metadata = metadata_cache
- .metadata
- .iter()
- .find(|metadata| metadata.title.as_deref() == Some(title))?;
- Some(metadata.id)
- }
-
- pub fn search(
- &self,
- query: String,
- cancellation_flag: Arc<AtomicBool>,
- cx: &App,
- ) -> Task<Vec<PromptMetadata>> {
- let cached_metadata = self.metadata_cache.read().metadata.clone();
- let executor = cx.background_executor().clone();
- cx.background_spawn(async move {
- let mut matches = if query.is_empty() {
- cached_metadata
- } else {
- let candidates = cached_metadata
- .iter()
- .enumerate()
- .filter_map(|(ix, metadata)| {
- Some(StringMatchCandidate::new(ix, metadata.title.as_ref()?))
- })
- .collect::<Vec<_>>();
- let matches = fuzzy::match_strings(
- &candidates,
- &query,
- false,
- true,
- 100,
- &cancellation_flag,
- executor,
- )
- .await;
- matches
- .into_iter()
- .map(|mat| cached_metadata[mat.candidate_id].clone())
- .collect()
- };
- matches.sort_by_key(|metadata| Reverse(metadata.default));
- matches
- })
- }
-
- pub fn save(
- &self,
- id: PromptId,
- title: Option<SharedString>,
- default: bool,
- body: Rope,
- cx: &Context<Self>,
- ) -> Task<Result<()>> {
- if !id.can_edit() {
- return Task::ready(Err(anyhow!("this prompt cannot be edited")));
- }
-
- let body = body.to_string();
- let is_default_content = id
- .as_built_in()
- .is_some_and(|builtin| body.trim() == builtin.default_content().trim());
-
- let metadata = if let Some(builtin) = id.as_built_in() {
- PromptMetadata::builtin(builtin)
- } else {
- PromptMetadata {
- id,
- title,
- default,
- saved_at: Utc::now(),
- }
- };
-
- self.metadata_cache.write().insert(metadata.clone());
-
- let db_connection = self.env.clone();
- let bodies = self.bodies;
- let metadata_db = self.metadata;
-
- let task = cx.background_spawn(async move {
- let mut txn = db_connection.write_txn()?;
-
- if is_default_content {
- metadata_db.delete(&mut txn, &id)?;
- bodies.delete(&mut txn, &id)?;
- } else {
- metadata_db.put(&mut txn, &id, &metadata)?;
- bodies.put(&mut txn, &id, &body)?;
- }
-
- txn.commit()?;
-
- anyhow::Ok(())
- });
-
- cx.spawn(async move |this, cx| {
- task.await?;
- this.update(cx, |_, cx| cx.emit(PromptsUpdatedEvent)).ok();
- anyhow::Ok(())
- })
- }
-
- pub fn save_metadata(
- &self,
- id: PromptId,
- mut title: Option<SharedString>,
- default: bool,
- cx: &Context<Self>,
- ) -> Task<Result<()>> {
- let mut cache = self.metadata_cache.write();
-
- if !id.can_edit() {
- title = cache
- .metadata_by_id
- .get(&id)
- .and_then(|metadata| metadata.title.clone());
- }
-
- let prompt_metadata = PromptMetadata {
- id,
- title,
- default,
- saved_at: Utc::now(),
- };
-
- cache.insert(prompt_metadata.clone());
-
- let db_connection = self.env.clone();
- let metadata = self.metadata;
-
- let task = cx.background_spawn(async move {
- let mut txn = db_connection.write_txn()?;
- metadata.put(&mut txn, &id, &prompt_metadata)?;
- txn.commit()?;
-
- anyhow::Ok(())
- });
-
- cx.spawn(async move |this, cx| {
- task.await?;
- this.update(cx, |_, cx| cx.emit(PromptsUpdatedEvent)).ok();
- anyhow::Ok(())
- })
- }
}
/// Deprecated: Legacy V1 prompt ID format, used only for migrating data from old databases. Use `PromptId` instead.
@@ -608,7 +358,7 @@ mod tests {
use gpui::TestAppContext;
#[gpui::test]
- async fn test_built_in_prompt_load_save(cx: &mut TestAppContext) {
+ async fn test_built_in_prompt_load(cx: &mut TestAppContext) {
cx.executor().allow_parking();
let temp_dir = tempfile::tempdir().unwrap();
@@ -632,265 +382,14 @@ mod tests {
"Loading a built-in prompt not in DB should return default content"
);
- let metadata = store.read_with(cx, |store, _| store.metadata(commit_message_id));
- assert!(
- metadata.is_some(),
- "Built-in prompt should always have metadata"
- );
assert!(
store.read_with(cx, |store, _| {
store
- .metadata_cache
- .read()
- .metadata_by_id
- .contains_key(&commit_message_id)
+ .all_prompt_metadata()
+ .iter()
+ .any(|metadata| metadata.id == commit_message_id)
}),
"Built-in prompt should always be in cache"
);
-
- let custom_content = "Custom commit message prompt";
- store
- .update(cx, |store, cx| {
- store.save(
- commit_message_id,
- Some("Commit message".into()),
- false,
- Rope::from(custom_content),
- cx,
- )
- })
- .await
- .unwrap();
-
- let loaded_custom = store
- .update(cx, |store, cx| store.load(commit_message_id, cx))
- .await
- .unwrap();
- assert_eq!(
- loaded_custom.trim(),
- custom_content.trim(),
- "Custom content should be loaded after saving"
- );
-
- assert!(
- store
- .read_with(cx, |store, _| store.metadata(commit_message_id))
- .is_some(),
- "Built-in prompt should have metadata after customization"
- );
-
- store
- .update(cx, |store, cx| {
- store.save(
- commit_message_id,
- Some("Commit message".into()),
- false,
- Rope::from(BuiltInPrompt::CommitMessage.default_content()),
- cx,
- )
- })
- .await
- .unwrap();
-
- let metadata_after_reset =
- store.read_with(cx, |store, _| store.metadata(commit_message_id));
- assert!(
- metadata_after_reset.is_some(),
- "Built-in prompt should still have metadata after reset"
- );
- assert_eq!(
- metadata_after_reset
- .as_ref()
- .and_then(|m| m.title.as_ref().map(|t| t.as_ref())),
- Some("Commit message"),
- "Built-in prompt should have default title after reset"
- );
-
- let loaded_after_reset = store
- .update(cx, |store, cx| store.load(commit_message_id, cx))
- .await
- .unwrap();
- let mut expected_content_after_reset =
- BuiltInPrompt::CommitMessage.default_content().to_string();
- LineEnding::normalize(&mut expected_content_after_reset);
- assert_eq!(
- loaded_after_reset.trim(),
- expected_content_after_reset.trim(),
- "Content should be back to default after saving default content"
- );
- }
-
- /// Test that the prompt store initializes successfully even when the database
- /// contains records with incompatible/undecodable PromptId keys (e.g., from
- /// a different branch that used a different serialization format).
- ///
- /// This is a regression test for the "fail-open" behavior: we should skip
- /// bad records rather than failing the entire store initialization.
- #[gpui::test]
- async fn test_prompt_store_handles_incompatible_db_records(cx: &mut TestAppContext) {
- cx.executor().allow_parking();
-
- let temp_dir = tempfile::tempdir().unwrap();
- let db_path = temp_dir.path().join("prompts-db-with-bad-records");
- std::fs::create_dir_all(&db_path).unwrap();
-
- // First, create the DB and write an incompatible record directly.
- // We simulate a record written by a different branch that used
- // `{"kind":"CommitMessage"}` instead of `{"kind":"BuiltIn", ...}`.
- {
- let db_env = unsafe {
- heed::EnvOpenOptions::new()
- .map_size(1024 * 1024 * 1024)
- .max_dbs(4)
- .open(&db_path)
- .unwrap()
- };
-
- let mut txn = db_env.write_txn().unwrap();
- // Create the metadata.v2 database with raw bytes so we can write
- // an incompatible key format.
- let metadata_db: Database<heed::types::Bytes, heed::types::Bytes> = db_env
- .create_database(&mut txn, Some("metadata.v2"))
- .unwrap();
-
- // Write an incompatible PromptId key: `{"kind":"CommitMessage"}`
- // This is the old/branch format that current code can't decode.
- let bad_key = br#"{"kind":"CommitMessage"}"#;
- let dummy_metadata = br#"{"id":{"kind":"CommitMessage"},"title":"Bad Record","default":false,"saved_at":"2024-01-01T00:00:00Z"}"#;
- metadata_db.put(&mut txn, bad_key, dummy_metadata).unwrap();
-
- // Also write a valid record to ensure we can still read good data.
- let good_key = br#"{"kind":"User","uuid":"550e8400-e29b-41d4-a716-446655440000"}"#;
- let good_metadata = br#"{"id":{"kind":"User","uuid":"550e8400-e29b-41d4-a716-446655440000"},"title":"Good Record","default":false,"saved_at":"2024-01-01T00:00:00Z"}"#;
- metadata_db.put(&mut txn, good_key, good_metadata).unwrap();
-
- txn.commit().unwrap();
- }
-
- // Now try to create a PromptStore from this DB.
- // With fail-open behavior, this should succeed and skip the bad record.
- // Without fail-open, this would return an error.
- let store_result = cx.update(|cx| PromptStore::new(db_path, cx)).await;
-
- assert!(
- store_result.is_ok(),
- "PromptStore should initialize successfully even with incompatible DB records. \
- Got error: {:?}",
- store_result.err()
- );
-
- let store = cx.new(|_cx| store_result.unwrap());
-
- // Verify the good record was loaded.
- let good_id = PromptId::User {
- uuid: UserPromptId("550e8400-e29b-41d4-a716-446655440000".parse().unwrap()),
- };
- let metadata = store.read_with(cx, |store, _| store.metadata(good_id));
- assert!(
- metadata.is_some(),
- "Valid records should still be loaded after skipping bad ones"
- );
- assert_eq!(
- metadata
- .as_ref()
- .and_then(|m| m.title.as_ref().map(|t| t.as_ref())),
- Some("Good Record"),
- "Valid record should have correct title"
- );
- }
-
- #[gpui::test]
- async fn test_deleted_prompt_does_not_reappear_after_migration(cx: &mut TestAppContext) {
- cx.executor().allow_parking();
-
- let temp_dir = tempfile::tempdir().unwrap();
- let db_path = temp_dir.path().join("prompts-db-v1-migration");
- std::fs::create_dir_all(&db_path).unwrap();
-
- let prompt_uuid: Uuid = "550e8400-e29b-41d4-a716-446655440001".parse().unwrap();
- let prompt_id_v1 = PromptIdV1(prompt_uuid);
- let prompt_id_v2 = PromptId::User {
- uuid: UserPromptId(prompt_uuid),
- };
-
- // Create V1 database with a prompt
- {
- let db_env = unsafe {
- heed::EnvOpenOptions::new()
- .map_size(1024 * 1024 * 1024)
- .max_dbs(4)
- .open(&db_path)
- .unwrap()
- };
-
- let mut txn = db_env.write_txn().unwrap();
-
- let metadata_v1_db: Database<SerdeBincode<PromptIdV1>, SerdeBincode<PromptMetadataV1>> =
- db_env.create_database(&mut txn, Some("metadata")).unwrap();
-
- let bodies_v1_db: Database<SerdeBincode<PromptIdV1>, SerdeBincode<String>> =
- db_env.create_database(&mut txn, Some("bodies")).unwrap();
-
- let metadata_v1 = PromptMetadataV1 {
- id: prompt_id_v1.clone(),
- title: Some("V1 Prompt".into()),
- default: false,
- saved_at: Utc::now(),
- };
-
- metadata_v1_db
- .put(&mut txn, &prompt_id_v1, &metadata_v1)
- .unwrap();
- bodies_v1_db
- .put(&mut txn, &prompt_id_v1, &"V1 prompt body".to_string())
- .unwrap();
-
- txn.commit().unwrap();
- }
-
- // Migrate V1 to V2 by creating PromptStore
- let store = cx
- .update(|cx| PromptStore::new(db_path.clone(), cx))
- .await
- .unwrap();
- let store = cx.new(|_cx| store);
-
- // Verify the prompt was migrated
- let metadata = store.read_with(cx, |store, _| store.metadata(prompt_id_v2));
- assert!(metadata.is_some(), "V1 prompt should be migrated to V2");
- assert_eq!(
- metadata
- .as_ref()
- .and_then(|m| m.title.as_ref().map(|t| t.as_ref())),
- Some("V1 Prompt"),
- "Migrated prompt should have correct title"
- );
-
- // Delete the prompt
- store
- .update(cx, |store, cx| store.delete(prompt_id_v2, cx))
- .await
- .unwrap();
-
- // Verify prompt is deleted
- let metadata_after_delete = store.read_with(cx, |store, _| store.metadata(prompt_id_v2));
- assert!(
- metadata_after_delete.is_none(),
- "Prompt should be deleted from V2"
- );
-
- drop(store);
-
- // "Restart" by creating a new PromptStore from the same path
- let store_after_restart = cx.update(|cx| PromptStore::new(db_path, cx)).await.unwrap();
- let store_after_restart = cx.new(|_cx| store_after_restart);
-
- // Test the prompt does not reappear
- let metadata_after_restart =
- store_after_restart.read_with(cx, |store, _| store.metadata(prompt_id_v2));
- assert!(
- metadata_after_restart.is_none(),
- "Deleted prompt should NOT reappear after restart/migration"
- );
}
}