mirror of
https://github.com/zed-industries/zed.git
synced 2026-12-03 05:51:27 +01:00
Remove dead code and redundant checks in agent and language model crates (#67218)
## Summary
Removes unused code and redundant work. No behavior changes.
- Removes about 25 unused items. Examples:
- `TerminalProviderCommand`
- `AgentPanel::activate_retained_thread`
- `Thread::is_generating_summary`
- `LanguageModelResponseMessage`
- the fake provider's `ToolUseRequest`, along with `language_model`'s
`serde_json` dependency
- `ResolvedSymbol::{line_text, truncated}` were never read, so symbol
lookups no longer build a display string.
- `SandboxWrap::is_local` has gone unread since #59790 moved the check
into `terminal_tool`.
- Removes `cx.notify()` after `set_server_state`, `add_to_queue`,
`set_editor_is_expanded` and `clear_thread_error`, which always notify.
- `ProfileSelector::ensure_picker` and `ThreadView::toggle_search`
create or reuse their entity in one step instead of re-checking an
`Option` they just set. This removes an `unwrap()`.
- Copilot: once both completion futures finished, the result-tracking
state could only produce an empty `Vec`. Removes it.
- Smaller redundancies:
- Bedrock reuses its `current_message` binding.
- The context server listener uses the request id it already has instead
of `request.id.unwrap()`.
- `action_log` drops an `is_empty` check that `Buffer::edit` already
makes.
- Drops clones made only to be borrowed, and 17 `arc_with_non_send_sync`
allows in agent tests that no longer fire.
## Testing
- `./script/clippy`
- `cargo test -p agent -p agent_ui -p acp_thread -p agent_servers -p
copilot -p language_model -p language_models`
## Self-review
- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [x] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist).
- [x] Tests cover the new or changed behavior.
Release Notes:
- N/A
This commit is contained in:
Generated
-1
@@ -9582,7 +9582,6 @@ dependencies = [
|
||||
"language_model_core",
|
||||
"log",
|
||||
"parking_lot",
|
||||
"serde_json",
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
|
||||
|
||||
@@ -4003,22 +4003,6 @@ pub enum TerminalProviderEvent {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum TerminalProviderCommand {
|
||||
WriteInput {
|
||||
terminal_id: acp_v2::TerminalId,
|
||||
bytes: Vec<u8>,
|
||||
},
|
||||
Resize {
|
||||
terminal_id: acp_v2::TerminalId,
|
||||
cols: u16,
|
||||
rows: u16,
|
||||
},
|
||||
Close {
|
||||
terminal_id: acp_v2::TerminalId,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Debug)]
|
||||
pub enum ThreadStatus {
|
||||
Unconfirmed,
|
||||
@@ -8226,11 +8210,9 @@ impl AcpThread {
|
||||
let buffer = load.await?;
|
||||
|
||||
let snapshot = if reuse_shared_snapshot {
|
||||
this.read_with(cx, |this, _| {
|
||||
this.shared_buffers.get(&buffer.clone()).cloned()
|
||||
})
|
||||
.log_err()
|
||||
.flatten()
|
||||
this.read_with(cx, |this, _| this.shared_buffers.get(&buffer).cloned())
|
||||
.log_err()
|
||||
.flatten()
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
@@ -764,10 +764,6 @@ impl AgentModelList {
|
||||
AgentModelList::Grouped(groups) => groups.is_empty(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_flat(&self) -> bool {
|
||||
matches!(self, AgentModelList::Flat(_))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -1035,7 +1031,6 @@ mod test_support {
|
||||
supports_close_session: bool,
|
||||
announces_subagents: bool,
|
||||
close_sessions_on_release: bool,
|
||||
supports_session_additional_directories: bool,
|
||||
supports_set_title: bool,
|
||||
supports_truncate: bool,
|
||||
agent_id: AgentId,
|
||||
@@ -1086,7 +1081,6 @@ mod test_support {
|
||||
supports_close_session: false,
|
||||
announces_subagents: false,
|
||||
close_sessions_on_release: true,
|
||||
supports_session_additional_directories: false,
|
||||
supports_set_title: true,
|
||||
supports_truncate: true,
|
||||
agent_id: AgentId::new("stub"),
|
||||
@@ -1252,14 +1246,6 @@ mod test_support {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_supports_session_additional_directories(
|
||||
mut self,
|
||||
supports_session_additional_directories: bool,
|
||||
) -> Self {
|
||||
self.supports_session_additional_directories = supports_session_additional_directories;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_supports_set_title(mut self, supports_set_title: bool) -> Self {
|
||||
self.supports_set_title = supports_set_title;
|
||||
self
|
||||
@@ -1413,10 +1399,6 @@ mod test_support {
|
||||
}
|
||||
}
|
||||
|
||||
fn supports_session_additional_directories(&self) -> bool {
|
||||
self.supports_session_additional_directories
|
||||
}
|
||||
|
||||
fn load_session(
|
||||
self: Rc<Self>,
|
||||
session_id: acp_v2::SessionId,
|
||||
|
||||
@@ -57,10 +57,6 @@ pub struct SandboxWrap {
|
||||
/// Allow unrestricted filesystem writes except for protected paths (ignores
|
||||
/// ordinary writable paths).
|
||||
pub allow_fs_write: bool,
|
||||
/// Whether the project (and therefore this terminal) is local. The
|
||||
/// enforcing proxy binds a loopback port on this host, so it can only
|
||||
/// confine local commands; a remote terminal can't reach it.
|
||||
pub is_local: bool,
|
||||
/// Windows/WSL only: `(release channel, version)` of the Linux `zed` to
|
||||
/// provision inside WSL as the sandbox helper (version `latest` for dev
|
||||
/// builds). Resolved by the agent (which can read the running app's release
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use anyhow::{Context as _, Result};
|
||||
use buffer_diff::BufferDiff;
|
||||
use clock;
|
||||
use collections::{BTreeMap, HashMap};
|
||||
use fs::MTime;
|
||||
use futures::{FutureExt, StreamExt, channel::mpsc};
|
||||
@@ -1000,9 +999,7 @@ impl ActionLog {
|
||||
}
|
||||
}
|
||||
|
||||
if !valid_edits.is_empty() {
|
||||
buffer.edit(valid_edits, None, cx);
|
||||
}
|
||||
buffer.edit(valid_edits, None, cx);
|
||||
});
|
||||
|
||||
if !self.tracked_buffers.contains_key(&buffer) {
|
||||
@@ -1286,11 +1283,6 @@ impl TrackedBuffer {
|
||||
&self.diff
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub fn diff_base_len(&self) -> usize {
|
||||
self.diff_base.len()
|
||||
}
|
||||
|
||||
fn has_edits(&self, cx: &App) -> bool {
|
||||
self.diff
|
||||
.read(cx)
|
||||
|
||||
@@ -26,7 +26,6 @@ use util::{ResultExt, path_list::PathList};
|
||||
use zed_env_vars::ZED_STATELESS;
|
||||
|
||||
pub type DbMessage = crate::Message;
|
||||
pub type DbSummary = crate::legacy_thread::DetailedSummaryState;
|
||||
pub type DbLanguageModel = crate::legacy_thread::SerializedLanguageModel;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
||||
@@ -7877,7 +7877,6 @@ async fn test_edit_file_tool_deny_rule_blocks_edit(cx: &mut TestAppContext) {
|
||||
});
|
||||
let action_log = cx.update(|cx| thread.read(cx).action_log.clone());
|
||||
|
||||
#[allow(clippy::arc_with_non_send_sync)]
|
||||
let tool = Arc::new(crate::EditFileTool::new(
|
||||
project.clone(),
|
||||
thread.downgrade(),
|
||||
@@ -7931,7 +7930,6 @@ async fn test_delete_path_tool_deny_rule_blocks_deletion(cx: &mut TestAppContext
|
||||
|
||||
let action_log = cx.new(|_cx| action_log::ActionLog::new(project.clone()));
|
||||
|
||||
#[allow(clippy::arc_with_non_send_sync)]
|
||||
let tool = Arc::new(crate::DeletePathTool::new(project, action_log));
|
||||
let (event_stream, _rx) = crate::ToolCallEventStream::test();
|
||||
|
||||
@@ -7983,7 +7981,6 @@ async fn test_move_path_tool_denies_if_destination_denied(cx: &mut TestAppContex
|
||||
agent_settings::AgentSettings::override_global(settings, cx);
|
||||
});
|
||||
|
||||
#[allow(clippy::arc_with_non_send_sync)]
|
||||
let tool = Arc::new(crate::MovePathTool::new(project));
|
||||
let (event_stream, _rx) = crate::ToolCallEventStream::test();
|
||||
|
||||
@@ -8039,7 +8036,6 @@ async fn test_move_path_tool_denies_if_source_denied(cx: &mut TestAppContext) {
|
||||
agent_settings::AgentSettings::override_global(settings, cx);
|
||||
});
|
||||
|
||||
#[allow(clippy::arc_with_non_send_sync)]
|
||||
let tool = Arc::new(crate::MovePathTool::new(project));
|
||||
let (event_stream, _rx) = crate::ToolCallEventStream::test();
|
||||
|
||||
@@ -8097,7 +8093,6 @@ async fn test_copy_path_tool_deny_rule_blocks_copy(cx: &mut TestAppContext) {
|
||||
agent_settings::AgentSettings::override_global(settings, cx);
|
||||
});
|
||||
|
||||
#[allow(clippy::arc_with_non_send_sync)]
|
||||
let tool = Arc::new(crate::CopyPathTool::new(project));
|
||||
let (event_stream, _rx) = crate::ToolCallEventStream::test();
|
||||
|
||||
@@ -8141,7 +8136,6 @@ async fn test_web_search_tool_deny_rule_blocks_search(cx: &mut TestAppContext) {
|
||||
agent_settings::AgentSettings::override_global(settings, cx);
|
||||
});
|
||||
|
||||
#[allow(clippy::arc_with_non_send_sync)]
|
||||
let tool = Arc::new(crate::WebSearchTool);
|
||||
let (event_stream, _rx) = crate::ToolCallEventStream::test();
|
||||
|
||||
@@ -8203,7 +8197,6 @@ async fn test_edit_file_tool_allow_rule_skips_confirmation(cx: &mut TestAppConte
|
||||
});
|
||||
let action_log = thread.read_with(cx, |thread, _cx| thread.action_log().clone());
|
||||
|
||||
#[allow(clippy::arc_with_non_send_sync)]
|
||||
let tool = Arc::new(crate::EditFileTool::new(
|
||||
project,
|
||||
thread.downgrade(),
|
||||
@@ -8271,7 +8264,6 @@ async fn test_edit_file_tool_allow_still_prompts_for_local_settings(cx: &mut Tes
|
||||
});
|
||||
let action_log = thread.read_with(cx, |thread, _cx| thread.action_log().clone());
|
||||
|
||||
#[allow(clippy::arc_with_non_send_sync)]
|
||||
let tool = Arc::new(crate::EditFileTool::new(
|
||||
project,
|
||||
thread.downgrade(),
|
||||
@@ -8320,7 +8312,6 @@ async fn test_fetch_tool_deny_rule_blocks_url(cx: &mut TestAppContext) {
|
||||
|
||||
let http_client = gpui::http_client::FakeHttpClient::with_200_response();
|
||||
|
||||
#[allow(clippy::arc_with_non_send_sync)]
|
||||
let tool = Arc::new(crate::FetchTool::new(http_client));
|
||||
let (event_stream, _rx) = crate::ToolCallEventStream::test();
|
||||
|
||||
@@ -8364,7 +8355,6 @@ async fn test_fetch_tool_allow_rule_skips_confirmation(cx: &mut TestAppContext)
|
||||
|
||||
let http_client = gpui::http_client::FakeHttpClient::with_200_response();
|
||||
|
||||
#[allow(clippy::arc_with_non_send_sync)]
|
||||
let tool = Arc::new(crate::FetchTool::new(http_client));
|
||||
let (event_stream, mut rx) = crate::ToolCallEventStream::test();
|
||||
|
||||
@@ -8405,7 +8395,6 @@ async fn test_fetch_tool_prompts_for_ungranted_host(cx: &mut TestAppContext) {
|
||||
|
||||
let http_client = gpui::http_client::FakeHttpClient::with_200_response();
|
||||
|
||||
#[allow(clippy::arc_with_non_send_sync)]
|
||||
let tool = Arc::new(crate::FetchTool::new(http_client));
|
||||
let (event_stream, mut rx) = crate::ToolCallEventStream::test();
|
||||
|
||||
@@ -8453,7 +8442,6 @@ async fn test_fetch_tool_granted_host_skips_prompt(cx: &mut TestAppContext) {
|
||||
|
||||
let http_client = gpui::http_client::FakeHttpClient::with_200_response();
|
||||
|
||||
#[allow(clippy::arc_with_non_send_sync)]
|
||||
let tool = Arc::new(crate::FetchTool::new(http_client));
|
||||
let (event_stream, mut rx) = crate::ToolCallEventStream::test();
|
||||
|
||||
@@ -8495,7 +8483,6 @@ async fn test_fetch_tool_refuses_loopback_without_unsandboxed(cx: &mut TestAppCo
|
||||
|
||||
let http_client = gpui::http_client::FakeHttpClient::with_200_response();
|
||||
|
||||
#[allow(clippy::arc_with_non_send_sync)]
|
||||
let tool = Arc::new(crate::FetchTool::new(http_client));
|
||||
let (event_stream, _rx) = crate::ToolCallEventStream::test();
|
||||
|
||||
@@ -8537,7 +8524,6 @@ async fn test_fetch_tool_unsandboxed_lifts_restrictions(cx: &mut TestAppContext)
|
||||
|
||||
let http_client = gpui::http_client::FakeHttpClient::with_200_response();
|
||||
|
||||
#[allow(clippy::arc_with_non_send_sync)]
|
||||
let tool = Arc::new(crate::FetchTool::new(http_client));
|
||||
let (event_stream, mut rx) = crate::ToolCallEventStream::test();
|
||||
|
||||
@@ -8598,7 +8584,6 @@ async fn test_fetch_tool_refuses_redirect_to_loopback(cx: &mut TestAppContext) {
|
||||
.unwrap())
|
||||
});
|
||||
|
||||
#[allow(clippy::arc_with_non_send_sync)]
|
||||
let tool = Arc::new(crate::FetchTool::new(http_client));
|
||||
let (event_stream, _rx) = crate::ToolCallEventStream::test();
|
||||
|
||||
@@ -8657,7 +8642,6 @@ async fn test_fetch_tool_reauthorizes_redirect_to_new_host(cx: &mut TestAppConte
|
||||
.unwrap())
|
||||
});
|
||||
|
||||
#[allow(clippy::arc_with_non_send_sync)]
|
||||
let tool = Arc::new(crate::FetchTool::new(http_client));
|
||||
let (event_stream, mut rx) = crate::ToolCallEventStream::test();
|
||||
|
||||
@@ -8725,7 +8709,6 @@ async fn test_fetch_tool_follows_same_host_redirect(cx: &mut TestAppContext) {
|
||||
}
|
||||
});
|
||||
|
||||
#[allow(clippy::arc_with_non_send_sync)]
|
||||
let tool = Arc::new(crate::FetchTool::new(http_client));
|
||||
let (event_stream, mut rx) = crate::ToolCallEventStream::test();
|
||||
|
||||
|
||||
@@ -1332,7 +1332,6 @@ pub struct Thread {
|
||||
/// the start of each request.
|
||||
current_request_token_usage: TokenUsage,
|
||||
pending_compaction_telemetry: Option<CompactionTelemetry>,
|
||||
#[allow(unused)]
|
||||
initial_project_snapshot: Shared<Task<Option<Arc<ProjectSnapshot>>>>,
|
||||
pub(crate) context_server_registry: Entity<ContextServerRegistry>,
|
||||
profile_id: AgentProfileId,
|
||||
@@ -4121,10 +4120,6 @@ impl Thread {
|
||||
self.title.clone()
|
||||
}
|
||||
|
||||
pub fn is_generating_summary(&self) -> bool {
|
||||
self.pending_summary_generation.is_some()
|
||||
}
|
||||
|
||||
pub fn is_generating_title(&self) -> bool {
|
||||
self.pending_title_generation.is_some()
|
||||
}
|
||||
@@ -4513,12 +4508,6 @@ impl Thread {
|
||||
self.running_turn.as_ref()?.tools.get(name).cloned()
|
||||
}
|
||||
|
||||
pub fn has_tool(&self, name: &str) -> bool {
|
||||
self.running_turn
|
||||
.as_ref()
|
||||
.is_some_and(|turn| turn.tools.contains_key(name))
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub fn has_registered_tool(&self, name: &str) -> bool {
|
||||
self.tools.contains_key(name)
|
||||
@@ -7158,18 +7147,6 @@ impl ToolCallEventStreamReceiver {
|
||||
panic!("Expected diff but got: {:?}", event);
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn expect_terminal(&mut self) -> Entity<acp_thread::Terminal> {
|
||||
let event = self.0.next().await;
|
||||
if let Some(Ok(ThreadEvent::ToolCallUpdate(acp_thread::ToolCallUpdate::UpdateTerminal(
|
||||
update,
|
||||
)))) = event
|
||||
{
|
||||
update.terminal
|
||||
} else {
|
||||
panic!("Expected terminal but got: {:?}", event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
|
||||
@@ -61,17 +61,6 @@ impl ContextServerRegistry {
|
||||
this
|
||||
}
|
||||
|
||||
pub fn tools_for_server(
|
||||
&self,
|
||||
server_id: &ContextServerId,
|
||||
) -> impl Iterator<Item = &Arc<dyn AnyAgentTool>> {
|
||||
self.registered_servers
|
||||
.get(server_id)
|
||||
.map(|server| server.tools.values())
|
||||
.into_iter()
|
||||
.flatten()
|
||||
}
|
||||
|
||||
pub fn servers(
|
||||
&self,
|
||||
) -> impl Iterator<
|
||||
|
||||
@@ -34,8 +34,6 @@ pub type CodeActionStore = Entity<Option<PendingCodeActions>>;
|
||||
pub struct ResolvedSymbol {
|
||||
pub buffer: Entity<Buffer>,
|
||||
pub position: Anchor,
|
||||
pub line_text: String,
|
||||
pub truncated: bool,
|
||||
}
|
||||
|
||||
pub const MAX_LINE_DISPLAY_LEN: usize = 200;
|
||||
@@ -165,7 +163,7 @@ impl SymbolLocator {
|
||||
.await
|
||||
.map_err(|e| format!("Failed to open '{}': {e}", self.file_path))?;
|
||||
|
||||
let (position, line_text, truncated) = buffer.read_with(cx, |buffer, _cx| {
|
||||
let position = buffer.read_with(cx, |buffer, _cx| {
|
||||
let snapshot = buffer.snapshot();
|
||||
let row = line.saturating_sub(1);
|
||||
|
||||
@@ -177,7 +175,6 @@ impl SymbolLocator {
|
||||
}
|
||||
|
||||
let line_len = snapshot.line_len(row);
|
||||
let truncated = line_len as usize > MAX_LINE_DISPLAY_LEN;
|
||||
let line_start = Point::new(row, 0);
|
||||
let line_end = Point::new(row, line_len);
|
||||
let line_chars = || {
|
||||
@@ -198,22 +195,10 @@ impl SymbolLocator {
|
||||
)
|
||||
})?;
|
||||
|
||||
let position = snapshot.anchor_before(Point::new(row, byte_offset as u32));
|
||||
let display_text: String = line_chars()
|
||||
.skip_while(|c| c.is_whitespace())
|
||||
.take(MAX_LINE_DISPLAY_LEN)
|
||||
.collect::<String>();
|
||||
let display_text = display_text.trim_end().to_string();
|
||||
|
||||
Ok((position, display_text, truncated))
|
||||
Ok(snapshot.anchor_before(Point::new(row, byte_offset as u32)))
|
||||
})?;
|
||||
|
||||
Ok(ResolvedSymbol {
|
||||
buffer,
|
||||
position,
|
||||
line_text,
|
||||
truncated,
|
||||
})
|
||||
Ok(ResolvedSymbol { buffer, position })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -747,7 +747,6 @@ async fn run_terminal_tool(
|
||||
protected_paths,
|
||||
network: network_request_to_sandbox_network_access(&effective.network),
|
||||
allow_fs_write: effective.allow_fs_write_all,
|
||||
is_local: is_local_project,
|
||||
wsl_zed_release: wsl_zed_release.clone(),
|
||||
};
|
||||
|
||||
@@ -1035,11 +1034,9 @@ async fn run_terminal_tool(
|
||||
let output = terminal.current_output(cx).map_err(|e| e.to_string())?;
|
||||
|
||||
let result = process_content(output, &input.command, timed_out, user_stopped, selection);
|
||||
let notes = sandbox_note.into_iter().collect::<Vec<_>>();
|
||||
Ok(if notes.is_empty() {
|
||||
result
|
||||
} else {
|
||||
format!("{}\n\n{result}", notes.join("\n\n"))
|
||||
Ok(match sandbox_note {
|
||||
Some(note) => format!("{note}\n\n{result}"),
|
||||
None => result,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1122,9 +1119,7 @@ fn wsl_drive_mount_path_to_windows_path(raw: &str) -> Option<PathBuf> {
|
||||
}
|
||||
|
||||
let mut windows_path = format!("{drive}:\\");
|
||||
if !rest.is_empty() {
|
||||
windows_path.push_str(&rest.replace('/', "\\"));
|
||||
}
|
||||
windows_path.push_str(&rest.replace('/', "\\"));
|
||||
Some(PathBuf::from(windows_path))
|
||||
}
|
||||
|
||||
|
||||
@@ -350,20 +350,6 @@ pub fn authorize_symlink_escapes(
|
||||
event_stream.authorize_always_prompt(title, context, cx)
|
||||
}
|
||||
|
||||
/// Checks whether a path escapes the project via symlink, without creating
|
||||
/// an authorization task. Useful for pre-filtering paths before settings checks.
|
||||
pub fn path_has_symlink_escape(
|
||||
project: &Project,
|
||||
path: impl AsRef<Path>,
|
||||
canonical_worktree_roots: &[PathBuf],
|
||||
cx: &App,
|
||||
) -> bool {
|
||||
matches!(
|
||||
resolve_project_path(project, path, canonical_worktree_roots, cx),
|
||||
Ok(ResolvedProjectPath::SymlinkEscape { .. })
|
||||
)
|
||||
}
|
||||
|
||||
/// Collects symlink escape info for a path without creating an authorization task.
|
||||
/// Returns `Some((display_path, canonical_target))` if the path escapes via symlink.
|
||||
pub fn detect_symlink_escape<'a>(
|
||||
|
||||
@@ -22,7 +22,6 @@ use agent_client_protocol::{
|
||||
v2::schema as acp_v2,
|
||||
};
|
||||
use anyhow::anyhow;
|
||||
use async_channel;
|
||||
use collections::HashMap;
|
||||
use feature_flags::{AcpBetaFeatureFlag, FeatureFlagAppExt as _};
|
||||
use futures::channel::mpsc;
|
||||
|
||||
@@ -13,11 +13,7 @@ use indoc::indoc;
|
||||
use project::{FakeFs, Project};
|
||||
#[cfg(test)]
|
||||
use settings::Settings;
|
||||
use std::{
|
||||
path::{Path, PathBuf},
|
||||
sync::Arc,
|
||||
time::Duration,
|
||||
};
|
||||
use std::{path::Path, sync::Arc, time::Duration};
|
||||
use util::path;
|
||||
use util::path_list::PathList;
|
||||
|
||||
@@ -509,27 +505,6 @@ pub async fn run_until_first_tool_call(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_zed_path() -> PathBuf {
|
||||
let mut zed_path = std::env::current_exe().unwrap();
|
||||
|
||||
while zed_path
|
||||
.file_name()
|
||||
.is_none_or(|name| name.to_string_lossy() != "debug")
|
||||
{
|
||||
if !zed_path.pop() {
|
||||
panic!("Could not find target directory");
|
||||
}
|
||||
}
|
||||
|
||||
zed_path.push("zed");
|
||||
|
||||
if !zed_path.exists() {
|
||||
panic!("\n🚨 Run `cargo build` at least once before running e2e tests\n\n");
|
||||
}
|
||||
|
||||
zed_path
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@@ -1148,17 +1148,17 @@ impl Render for ConfigureContextServerModal {
|
||||
self.render_loading("Connecting Server…")
|
||||
}
|
||||
State::AuthRequired { server_id } => {
|
||||
self.render_auth_required(&server_id.clone(), cx)
|
||||
self.render_auth_required(server_id, cx)
|
||||
}
|
||||
State::ClientSecretRequired { server_id, error } => {
|
||||
self.render_client_secret_required(
|
||||
&server_id.clone(),
|
||||
server_id,
|
||||
error.clone(),
|
||||
cx,
|
||||
)
|
||||
}
|
||||
State::Authenticating { server_id } => {
|
||||
self.render_authenticating(&server_id.clone(), cx)
|
||||
self.render_authenticating(server_id, cx)
|
||||
}
|
||||
State::Error(error) => {
|
||||
Self::render_modal_error(error.clone())
|
||||
|
||||
@@ -726,7 +726,7 @@ impl Render for AgentDiffPane {
|
||||
.full_width()
|
||||
.key_binding(KeyBinding::for_action_in(
|
||||
&ToggleFocus,
|
||||
&focus_handle.clone(),
|
||||
focus_handle,
|
||||
cx,
|
||||
))
|
||||
.on_click(|_event, window, cx| {
|
||||
|
||||
@@ -3316,33 +3316,6 @@ impl AgentPanel {
|
||||
thread_id
|
||||
}
|
||||
|
||||
pub fn activate_retained_thread(
|
||||
&mut self,
|
||||
id: ThreadId,
|
||||
focus: bool,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
let conversation_view = if let Some(view) = self.remove_retained_thread(&id) {
|
||||
self.try_make_empty_draft_ephemeral(view.clone(), cx);
|
||||
view
|
||||
} else if let Some(draft) = &self.draft_thread {
|
||||
if draft.read(cx).thread_id == id {
|
||||
draft.clone()
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
};
|
||||
self.set_base_view(
|
||||
BaseView::AgentThread { conversation_view },
|
||||
focus,
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
}
|
||||
|
||||
pub fn active_thread_id(&self, cx: &App) -> Option<ThreadId> {
|
||||
match &self.base_view {
|
||||
BaseView::AgentThread { conversation_view } => {
|
||||
@@ -3950,7 +3923,7 @@ impl AgentPanel {
|
||||
|
||||
cx.spawn_in(window, async move |this, cx| {
|
||||
thread_store
|
||||
.update(&mut cx.clone(), |store, cx| {
|
||||
.update(cx, |store, cx| {
|
||||
store.save_thread(session_id.clone(), db_thread, Default::default(), cx)
|
||||
})
|
||||
.await?;
|
||||
|
||||
@@ -89,7 +89,6 @@ pub use thread_import::{
|
||||
AcpThreadImportOnboarding, CrossChannelImportOnboarding, ThreadImportModal,
|
||||
channels_with_threads, import_threads_from_other_channels,
|
||||
};
|
||||
use zed_actions;
|
||||
pub use zed_actions::agent::CycleFavoriteModels;
|
||||
pub use zed_actions::{CreateWorktree, NewWorktreeBranchTarget, SwitchWorktree};
|
||||
|
||||
|
||||
@@ -1311,7 +1311,6 @@ impl ConversationView {
|
||||
});
|
||||
});
|
||||
}
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
fn initial_state(
|
||||
@@ -1714,7 +1713,7 @@ impl ConversationView {
|
||||
let agent_display_name = self
|
||||
.agent_server_store
|
||||
.read(cx)
|
||||
.agent_display_name(&agent_id.clone())
|
||||
.agent_display_name(&agent_id)
|
||||
.unwrap_or_else(|| agent_id.0.clone());
|
||||
|
||||
let agent_icon = self.agent.logo();
|
||||
|
||||
@@ -2917,7 +2917,6 @@ impl ThreadView {
|
||||
message_editor.update(cx, |message_editor, cx| {
|
||||
message_editor.clear(window, cx);
|
||||
});
|
||||
cx.notify();
|
||||
})?;
|
||||
Ok(())
|
||||
})
|
||||
@@ -3298,7 +3297,6 @@ impl ThreadView {
|
||||
}
|
||||
self.set_editor_is_expanded(!self.editor_expanded, cx);
|
||||
cx.stop_propagation();
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
pub fn set_editor_is_expanded(&mut self, is_expanded: bool, cx: &mut Context<Self>) {
|
||||
@@ -5422,7 +5420,7 @@ impl ThreadView {
|
||||
this.tooltip(Tooltip::text(EDIT_NOT_READY_TOOLTIP_LABEL))
|
||||
})
|
||||
.key_binding(
|
||||
KeyBinding::for_action_in(&RejectAll, &focus_handle.clone(), cx)
|
||||
KeyBinding::for_action_in(&RejectAll, &focus_handle, cx)
|
||||
.map(|kb| kb.size(rems_from_px(12_f32))),
|
||||
)
|
||||
.on_click(cx.listener(move |this, _, window, cx| {
|
||||
@@ -5979,7 +5977,7 @@ impl ThreadView {
|
||||
this.key_binding(
|
||||
KeyBinding::for_action_in(
|
||||
action.as_ref(),
|
||||
&focus_handle.clone(),
|
||||
&focus_handle,
|
||||
cx,
|
||||
)
|
||||
.map(|kb| kb.size(keybinding_size)),
|
||||
@@ -8657,7 +8655,9 @@ impl ThreadView {
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if self.thread_search_bar.is_none() {
|
||||
let search_bar = if let Some(search_bar) = self.thread_search_bar.clone() {
|
||||
search_bar
|
||||
} else {
|
||||
let thread = self.thread.clone();
|
||||
let view = cx.entity().downgrade();
|
||||
let on_activate =
|
||||
@@ -8696,27 +8696,21 @@ impl ThreadView {
|
||||
}
|
||||
},
|
||||
));
|
||||
self.thread_search_bar = Some(search_bar);
|
||||
}
|
||||
self.thread_search_bar = Some(search_bar.clone());
|
||||
search_bar
|
||||
};
|
||||
|
||||
// Re-focus an open bar unless it already owns focus.
|
||||
let search_bar_focused = self
|
||||
.thread_search_bar
|
||||
.as_ref()
|
||||
.is_some_and(|bar| bar.focus_handle(cx).contains_focused(window, cx));
|
||||
let search_bar_focused = search_bar.focus_handle(cx).contains_focused(window, cx);
|
||||
|
||||
if self.thread_search_visible && search_bar_focused {
|
||||
if let Some(bar) = &self.thread_search_bar {
|
||||
bar.update(cx, |bar, cx| bar.clear_highlights(cx));
|
||||
}
|
||||
search_bar.update(cx, |bar, cx| bar.clear_highlights(cx));
|
||||
self.thread_search_visible = false;
|
||||
self.message_editor.focus_handle(cx).focus(window, cx);
|
||||
cx.notify();
|
||||
} else {
|
||||
self.thread_search_visible = true;
|
||||
if let Some(bar) = self.thread_search_bar.clone() {
|
||||
bar.update(cx, |bar, cx| bar.focus_and_refresh(window, cx));
|
||||
}
|
||||
search_bar.update(cx, |bar, cx| bar.focus_and_refresh(window, cx));
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
@@ -13437,7 +13431,6 @@ impl ThreadView {
|
||||
.on_click(cx.listener({
|
||||
move |this, _, _, cx| {
|
||||
this.clear_thread_error(cx);
|
||||
cx.notify();
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -808,13 +808,10 @@ mod tests {
|
||||
use fs::FakeFs;
|
||||
use gpui::TestAppContext;
|
||||
use project::Project;
|
||||
use prompt_store;
|
||||
use release_channel;
|
||||
use semver::Version;
|
||||
use serde_json::json;
|
||||
use settings::SettingsStore;
|
||||
use std::path::Path;
|
||||
use theme;
|
||||
use util::path;
|
||||
|
||||
fn init_test(cx: &mut TestAppContext) {
|
||||
|
||||
@@ -126,7 +126,9 @@ impl ProfileSelector {
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Entity<Picker<ProfilePickerDelegate>> {
|
||||
if self.picker.is_none() {
|
||||
let picker = if let Some(picker) = self.picker.clone() {
|
||||
picker
|
||||
} else {
|
||||
let delegate = ProfilePickerDelegate::new(
|
||||
self.fs.clone(),
|
||||
self.provider.clone(),
|
||||
@@ -143,24 +145,23 @@ impl ProfileSelector {
|
||||
.initial_width(rems(18.))
|
||||
});
|
||||
|
||||
self.picker = Some(picker);
|
||||
}
|
||||
self.picker = Some(picker.clone());
|
||||
picker
|
||||
};
|
||||
|
||||
if self.pending_refresh {
|
||||
if let Some(picker) = &self.picker {
|
||||
let profiles = AgentProfile::available_profiles(cx);
|
||||
self.profiles = profiles.clone();
|
||||
picker.update(cx, |picker, cx| {
|
||||
let query = picker.query(cx);
|
||||
picker
|
||||
.delegate
|
||||
.refresh_profiles(profiles.clone(), query, cx);
|
||||
});
|
||||
}
|
||||
let profiles = AgentProfile::available_profiles(cx);
|
||||
self.profiles = profiles.clone();
|
||||
picker.update(cx, |picker, cx| {
|
||||
let query = picker.query(cx);
|
||||
picker
|
||||
.delegate
|
||||
.refresh_profiles(profiles.clone(), query, cx);
|
||||
});
|
||||
self.pending_refresh = false;
|
||||
}
|
||||
|
||||
self.picker.as_ref().unwrap().clone()
|
||||
picker
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,15 +33,6 @@ pub fn set_stub_agent_connection(connection: StubAgentConnection) -> StubAgentCo
|
||||
connection
|
||||
}
|
||||
|
||||
/// Returns the shared `StubAgentConnection` used by `Agent::Stub`,
|
||||
/// creating a default one if none was registered.
|
||||
pub fn stub_agent_connection() -> StubAgentConnection {
|
||||
STUB_AGENT_CONNECTION.with(|cell| {
|
||||
let mut borrow = cell.borrow_mut();
|
||||
borrow.get_or_insert_with(StubAgentConnection::new).clone()
|
||||
})
|
||||
}
|
||||
|
||||
pub struct StubAgentServer<C> {
|
||||
connection: C,
|
||||
agent_id: AgentId,
|
||||
|
||||
@@ -933,23 +933,6 @@ impl ThreadMetadataStore {
|
||||
self.in_flight_archives.remove(&thread_id);
|
||||
}
|
||||
|
||||
/// Returns `true` if any unarchived thread other than `thread_id`
|
||||
/// references `path` in its folder paths. Used to determine whether a
|
||||
/// worktree can safely be removed from disk.
|
||||
pub fn path_is_referenced_by_unarchived_threads(
|
||||
&self,
|
||||
thread_id: Option<ThreadId>,
|
||||
path: &Path,
|
||||
remote_connection: Option<&RemoteConnectionOptions>,
|
||||
) -> bool {
|
||||
self.path_is_referenced_by_unarchived_threads_matching(
|
||||
thread_id,
|
||||
path,
|
||||
remote_connection,
|
||||
|_| true,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn path_is_referenced_by_unarchived_threads_matching(
|
||||
&self,
|
||||
thread_id: Option<ThreadId>,
|
||||
|
||||
@@ -1351,10 +1351,6 @@ impl ApiError {
|
||||
ApiErrorCode::from_str(&self.error_type).ok()
|
||||
}
|
||||
|
||||
pub fn is_rate_limit_error(&self) -> bool {
|
||||
matches!(self.error_type.as_str(), "rate_limit_error")
|
||||
}
|
||||
|
||||
pub fn match_window_exceeded(&self) -> Option<u64> {
|
||||
let Some(ApiErrorCode::InvalidRequestError) = self.code() else {
|
||||
return None;
|
||||
|
||||
@@ -54,7 +54,6 @@ pub(crate) struct Client {
|
||||
name: Arc<str>,
|
||||
subscription_set: Arc<Mutex<NotificationSubscriptionSet>>,
|
||||
response_handlers: Arc<Mutex<Option<HashMap<RequestId, ResponseHandler>>>>,
|
||||
#[allow(clippy::type_complexity)]
|
||||
#[allow(dead_code)]
|
||||
io_tasks: Mutex<Option<(Task<Option<()>>, Task<Option<()>>)>>,
|
||||
output_done_rx: Mutex<Option<barrier::Receiver>>,
|
||||
@@ -110,7 +109,6 @@ struct AnyResponse<'a> {
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[allow(dead_code)]
|
||||
pub(crate) struct Response<T> {
|
||||
pub jsonrpc: &'static str,
|
||||
pub id: RequestId,
|
||||
@@ -123,7 +121,6 @@ pub(crate) struct Response<T> {
|
||||
pub(crate) enum CspResult<T> {
|
||||
#[serde(rename = "result")]
|
||||
Ok(Option<T>),
|
||||
#[allow(dead_code)]
|
||||
Error(Option<Error>),
|
||||
}
|
||||
|
||||
|
||||
@@ -220,7 +220,7 @@ impl McpServer {
|
||||
Self::handle_call_tool(request_id, request.params, &tools, &outgoing_tx, cx)
|
||||
.await;
|
||||
} else if request.method == ListTools::METHOD {
|
||||
Self::handle_list_tools(request.id.unwrap(), &tools, &outgoing_tx);
|
||||
Self::handle_list_tools(request_id, &tools, &outgoing_tx);
|
||||
} else if let Some(handler) = handlers.borrow().get(&request.method.as_ref()) {
|
||||
let outgoing_tx = outgoing_tx.clone();
|
||||
|
||||
|
||||
@@ -699,16 +699,6 @@ pub enum CompletionTotal {
|
||||
Unknown,
|
||||
}
|
||||
|
||||
impl CompletionTotal {
|
||||
pub fn from_options(has_more: Option<bool>, total: Option<u32>) -> Self {
|
||||
match (has_more, total) {
|
||||
(_, Some(count)) => CompletionTotal::Exact(count),
|
||||
(Some(true), _) => CompletionTotal::HasMore,
|
||||
_ => CompletionTotal::Unknown,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Completion {
|
||||
pub values: Vec<String>,
|
||||
pub total: CompletionTotal,
|
||||
|
||||
@@ -1151,36 +1151,23 @@ impl Copilot {
|
||||
|
||||
futures::pin_mut!(nes_fut, inline_fut);
|
||||
|
||||
let mut nes_result: Option<Vec<CopilotEditPrediction>> = None;
|
||||
let mut inline_result: Option<Vec<CopilotEditPrediction>> = None;
|
||||
|
||||
loop {
|
||||
select_biased! {
|
||||
nes = nes_fut => {
|
||||
if !nes.is_empty() {
|
||||
return Ok(nes);
|
||||
}
|
||||
nes_result = Some(nes);
|
||||
}
|
||||
inline = inline_fut => {
|
||||
if !inline.is_empty() {
|
||||
return Ok(inline);
|
||||
}
|
||||
inline_result = Some(inline);
|
||||
}
|
||||
complete => break,
|
||||
}
|
||||
|
||||
if let (Some(nes), Some(inline)) = (&nes_result, &inline_result) {
|
||||
return if !nes.is_empty() {
|
||||
Ok(nes.clone())
|
||||
} else {
|
||||
Ok(inline.clone())
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Ok(nes_result.or(inline_result).unwrap_or_default())
|
||||
Ok(Vec::new())
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -751,7 +751,7 @@ mod tests {
|
||||
},
|
||||
}],
|
||||
);
|
||||
_ = editor.update_in(cx, |editor, window, cx| {
|
||||
editor.update_in(cx, |editor, window, cx| {
|
||||
// Ensure copilot suggestions are shown for the first excerpt.
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_ranges([Point::new(1, 5)..Point::new(1, 5)])
|
||||
@@ -759,7 +759,7 @@ mod tests {
|
||||
editor.show_edit_prediction(&Default::default(), window, cx);
|
||||
});
|
||||
executor.advance_clock(COPILOT_TEST_DEBOUNCE);
|
||||
_ = editor.update_in(cx, |editor, _, _| {
|
||||
editor.update_in(cx, |editor, _, _| {
|
||||
assert!(editor.has_active_edit_prediction());
|
||||
});
|
||||
pretty_assertions::assert_eq!(
|
||||
@@ -788,7 +788,7 @@ mod tests {
|
||||
},
|
||||
}],
|
||||
);
|
||||
_ = editor.update_in(cx, |editor, window, cx| {
|
||||
editor.update_in(cx, |editor, window, cx| {
|
||||
// Move to another excerpt, ensuring the suggestion gets cleared.
|
||||
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
|
||||
s.select_ranges([Point::new(4, 5)..Point::new(4, 5)])
|
||||
@@ -828,7 +828,7 @@ mod tests {
|
||||
|
||||
// Ensure the new suggestion is displayed when the debounce timeout expires.
|
||||
executor.advance_clock(COPILOT_TEST_DEBOUNCE);
|
||||
_ = editor.update(cx, |editor, _| {
|
||||
editor.update(cx, |editor, _| {
|
||||
assert!(editor.has_active_edit_prediction());
|
||||
});
|
||||
assert_eq!(
|
||||
|
||||
@@ -480,7 +480,7 @@ fn find_available_model(selected: &SelectedModel, cx: &gpui::App) -> Option<Lang
|
||||
model.provider_id() == selected.provider
|
||||
&& model_id_matches_selected(&model.provider_id(), &model.id(), &selected.model)
|
||||
})
|
||||
.max_by(|left, right| left.id().0.to_string().cmp(&right.id().0.to_string()))
|
||||
.max_by_key(|model| model.id())
|
||||
}
|
||||
|
||||
fn model_id_matches_selected(
|
||||
|
||||
@@ -30,7 +30,6 @@ image.workspace = true
|
||||
language_model_core.workspace = true
|
||||
log.workspace = true
|
||||
parking_lot.workspace = true
|
||||
serde_json.workspace = true
|
||||
thiserror.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
@@ -332,11 +332,3 @@ impl FakeProviderState {
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct ToolUseRequest {
|
||||
pub request: LanguageModelRequest,
|
||||
pub name: String,
|
||||
pub description: String,
|
||||
pub schema: serde_json::Value,
|
||||
}
|
||||
|
||||
@@ -547,12 +547,6 @@ impl Speed {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq)]
|
||||
pub struct LanguageModelResponseMessage {
|
||||
pub role: Option<Role>,
|
||||
pub content: Option<String>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@@ -1692,10 +1692,8 @@ impl MantleResponseEventMapper {
|
||||
// suffix.
|
||||
if snapshot.starts_with(&previous.text) && snapshot.len() > previous.text.len()
|
||||
{
|
||||
if let Some(current_message) = self.current_message.as_mut() {
|
||||
current_message.kind = MantleMessageSnapshotKind::Cumulative;
|
||||
current_message.emitted_text_length = previous.text.len();
|
||||
}
|
||||
current_message.kind = MantleMessageSnapshotKind::Cumulative;
|
||||
current_message.emitted_text_length = previous.text.len();
|
||||
let mut events = Vec::new();
|
||||
self.flush_pending_message(&mut events, true);
|
||||
events.extend(self.map_snapshot_suffix(output_index, content_index));
|
||||
@@ -1713,9 +1711,7 @@ impl MantleResponseEventMapper {
|
||||
|
||||
// Diverged from the previous message, had a different phase, or there
|
||||
// was no previous message: this is an independent message.
|
||||
if let Some(current_message) = self.current_message.as_mut() {
|
||||
current_message.kind = MantleMessageSnapshotKind::Independent;
|
||||
}
|
||||
current_message.kind = MantleMessageSnapshotKind::Independent;
|
||||
let mut events = Vec::new();
|
||||
self.flush_pending_message(&mut events, false);
|
||||
events.extend(self.map_text_event(item_id, output_index, content_index, snapshot));
|
||||
|
||||
@@ -241,7 +241,7 @@ impl CloudLanguageModelProvider {
|
||||
let maintain_client_status = cx.spawn(async move |cx| {
|
||||
while let Some(status) = status_rx.next().await {
|
||||
if let Some(this) = state_ref.upgrade() {
|
||||
_ = this.update(cx, |this, cx| {
|
||||
this.update(cx, |this, cx| {
|
||||
if this.status != status {
|
||||
this.status = status;
|
||||
if status.is_signed_out() {
|
||||
|
||||
@@ -70,10 +70,10 @@ impl State {
|
||||
);
|
||||
|
||||
cx.spawn(async move |this, cx| {
|
||||
let result = task.await?;
|
||||
task.await?;
|
||||
this.update(cx, |this, cx| this.restart_fetch_models_task(cx))
|
||||
.ok();
|
||||
Ok(result)
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,6 @@ pub enum ToolChoice {
|
||||
#[derive(Clone, Deserialize, Serialize, Debug)]
|
||||
#[serde(tag = "type", rename_all = "snake_case")]
|
||||
pub enum ToolDefinition {
|
||||
#[allow(dead_code)]
|
||||
Function { function: FunctionDefinition },
|
||||
}
|
||||
|
||||
|
||||
@@ -177,14 +177,6 @@ pub struct LocalModelListing {
|
||||
pub details: ModelDetails,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct LocalModel {
|
||||
pub modelfile: String,
|
||||
pub parameters: String,
|
||||
pub template: String,
|
||||
pub details: ModelDetails,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct ModelDetails {
|
||||
pub format: String,
|
||||
|
||||
@@ -815,7 +815,6 @@ pub enum ToolChoice {
|
||||
#[derive(Clone, Deserialize, Serialize, Debug)]
|
||||
#[serde(tag = "type", rename_all = "snake_case")]
|
||||
pub enum ToolDefinition {
|
||||
#[allow(dead_code)]
|
||||
Function { function: FunctionDefinition },
|
||||
}
|
||||
|
||||
|
||||
@@ -203,7 +203,6 @@ pub enum ToolChoice {
|
||||
#[derive(Clone, Deserialize, Serialize, Debug)]
|
||||
#[serde(tag = "type", rename_all = "snake_case")]
|
||||
pub enum ToolDefinition {
|
||||
#[allow(dead_code)]
|
||||
Function { function: FunctionDefinition },
|
||||
}
|
||||
|
||||
@@ -305,39 +304,6 @@ impl From<&str> for MessageContent {
|
||||
}
|
||||
}
|
||||
|
||||
impl MessageContent {
|
||||
pub fn as_text(&self) -> Option<&str> {
|
||||
match self {
|
||||
Self::Plain(text) => Some(text),
|
||||
Self::Multipart(parts) if parts.len() == 1 => {
|
||||
if let MessagePart::Text { text, .. } = &parts[0] {
|
||||
Some(text)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_text(&self) -> String {
|
||||
match self {
|
||||
Self::Plain(text) => text.clone(),
|
||||
Self::Multipart(parts) => parts
|
||||
.iter()
|
||||
.filter_map(|part| {
|
||||
if let MessagePart::Text { text, .. } = part {
|
||||
Some(text.as_str())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.concat(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Copy, Clone, Eq, PartialEq)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum CacheControlType {
|
||||
|
||||
@@ -111,10 +111,6 @@ impl PromptId {
|
||||
Self::BuiltIn(builtin) => Some(*builtin),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_built_in(&self) -> bool {
|
||||
matches!(self, Self::BuiltIn { .. })
|
||||
}
|
||||
}
|
||||
|
||||
impl From<BuiltInPrompt> for PromptId {
|
||||
|
||||
@@ -45,11 +45,6 @@ impl WebSearchRegistry {
|
||||
self.active_provider.clone()
|
||||
}
|
||||
|
||||
pub fn set_active_provider(&mut self, provider: Arc<dyn WebSearchProvider>) {
|
||||
self.active_provider = Some(provider.clone());
|
||||
self.providers.insert(provider.id(), provider);
|
||||
}
|
||||
|
||||
pub fn register_provider<T: WebSearchProvider + 'static>(
|
||||
&mut self,
|
||||
provider: T,
|
||||
|
||||
@@ -29,9 +29,6 @@ impl Global for ZedCredentialsProvider {}
|
||||
|
||||
/// Returns the global [`CredentialsProvider`].
|
||||
pub fn init_global(cx: &mut App) {
|
||||
// The `CredentialsProvider` trait has `Send + Sync` bounds on it, so it
|
||||
// seems like this is a false positive from Clippy.
|
||||
#[allow(clippy::arc_with_non_send_sync)]
|
||||
let provider = new(cx);
|
||||
cx.set_global(ZedCredentialsProvider(provider));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user