Compare commits
11 Commits
fix-copilo
...
windows-ho
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b95099056 | ||
|
|
d490443286 | ||
|
|
1f9d5ef684 | ||
|
|
83f0a3fd13 | ||
|
|
7ecbf8cf60 | ||
|
|
fb0fcd86fd | ||
|
|
36708c910a | ||
|
|
388fda2292 | ||
|
|
94f9b85859 | ||
|
|
1c072017a4 | ||
|
|
8a992703a7 |
@@ -96,9 +96,9 @@
|
||||
"terminal.ansi.bright_white": "#fafafaff",
|
||||
"terminal.ansi.dim_white": "#575d65ff",
|
||||
"link_text.hover": "#74ade8ff",
|
||||
"version_control.added": "#27a657ff",
|
||||
"version_control.added": "#2EA048ff",
|
||||
"version_control.modified": "#d3b020ff",
|
||||
"version_control.deleted": "#e06c76ff",
|
||||
"version_control.deleted": "#78081Bff",
|
||||
"version_control.conflict_marker.ours": "#a1c1811a",
|
||||
"version_control.conflict_marker.theirs": "#74ade81a",
|
||||
"conflict": "#dec184ff",
|
||||
@@ -497,9 +497,9 @@
|
||||
"terminal.ansi.bright_white": "#ffffffff",
|
||||
"terminal.ansi.dim_white": "#aaaaaaff",
|
||||
"link_text.hover": "#5c78e2ff",
|
||||
"version_control.added": "#27a657ff",
|
||||
"version_control.added": "#2EA048ff",
|
||||
"version_control.modified": "#d3b020ff",
|
||||
"version_control.deleted": "#e06c76ff",
|
||||
"version_control.deleted": "#F85149ff",
|
||||
"conflict": "#a48819ff",
|
||||
"conflict.background": "#faf2e6ff",
|
||||
"conflict.border": "#f4e7d1ff",
|
||||
|
||||
@@ -823,10 +823,6 @@ async fn stream_completion(
|
||||
let is_streaming = request.stream;
|
||||
|
||||
let json = serde_json::to_string(&request)?;
|
||||
eprintln!(
|
||||
"Copilot chat completion request to {}: {}",
|
||||
completion_url, json
|
||||
);
|
||||
let request = request_builder.body(AsyncBody::from(json))?;
|
||||
let mut response = client.send(request).await?;
|
||||
|
||||
@@ -834,11 +830,6 @@ async fn stream_completion(
|
||||
let mut body = Vec::new();
|
||||
response.body_mut().read_to_end(&mut body).await?;
|
||||
let body_str = std::str::from_utf8(&body)?;
|
||||
eprintln!(
|
||||
"Copilot chat completion HTTP error: status={}, response_body={}",
|
||||
response.status(),
|
||||
body_str
|
||||
);
|
||||
anyhow::bail!(
|
||||
"Failed to connect to API: {} {}",
|
||||
response.status(),
|
||||
@@ -846,11 +837,6 @@ async fn stream_completion(
|
||||
);
|
||||
}
|
||||
|
||||
eprintln!(
|
||||
"Copilot chat completion response status: {}",
|
||||
response.status()
|
||||
);
|
||||
|
||||
if is_streaming {
|
||||
let reader = BufReader::new(response.into_body());
|
||||
Ok(reader
|
||||
@@ -858,7 +844,6 @@ async fn stream_completion(
|
||||
.filter_map(|line| async move {
|
||||
match line {
|
||||
Ok(line) => {
|
||||
eprintln!("Copilot chat completion stream line: {}", line);
|
||||
let line = line.strip_prefix("data: ")?;
|
||||
if line.starts_with("[DONE]") {
|
||||
return None;
|
||||
@@ -872,14 +857,7 @@ async fn stream_completion(
|
||||
Some(Ok(response))
|
||||
}
|
||||
}
|
||||
Err(error) => {
|
||||
eprintln!(
|
||||
"Failed to parse Copilot chat completion stream event: {}\nLine: {}",
|
||||
error,
|
||||
line
|
||||
);
|
||||
Some(Err(anyhow!(error)))
|
||||
}
|
||||
Err(error) => Some(Err(anyhow!(error))),
|
||||
}
|
||||
}
|
||||
Err(error) => Some(Err(anyhow!(error))),
|
||||
@@ -890,10 +868,6 @@ async fn stream_completion(
|
||||
let mut body = Vec::new();
|
||||
response.body_mut().read_to_end(&mut body).await?;
|
||||
let body_str = std::str::from_utf8(&body)?;
|
||||
eprintln!(
|
||||
"Copilot chat completion non-streaming response body: {}",
|
||||
body_str
|
||||
);
|
||||
let response: ResponseEvent = serde_json::from_str(body_str)?;
|
||||
|
||||
Ok(futures::stream::once(async move { Ok(response) }).boxed())
|
||||
|
||||
@@ -314,23 +314,15 @@ pub async fn stream_response(
|
||||
|
||||
let is_streaming = request.stream;
|
||||
let json = serde_json::to_string(&request)?;
|
||||
eprintln!("Copilot responses request to {}: {}", api_url, json);
|
||||
let request = request_builder.body(AsyncBody::from(json))?;
|
||||
let mut response = client.send(request).await?;
|
||||
|
||||
if !response.status().is_success() {
|
||||
let mut body = String::new();
|
||||
response.body_mut().read_to_string(&mut body).await?;
|
||||
eprintln!(
|
||||
"Copilot responses HTTP error: status={}, response_body={}",
|
||||
response.status(),
|
||||
body
|
||||
);
|
||||
anyhow::bail!("Failed to connect to API: {} {}", response.status(), body);
|
||||
}
|
||||
|
||||
eprintln!("Copilot responses response status: {}", response.status());
|
||||
|
||||
if is_streaming {
|
||||
let reader = BufReader::new(response.into_body());
|
||||
Ok(reader
|
||||
@@ -338,7 +330,6 @@ pub async fn stream_response(
|
||||
.filter_map(|line| async move {
|
||||
match line {
|
||||
Ok(line) => {
|
||||
eprintln!("Copilot responses stream line: {}", line);
|
||||
let line = line.strip_prefix("data: ")?;
|
||||
if line.starts_with("[DONE]") || line.is_empty() {
|
||||
return None;
|
||||
@@ -365,7 +356,6 @@ pub async fn stream_response(
|
||||
// Removes the need of having a method to map StreamEvent and another to map Response to a LanguageCompletionEvent
|
||||
let mut body = String::new();
|
||||
response.body_mut().read_to_string(&mut body).await?;
|
||||
eprintln!("Copilot responses non-streaming response body: {}", body);
|
||||
|
||||
match serde_json::from_str::<Response>(&body) {
|
||||
Ok(response) => {
|
||||
|
||||
@@ -239,6 +239,89 @@ async fn test_fuzzy_over_sort_positions(cx: &mut TestAppContext) {
|
||||
assert_eq!(matches[2].string, "fetch_code_lens");
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_semver_label_sort_by_latest_version(cx: &mut TestAppContext) {
|
||||
let mut versions = [
|
||||
"10.4.112",
|
||||
"10.4.22",
|
||||
"10.4.2",
|
||||
"10.4.20",
|
||||
"10.4.21",
|
||||
"10.4.12",
|
||||
// Pre-release versions
|
||||
"10.4.22-alpha",
|
||||
"10.4.22-beta.1",
|
||||
"10.4.22-rc.1",
|
||||
// Build metadata versions
|
||||
"10.4.21+build.123",
|
||||
"10.4.20+20210327",
|
||||
];
|
||||
versions.sort_by(|a, b| {
|
||||
match (
|
||||
semver::Version::parse(a).ok(),
|
||||
semver::Version::parse(b).ok(),
|
||||
) {
|
||||
(Some(a_ver), Some(b_ver)) => b_ver.cmp(&a_ver),
|
||||
_ => std::cmp::Ordering::Equal,
|
||||
}
|
||||
});
|
||||
let completions: Vec<_> = versions
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, version)| {
|
||||
// This sort text would come from the LSP
|
||||
let sort_text = format!("{:08}", i);
|
||||
CompletionBuilder::new(version, None, &sort_text, None)
|
||||
})
|
||||
.collect();
|
||||
|
||||
// Case 1: User types just the major and minor version
|
||||
let matches =
|
||||
filter_and_sort_matches("10.4.", &completions, SnippetSortOrder::default(), cx).await;
|
||||
// Versions are ordered by recency (latest first)
|
||||
let expected_versions = [
|
||||
"10.4.112",
|
||||
"10.4.22",
|
||||
"10.4.22-rc.1",
|
||||
"10.4.22-beta.1",
|
||||
"10.4.22-alpha",
|
||||
"10.4.21+build.123",
|
||||
"10.4.21",
|
||||
"10.4.20+20210327",
|
||||
"10.4.20",
|
||||
"10.4.12",
|
||||
"10.4.2",
|
||||
];
|
||||
for (match_item, expected) in matches.iter().zip(expected_versions.iter()) {
|
||||
assert_eq!(match_item.string.as_ref() as &str, *expected);
|
||||
}
|
||||
|
||||
// Case 2: User types the major, minor, and patch version
|
||||
let matches =
|
||||
filter_and_sort_matches("10.4.2", &completions, SnippetSortOrder::default(), cx).await;
|
||||
let expected_versions = [
|
||||
// Exact match comes first
|
||||
"10.4.2",
|
||||
// Ordered by recency with exact major, minor, and patch versions
|
||||
"10.4.22",
|
||||
"10.4.22-rc.1",
|
||||
"10.4.22-beta.1",
|
||||
"10.4.22-alpha",
|
||||
"10.4.21+build.123",
|
||||
"10.4.21",
|
||||
"10.4.20+20210327",
|
||||
"10.4.20",
|
||||
// Versions with non-exact patch versions are ordered by fuzzy score
|
||||
// Higher fuzzy score than 112 patch version since "2" appears before "1"
|
||||
// in "12", making it rank higher than "112"
|
||||
"10.4.12",
|
||||
"10.4.112",
|
||||
];
|
||||
for (match_item, expected) in matches.iter().zip(expected_versions.iter()) {
|
||||
assert_eq!(match_item.string.as_ref() as &str, *expected);
|
||||
}
|
||||
}
|
||||
|
||||
async fn test_for_each_prefix<F>(
|
||||
target: &str,
|
||||
completions: &Vec<Completion>,
|
||||
@@ -259,30 +342,55 @@ struct CompletionBuilder;
|
||||
|
||||
impl CompletionBuilder {
|
||||
fn constant(label: &str, filter_text: Option<&str>, sort_text: &str) -> Completion {
|
||||
Self::new(label, filter_text, sort_text, CompletionItemKind::CONSTANT)
|
||||
Self::new(
|
||||
label,
|
||||
filter_text,
|
||||
sort_text,
|
||||
Some(CompletionItemKind::CONSTANT),
|
||||
)
|
||||
}
|
||||
|
||||
fn function(label: &str, filter_text: Option<&str>, sort_text: &str) -> Completion {
|
||||
Self::new(label, filter_text, sort_text, CompletionItemKind::FUNCTION)
|
||||
Self::new(
|
||||
label,
|
||||
filter_text,
|
||||
sort_text,
|
||||
Some(CompletionItemKind::FUNCTION),
|
||||
)
|
||||
}
|
||||
|
||||
fn method(label: &str, filter_text: Option<&str>, sort_text: &str) -> Completion {
|
||||
Self::new(label, filter_text, sort_text, CompletionItemKind::METHOD)
|
||||
Self::new(
|
||||
label,
|
||||
filter_text,
|
||||
sort_text,
|
||||
Some(CompletionItemKind::METHOD),
|
||||
)
|
||||
}
|
||||
|
||||
fn variable(label: &str, filter_text: Option<&str>, sort_text: &str) -> Completion {
|
||||
Self::new(label, filter_text, sort_text, CompletionItemKind::VARIABLE)
|
||||
Self::new(
|
||||
label,
|
||||
filter_text,
|
||||
sort_text,
|
||||
Some(CompletionItemKind::VARIABLE),
|
||||
)
|
||||
}
|
||||
|
||||
fn snippet(label: &str, filter_text: Option<&str>, sort_text: &str) -> Completion {
|
||||
Self::new(label, filter_text, sort_text, CompletionItemKind::SNIPPET)
|
||||
Self::new(
|
||||
label,
|
||||
filter_text,
|
||||
sort_text,
|
||||
Some(CompletionItemKind::SNIPPET),
|
||||
)
|
||||
}
|
||||
|
||||
fn new(
|
||||
label: &str,
|
||||
filter_text: Option<&str>,
|
||||
sort_text: &str,
|
||||
kind: CompletionItemKind,
|
||||
kind: Option<CompletionItemKind>,
|
||||
) -> Completion {
|
||||
Completion {
|
||||
replace_range: Anchor::MIN..Anchor::MAX,
|
||||
@@ -294,7 +402,7 @@ impl CompletionBuilder {
|
||||
server_id: LanguageServerId(0),
|
||||
lsp_completion: Box::new(CompletionItem {
|
||||
label: label.to_string(),
|
||||
kind: Some(kind),
|
||||
kind: kind,
|
||||
sort_text: Some(sort_text.to_string()),
|
||||
filter_text: filter_text.map(|text| text.to_string()),
|
||||
..Default::default()
|
||||
|
||||
@@ -457,7 +457,9 @@ pub fn map_to_language_model_completion_events(
|
||||
)));
|
||||
}
|
||||
Some("tool_calls") => {
|
||||
// Emit reasoning details if we have them (e.g. for Gemini 3)
|
||||
// Gemini 3 models send reasoning_opaque/reasoning_text that must
|
||||
// be preserved and sent back in subsequent requests. Emit as
|
||||
// ReasoningDetails so the agent stores it in the message.
|
||||
if state.reasoning_opaque.is_some()
|
||||
|| state.reasoning_text.is_some()
|
||||
{
|
||||
|
||||
@@ -340,11 +340,11 @@ impl LspLogView {
|
||||
* Configuration: {CONFIGURATION}",
|
||||
NAME = info.status.name,
|
||||
ID = info.id,
|
||||
BINARY = info.status.binary.as_ref().map_or_else(
|
||||
|| "Unknown".to_string(),
|
||||
|binary| serde_json::to_string_pretty(binary)
|
||||
.unwrap_or_else(|e| format!("Failed to serialize binary info: {e:#}"))
|
||||
),
|
||||
BINARY = info
|
||||
.status
|
||||
.binary
|
||||
.as_ref()
|
||||
.map_or_else(|| "Unknown".to_string(), |binary| format!("{:#?}", binary)),
|
||||
WORKSPACE_FOLDERS = info
|
||||
.status
|
||||
.workspace_folders
|
||||
|
||||
@@ -11,5 +11,6 @@ brackets = [
|
||||
tab_size = 2
|
||||
prettier_parser_name = "json"
|
||||
debuggers = ["JavaScript"]
|
||||
|
||||
[overrides.string]
|
||||
completion_query_characters = [":", " "]
|
||||
completion_query_characters = [":", " ", "."]
|
||||
|
||||
@@ -199,12 +199,12 @@ impl ContextServerStore {
|
||||
)
|
||||
}
|
||||
|
||||
/// Returns all configured context server ids, regardless of enabled state.
|
||||
/// Returns all configured context server ids, excluding the ones that are disabled
|
||||
pub fn configured_server_ids(&self) -> Vec<ContextServerId> {
|
||||
self.context_server_settings
|
||||
.keys()
|
||||
.cloned()
|
||||
.map(ContextServerId)
|
||||
.iter()
|
||||
.filter(|(_, settings)| settings.enabled())
|
||||
.map(|(id, _)| ContextServerId(id.clone()))
|
||||
.collect()
|
||||
}
|
||||
|
||||
|
||||
@@ -680,13 +680,60 @@ impl GitStore {
|
||||
})
|
||||
}
|
||||
|
||||
fn load_diff_bases(
|
||||
&mut self,
|
||||
buffer: Entity<Buffer>,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Task<Result<DiffBasesChange>> {
|
||||
let buffer_id = buffer.read(cx).remote_id();
|
||||
match &self.state {
|
||||
GitStoreState::Local { .. } => {
|
||||
let Some((repo, repo_path)) =
|
||||
self.repository_and_path_for_buffer_id(buffer.read(cx).remote_id(), cx)
|
||||
else {
|
||||
return Task::ready(Err(anyhow!("failed to find git repository for buffer")));
|
||||
};
|
||||
repo.update(cx, |repo, cx| {
|
||||
repo.load_committed_text(buffer_id, repo_path, cx)
|
||||
})
|
||||
}
|
||||
GitStoreState::Remote {
|
||||
upstream_client,
|
||||
upstream_project_id,
|
||||
..
|
||||
} => cx.background_spawn({
|
||||
let upstream_client = upstream_client.clone();
|
||||
let upstream_project_id = *upstream_project_id;
|
||||
|
||||
async move {
|
||||
use proto::open_uncommitted_diff_response::Mode;
|
||||
|
||||
let response = upstream_client
|
||||
.request(proto::OpenUncommittedDiff {
|
||||
project_id: upstream_project_id,
|
||||
buffer_id: buffer_id.to_proto(),
|
||||
})
|
||||
.await?;
|
||||
let mode = Mode::from_i32(response.mode).context("Invalid mode")?;
|
||||
let bases = match mode {
|
||||
Mode::IndexMatchesHead => DiffBasesChange::SetBoth(response.committed_text),
|
||||
Mode::IndexAndHead => DiffBasesChange::SetEach {
|
||||
head: response.committed_text,
|
||||
index: response.staged_text,
|
||||
},
|
||||
};
|
||||
Ok(bases)
|
||||
}
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn open_uncommitted_diff(
|
||||
&mut self,
|
||||
buffer: Entity<Buffer>,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Task<Result<Entity<BufferDiff>>> {
|
||||
let buffer_id = buffer.read(cx).remote_id();
|
||||
|
||||
if let Some(diff_state) = self.diffs.get(&buffer_id)
|
||||
&& let Some(uncommitted_diff) = diff_state
|
||||
.read(cx)
|
||||
@@ -705,20 +752,11 @@ impl GitStore {
|
||||
return Task::ready(Ok(uncommitted_diff));
|
||||
}
|
||||
|
||||
let Some((repo, repo_path)) =
|
||||
self.repository_and_path_for_buffer_id(buffer.read(cx).remote_id(), cx)
|
||||
else {
|
||||
return Task::ready(Err(anyhow!("failed to find git repository for buffer")));
|
||||
};
|
||||
|
||||
let changes = self.load_diff_bases(buffer.clone(), cx);
|
||||
let task = self
|
||||
.loading_diffs
|
||||
.entry((buffer_id, DiffKind::Uncommitted))
|
||||
.or_insert_with(|| {
|
||||
let changes = repo.update(cx, |repo, cx| {
|
||||
repo.load_committed_text(buffer_id, repo_path, cx)
|
||||
});
|
||||
|
||||
// todo(lw): hot foreground spawn
|
||||
cx.spawn(async move |this, cx| {
|
||||
Self::open_diff_internal(this, DiffKind::Uncommitted, changes.await, buffer, cx)
|
||||
@@ -728,7 +766,6 @@ impl GitStore {
|
||||
.shared()
|
||||
})
|
||||
.clone();
|
||||
|
||||
cx.background_spawn(async move { task.await.map_err(|e| anyhow!("{e}")) })
|
||||
}
|
||||
|
||||
@@ -1401,36 +1438,22 @@ impl GitStore {
|
||||
// repository. In that case, we'll want to update the buffer's
|
||||
// `BufferDiffState`, in case it already has one.
|
||||
let buffer_id = buffer.read(cx).remote_id();
|
||||
let diff_state = self.diffs.get(&buffer_id);
|
||||
let repo = self.repository_and_path_for_buffer_id(buffer_id, cx);
|
||||
|
||||
if let Some(diff_state) = diff_state
|
||||
&& let Some((repo, repo_path)) = repo
|
||||
{
|
||||
let buffer = buffer.clone();
|
||||
let diff_state = diff_state.clone();
|
||||
|
||||
cx.spawn(async move |_git_store, cx| {
|
||||
async {
|
||||
let diff_bases_change = repo
|
||||
.update(cx, |repo, cx| {
|
||||
repo.load_committed_text(buffer_id, repo_path, cx)
|
||||
})?
|
||||
.await?;
|
||||
|
||||
diff_state.update(cx, |diff_state, cx| {
|
||||
let buffer_snapshot = buffer.read(cx).text_snapshot();
|
||||
diff_state.diff_bases_changed(
|
||||
buffer_snapshot,
|
||||
Some(diff_bases_change),
|
||||
cx,
|
||||
);
|
||||
})
|
||||
}
|
||||
.await
|
||||
.log_err();
|
||||
})
|
||||
.detach();
|
||||
if let Some(diff_state) = self.diffs.get(&buffer_id) {
|
||||
let diff_state = diff_state.downgrade();
|
||||
let diff_bases = self.load_diff_bases(buffer.clone(), cx);
|
||||
let buffer = buffer.downgrade();
|
||||
cx.spawn(async move |_, cx| {
|
||||
let diff_bases_change = diff_bases.await?;
|
||||
let buffer = buffer.upgrade().context("buffer dropped")?;
|
||||
diff_state.update(cx, |diff_state, cx| {
|
||||
let buffer_snapshot = buffer.read(cx).text_snapshot();
|
||||
diff_state.diff_bases_changed(
|
||||
buffer_snapshot,
|
||||
Some(diff_bases_change),
|
||||
cx,
|
||||
);
|
||||
})
|
||||
}).detach();
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
||||
@@ -649,9 +649,10 @@ impl TerminalView {
|
||||
// When focused, check blinking settings and blink manager state
|
||||
match TerminalSettings::get_global(cx).blinking {
|
||||
TerminalBlink::Off => true,
|
||||
TerminalBlink::On | TerminalBlink::TerminalControlled => {
|
||||
self.blink_manager.read(cx).visible()
|
||||
TerminalBlink::TerminalControlled => {
|
||||
!self.blinking_terminal_enabled || self.blink_manager.read(cx).visible()
|
||||
}
|
||||
TerminalBlink::On => self.blink_manager.read(cx).visible(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ impl EditPredictionProvider for ZetaEditPredictionProvider {
|
||||
) -> bool {
|
||||
let zeta = self.zeta.read(cx);
|
||||
if zeta.edit_prediction_model == ZetaEditPredictionModel::Sweep {
|
||||
zeta.sweep_api_token.is_some()
|
||||
zeta.sweep_ai.api_token.is_some()
|
||||
} else {
|
||||
true
|
||||
}
|
||||
|
||||
@@ -1,10 +1,269 @@
|
||||
use std::fmt;
|
||||
use std::{path::Path, sync::Arc};
|
||||
|
||||
use anyhow::{Context as _, Result};
|
||||
use cloud_llm_client::predict_edits_v3::Event;
|
||||
use futures::AsyncReadExt as _;
|
||||
use gpui::{
|
||||
App, AppContext as _, Entity, Task,
|
||||
http_client::{self, AsyncBody, Method},
|
||||
};
|
||||
use language::{Buffer, BufferSnapshot, Point, ToOffset as _, ToPoint as _};
|
||||
use lsp::DiagnosticSeverity;
|
||||
use project::{Project, ProjectPath};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
collections::VecDeque,
|
||||
fmt::{self, Write as _},
|
||||
ops::Range,
|
||||
path::Path,
|
||||
sync::Arc,
|
||||
time::Instant,
|
||||
};
|
||||
use util::ResultExt as _;
|
||||
|
||||
use crate::{EditPrediction, EditPredictionId, EditPredictionInputs};
|
||||
|
||||
const SWEEP_API_URL: &str = "https://autocomplete.sweep.dev/backend/next_edit_autocomplete";
|
||||
|
||||
pub struct SweepAi {
|
||||
pub api_token: Option<String>,
|
||||
pub debug_info: Arc<str>,
|
||||
}
|
||||
|
||||
impl SweepAi {
|
||||
pub fn new(cx: &App) -> Self {
|
||||
SweepAi {
|
||||
api_token: std::env::var("SWEEP_AI_TOKEN")
|
||||
.context("No SWEEP_AI_TOKEN environment variable set")
|
||||
.log_err(),
|
||||
debug_info: debug_info(cx),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn request_prediction_with_sweep(
|
||||
&self,
|
||||
project: &Entity<Project>,
|
||||
active_buffer: &Entity<Buffer>,
|
||||
snapshot: BufferSnapshot,
|
||||
position: language::Anchor,
|
||||
events: Vec<Arc<Event>>,
|
||||
recent_paths: &VecDeque<ProjectPath>,
|
||||
diagnostic_search_range: Range<Point>,
|
||||
cx: &mut App,
|
||||
) -> Task<Result<Option<EditPrediction>>> {
|
||||
let debug_info = self.debug_info.clone();
|
||||
let Some(api_token) = self.api_token.clone() else {
|
||||
return Task::ready(Ok(None));
|
||||
};
|
||||
let full_path: Arc<Path> = snapshot
|
||||
.file()
|
||||
.map(|file| file.full_path(cx))
|
||||
.unwrap_or_else(|| "untitled".into())
|
||||
.into();
|
||||
|
||||
let project_file = project::File::from_dyn(snapshot.file());
|
||||
let repo_name = project_file
|
||||
.map(|file| file.worktree.read(cx).root_name_str())
|
||||
.unwrap_or("untitled")
|
||||
.into();
|
||||
let offset = position.to_offset(&snapshot);
|
||||
|
||||
let recent_buffers = recent_paths.iter().cloned();
|
||||
let http_client = cx.http_client();
|
||||
|
||||
let recent_buffer_snapshots = recent_buffers
|
||||
.filter_map(|project_path| {
|
||||
let buffer = project.read(cx).get_open_buffer(&project_path, cx)?;
|
||||
if active_buffer == &buffer {
|
||||
None
|
||||
} else {
|
||||
Some(buffer.read(cx).snapshot())
|
||||
}
|
||||
})
|
||||
.take(3)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let cursor_point = position.to_point(&snapshot);
|
||||
let buffer_snapshotted_at = Instant::now();
|
||||
|
||||
let result = cx.background_spawn(async move {
|
||||
let text = snapshot.text();
|
||||
|
||||
let mut recent_changes = String::new();
|
||||
for event in &events {
|
||||
write_event(event.as_ref(), &mut recent_changes).unwrap();
|
||||
}
|
||||
|
||||
let mut file_chunks = recent_buffer_snapshots
|
||||
.into_iter()
|
||||
.map(|snapshot| {
|
||||
let end_point = Point::new(30, 0).min(snapshot.max_point());
|
||||
FileChunk {
|
||||
content: snapshot.text_for_range(Point::zero()..end_point).collect(),
|
||||
file_path: snapshot
|
||||
.file()
|
||||
.map(|f| f.path().as_unix_str())
|
||||
.unwrap_or("untitled")
|
||||
.to_string(),
|
||||
start_line: 0,
|
||||
end_line: end_point.row as usize,
|
||||
timestamp: snapshot.file().and_then(|file| {
|
||||
Some(
|
||||
file.disk_state()
|
||||
.mtime()?
|
||||
.to_seconds_and_nanos_for_persistence()?
|
||||
.0,
|
||||
)
|
||||
}),
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let diagnostic_entries = snapshot.diagnostics_in_range(diagnostic_search_range, false);
|
||||
let mut diagnostic_content = String::new();
|
||||
let mut diagnostic_count = 0;
|
||||
|
||||
for entry in diagnostic_entries {
|
||||
let start_point: Point = entry.range.start;
|
||||
|
||||
let severity = match entry.diagnostic.severity {
|
||||
DiagnosticSeverity::ERROR => "error",
|
||||
DiagnosticSeverity::WARNING => "warning",
|
||||
DiagnosticSeverity::INFORMATION => "info",
|
||||
DiagnosticSeverity::HINT => "hint",
|
||||
_ => continue,
|
||||
};
|
||||
|
||||
diagnostic_count += 1;
|
||||
|
||||
writeln!(
|
||||
&mut diagnostic_content,
|
||||
"{} at line {}: {}",
|
||||
severity,
|
||||
start_point.row + 1,
|
||||
entry.diagnostic.message
|
||||
)?;
|
||||
}
|
||||
|
||||
if !diagnostic_content.is_empty() {
|
||||
file_chunks.push(FileChunk {
|
||||
file_path: format!("Diagnostics for {}", full_path.display()),
|
||||
start_line: 0,
|
||||
end_line: diagnostic_count,
|
||||
content: diagnostic_content,
|
||||
timestamp: None,
|
||||
});
|
||||
}
|
||||
|
||||
let request_body = AutocompleteRequest {
|
||||
debug_info,
|
||||
repo_name,
|
||||
file_path: full_path.clone(),
|
||||
file_contents: text.clone(),
|
||||
original_file_contents: text,
|
||||
cursor_position: offset,
|
||||
recent_changes: recent_changes.clone(),
|
||||
changes_above_cursor: true,
|
||||
multiple_suggestions: false,
|
||||
branch: None,
|
||||
file_chunks,
|
||||
retrieval_chunks: vec![],
|
||||
recent_user_actions: vec![],
|
||||
// TODO
|
||||
privacy_mode_enabled: false,
|
||||
};
|
||||
|
||||
let mut buf: Vec<u8> = Vec::new();
|
||||
let writer = brotli::CompressorWriter::new(&mut buf, 4096, 11, 22);
|
||||
serde_json::to_writer(writer, &request_body)?;
|
||||
let body: AsyncBody = buf.into();
|
||||
|
||||
let inputs = EditPredictionInputs {
|
||||
events,
|
||||
included_files: vec![cloud_llm_client::predict_edits_v3::IncludedFile {
|
||||
path: full_path.clone(),
|
||||
max_row: cloud_llm_client::predict_edits_v3::Line(snapshot.max_point().row),
|
||||
excerpts: vec![cloud_llm_client::predict_edits_v3::Excerpt {
|
||||
start_line: cloud_llm_client::predict_edits_v3::Line(0),
|
||||
text: request_body.file_contents.into(),
|
||||
}],
|
||||
}],
|
||||
cursor_point: cloud_llm_client::predict_edits_v3::Point {
|
||||
column: cursor_point.column,
|
||||
line: cloud_llm_client::predict_edits_v3::Line(cursor_point.row),
|
||||
},
|
||||
cursor_path: full_path.clone(),
|
||||
};
|
||||
|
||||
let request = http_client::Request::builder()
|
||||
.uri(SWEEP_API_URL)
|
||||
.header("Content-Type", "application/json")
|
||||
.header("Authorization", format!("Bearer {}", api_token))
|
||||
.header("Connection", "keep-alive")
|
||||
.header("Content-Encoding", "br")
|
||||
.method(Method::POST)
|
||||
.body(body)?;
|
||||
|
||||
let mut response = http_client.send(request).await?;
|
||||
|
||||
let mut body: Vec<u8> = Vec::new();
|
||||
response.body_mut().read_to_end(&mut body).await?;
|
||||
|
||||
let response_received_at = Instant::now();
|
||||
if !response.status().is_success() {
|
||||
anyhow::bail!(
|
||||
"Request failed with status: {:?}\nBody: {}",
|
||||
response.status(),
|
||||
String::from_utf8_lossy(&body),
|
||||
);
|
||||
};
|
||||
|
||||
let response: AutocompleteResponse = serde_json::from_slice(&body)?;
|
||||
|
||||
let old_text = snapshot
|
||||
.text_for_range(response.start_index..response.end_index)
|
||||
.collect::<String>();
|
||||
let edits = language::text_diff(&old_text, &response.completion)
|
||||
.into_iter()
|
||||
.map(|(range, text)| {
|
||||
(
|
||||
snapshot.anchor_after(response.start_index + range.start)
|
||||
..snapshot.anchor_before(response.start_index + range.end),
|
||||
text,
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
anyhow::Ok((
|
||||
response.autocomplete_id,
|
||||
edits,
|
||||
snapshot,
|
||||
response_received_at,
|
||||
inputs,
|
||||
))
|
||||
});
|
||||
|
||||
let buffer = active_buffer.clone();
|
||||
|
||||
cx.spawn(async move |cx| {
|
||||
let (id, edits, old_snapshot, response_received_at, inputs) = result.await?;
|
||||
anyhow::Ok(
|
||||
EditPrediction::new(
|
||||
EditPredictionId(id.into()),
|
||||
&buffer,
|
||||
&old_snapshot,
|
||||
edits.into(),
|
||||
buffer_snapshotted_at,
|
||||
response_received_at,
|
||||
inputs,
|
||||
cx,
|
||||
)
|
||||
.await,
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct AutocompleteRequest {
|
||||
struct AutocompleteRequest {
|
||||
pub debug_info: Arc<str>,
|
||||
pub repo_name: String,
|
||||
pub branch: Option<String>,
|
||||
@@ -22,7 +281,7 @@ pub struct AutocompleteRequest {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct FileChunk {
|
||||
struct FileChunk {
|
||||
pub file_path: String,
|
||||
pub start_line: usize,
|
||||
pub end_line: usize,
|
||||
@@ -31,7 +290,7 @@ pub struct FileChunk {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct RetrievalChunk {
|
||||
struct RetrievalChunk {
|
||||
pub file_path: String,
|
||||
pub start_line: usize,
|
||||
pub end_line: usize,
|
||||
@@ -40,7 +299,7 @@ pub struct RetrievalChunk {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct UserAction {
|
||||
struct UserAction {
|
||||
pub action_type: ActionType,
|
||||
pub line_number: usize,
|
||||
pub offset: usize,
|
||||
@@ -51,7 +310,7 @@ pub struct UserAction {
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
|
||||
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||
pub enum ActionType {
|
||||
enum ActionType {
|
||||
CursorMovement,
|
||||
InsertChar,
|
||||
DeleteChar,
|
||||
@@ -60,7 +319,7 @@ pub enum ActionType {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct AutocompleteResponse {
|
||||
struct AutocompleteResponse {
|
||||
pub autocomplete_id: String,
|
||||
pub start_index: usize,
|
||||
pub end_index: usize,
|
||||
@@ -80,7 +339,7 @@ pub struct AutocompleteResponse {
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct AdditionalCompletion {
|
||||
struct AdditionalCompletion {
|
||||
pub start_index: usize,
|
||||
pub end_index: usize,
|
||||
pub completion: String,
|
||||
@@ -90,7 +349,7 @@ pub struct AdditionalCompletion {
|
||||
pub finish_reason: Option<String>,
|
||||
}
|
||||
|
||||
pub(crate) fn write_event(
|
||||
fn write_event(
|
||||
event: &cloud_llm_client::predict_edits_v3::Event,
|
||||
f: &mut impl fmt::Write,
|
||||
) -> fmt::Result {
|
||||
@@ -115,7 +374,7 @@ pub(crate) fn write_event(
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn debug_info(cx: &gpui::App) -> Arc<str> {
|
||||
fn debug_info(cx: &gpui::App) -> Arc<str> {
|
||||
format!(
|
||||
"Zed v{version} ({sha}) - OS: {os} - Zed v{version}",
|
||||
version = release_channel::AppVersion::global(cx),
|
||||
|
||||
@@ -30,7 +30,6 @@ use language::{
|
||||
};
|
||||
use language::{BufferSnapshot, OffsetRangeExt};
|
||||
use language_model::{LlmApiToken, RefreshLlmTokenListener};
|
||||
use lsp::DiagnosticSeverity;
|
||||
use open_ai::FunctionDefinition;
|
||||
use project::{DisableAiSettings, Project, ProjectPath, WorktreeId};
|
||||
use release_channel::AppVersion;
|
||||
@@ -42,7 +41,6 @@ use std::collections::{VecDeque, hash_map};
|
||||
use telemetry_events::EditPredictionRating;
|
||||
use workspace::Workspace;
|
||||
|
||||
use std::fmt::Write as _;
|
||||
use std::ops::Range;
|
||||
use std::path::Path;
|
||||
use std::rc::Rc;
|
||||
@@ -80,6 +78,7 @@ use crate::rate_prediction_modal::{
|
||||
NextEdit, PreviousEdit, RatePredictionsModal, ThumbsDownActivePrediction,
|
||||
ThumbsUpActivePrediction,
|
||||
};
|
||||
use crate::sweep_ai::SweepAi;
|
||||
use crate::zeta1::request_prediction_with_zeta1;
|
||||
pub use provider::ZetaEditPredictionProvider;
|
||||
|
||||
@@ -171,7 +170,7 @@ impl FeatureFlag for Zeta2FeatureFlag {
|
||||
const NAME: &'static str = "zeta2";
|
||||
|
||||
fn enabled_for_staff() -> bool {
|
||||
false
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,8 +191,7 @@ pub struct Zeta {
|
||||
#[cfg(feature = "eval-support")]
|
||||
eval_cache: Option<Arc<dyn EvalCache>>,
|
||||
edit_prediction_model: ZetaEditPredictionModel,
|
||||
sweep_api_token: Option<String>,
|
||||
sweep_ai_debug_info: Arc<str>,
|
||||
sweep_ai: SweepAi,
|
||||
data_collection_choice: DataCollectionChoice,
|
||||
rejected_predictions: Vec<EditPredictionRejection>,
|
||||
reject_predictions_tx: mpsc::UnboundedSender<()>,
|
||||
@@ -202,7 +200,7 @@ pub struct Zeta {
|
||||
rated_predictions: HashSet<EditPredictionId>,
|
||||
}
|
||||
|
||||
#[derive(Default, PartialEq, Eq)]
|
||||
#[derive(Copy, Clone, Default, PartialEq, Eq)]
|
||||
pub enum ZetaEditPredictionModel {
|
||||
#[default]
|
||||
Zeta1,
|
||||
@@ -499,11 +497,8 @@ impl Zeta {
|
||||
#[cfg(feature = "eval-support")]
|
||||
eval_cache: None,
|
||||
edit_prediction_model: ZetaEditPredictionModel::Zeta2,
|
||||
sweep_api_token: std::env::var("SWEEP_AI_TOKEN")
|
||||
.context("No SWEEP_AI_TOKEN environment variable set")
|
||||
.log_err(),
|
||||
sweep_ai: SweepAi::new(cx),
|
||||
data_collection_choice,
|
||||
sweep_ai_debug_info: sweep_ai::debug_info(cx),
|
||||
rejected_predictions: Vec::new(),
|
||||
reject_predictions_debounce_task: None,
|
||||
reject_predictions_tx: reject_tx,
|
||||
@@ -517,7 +512,7 @@ impl Zeta {
|
||||
}
|
||||
|
||||
pub fn has_sweep_api_token(&self) -> bool {
|
||||
self.sweep_api_token.is_some()
|
||||
self.sweep_ai.api_token.is_some()
|
||||
}
|
||||
|
||||
#[cfg(feature = "eval-support")]
|
||||
@@ -643,7 +638,9 @@ impl Zeta {
|
||||
}
|
||||
}
|
||||
project::Event::DiagnosticsUpdated { .. } => {
|
||||
self.refresh_prediction_from_diagnostics(project, cx);
|
||||
if cx.has_flag::<Zeta2FeatureFlag>() {
|
||||
self.refresh_prediction_from_diagnostics(project, cx);
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
@@ -1126,7 +1123,6 @@ impl Zeta {
|
||||
zeta_project.next_pending_prediction_id += 1;
|
||||
let last_request = zeta_project.last_prediction_refresh;
|
||||
|
||||
// TODO report cancelled requests like in zeta1
|
||||
let task = cx.spawn(async move |this, cx| {
|
||||
if let Some((last_entity, last_timestamp)) = last_request
|
||||
&& throttle_entity == last_entity
|
||||
@@ -1136,6 +1132,12 @@ impl Zeta {
|
||||
cx.background_executor().timer(timeout).await;
|
||||
}
|
||||
|
||||
this.update(cx, |this, cx| {
|
||||
this.get_or_init_zeta_project(&project, cx)
|
||||
.last_prediction_refresh = Some((throttle_entity, Instant::now()));
|
||||
})
|
||||
.ok();
|
||||
|
||||
let edit_prediction_id = do_refresh(this.clone(), cx).await.log_err().flatten();
|
||||
|
||||
// When a prediction completes, remove it from the pending list, and cancel
|
||||
@@ -1183,249 +1185,77 @@ impl Zeta {
|
||||
position: language::Anchor,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Task<Result<Option<EditPrediction>>> {
|
||||
match self.edit_prediction_model {
|
||||
ZetaEditPredictionModel::Zeta1 => {
|
||||
request_prediction_with_zeta1(self, project, active_buffer, position, cx)
|
||||
}
|
||||
ZetaEditPredictionModel::Zeta2 => {
|
||||
self.request_prediction_with_zeta2(project, active_buffer, position, cx)
|
||||
}
|
||||
ZetaEditPredictionModel::Sweep => {
|
||||
self.request_prediction_with_sweep(project, active_buffer, position, true, cx)
|
||||
}
|
||||
}
|
||||
self.request_prediction_internal(
|
||||
project.clone(),
|
||||
active_buffer.clone(),
|
||||
position,
|
||||
cx.has_flag::<Zeta2FeatureFlag>(),
|
||||
cx,
|
||||
)
|
||||
}
|
||||
|
||||
fn request_prediction_with_sweep(
|
||||
fn request_prediction_internal(
|
||||
&mut self,
|
||||
project: &Entity<Project>,
|
||||
active_buffer: &Entity<Buffer>,
|
||||
project: Entity<Project>,
|
||||
active_buffer: Entity<Buffer>,
|
||||
position: language::Anchor,
|
||||
allow_jump: bool,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Task<Result<Option<EditPrediction>>> {
|
||||
let snapshot = active_buffer.read(cx).snapshot();
|
||||
let debug_info = self.sweep_ai_debug_info.clone();
|
||||
let Some(api_token) = self.sweep_api_token.clone() else {
|
||||
return Task::ready(Ok(None));
|
||||
};
|
||||
let full_path: Arc<Path> = snapshot
|
||||
.file()
|
||||
.map(|file| file.full_path(cx))
|
||||
.unwrap_or_else(|| "untitled".into())
|
||||
.into();
|
||||
|
||||
let project_file = project::File::from_dyn(snapshot.file());
|
||||
let repo_name = project_file
|
||||
.map(|file| file.worktree.read(cx).root_name_str())
|
||||
.unwrap_or("untitled")
|
||||
.into();
|
||||
let offset = position.to_offset(&snapshot);
|
||||
|
||||
let project_state = self.get_or_init_zeta_project(project, cx);
|
||||
let events = project_state.events(cx);
|
||||
let has_events = !events.is_empty();
|
||||
let recent_buffers = project_state.recent_paths.iter().cloned();
|
||||
let http_client = cx.http_client();
|
||||
|
||||
let recent_buffer_snapshots = recent_buffers
|
||||
.filter_map(|project_path| {
|
||||
let buffer = project.read(cx).get_open_buffer(&project_path, cx)?;
|
||||
if active_buffer == &buffer {
|
||||
None
|
||||
} else {
|
||||
Some(buffer.read(cx).snapshot())
|
||||
}
|
||||
})
|
||||
.take(3)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
const DIAGNOSTIC_LINES_RANGE: u32 = 20;
|
||||
|
||||
self.get_or_init_zeta_project(&project, cx);
|
||||
let zeta_project = self.projects.get(&project.entity_id()).unwrap();
|
||||
let events = zeta_project.events(cx);
|
||||
let has_events = !events.is_empty();
|
||||
|
||||
let snapshot = active_buffer.read(cx).snapshot();
|
||||
let cursor_point = position.to_point(&snapshot);
|
||||
let diagnostic_search_start = cursor_point.row.saturating_sub(DIAGNOSTIC_LINES_RANGE);
|
||||
let diagnostic_search_end = cursor_point.row + DIAGNOSTIC_LINES_RANGE;
|
||||
let diagnostic_search_range =
|
||||
Point::new(diagnostic_search_start, 0)..Point::new(diagnostic_search_end, 0);
|
||||
let buffer_snapshotted_at = Instant::now();
|
||||
|
||||
let result = cx.background_spawn({
|
||||
let snapshot = snapshot.clone();
|
||||
let diagnostic_search_range = diagnostic_search_range.clone();
|
||||
async move {
|
||||
let text = snapshot.text();
|
||||
|
||||
let mut recent_changes = String::new();
|
||||
for event in &events {
|
||||
sweep_ai::write_event(event.as_ref(), &mut recent_changes).unwrap();
|
||||
}
|
||||
|
||||
let mut file_chunks = recent_buffer_snapshots
|
||||
.into_iter()
|
||||
.map(|snapshot| {
|
||||
let end_point = Point::new(30, 0).min(snapshot.max_point());
|
||||
sweep_ai::FileChunk {
|
||||
content: snapshot.text_for_range(Point::zero()..end_point).collect(),
|
||||
file_path: snapshot
|
||||
.file()
|
||||
.map(|f| f.path().as_unix_str())
|
||||
.unwrap_or("untitled")
|
||||
.to_string(),
|
||||
start_line: 0,
|
||||
end_line: end_point.row as usize,
|
||||
timestamp: snapshot.file().and_then(|file| {
|
||||
Some(
|
||||
file.disk_state()
|
||||
.mtime()?
|
||||
.to_seconds_and_nanos_for_persistence()?
|
||||
.0,
|
||||
)
|
||||
}),
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let diagnostic_entries =
|
||||
snapshot.diagnostics_in_range(diagnostic_search_range, false);
|
||||
let mut diagnostic_content = String::new();
|
||||
let mut diagnostic_count = 0;
|
||||
|
||||
for entry in diagnostic_entries {
|
||||
let start_point: Point = entry.range.start;
|
||||
|
||||
let severity = match entry.diagnostic.severity {
|
||||
DiagnosticSeverity::ERROR => "error",
|
||||
DiagnosticSeverity::WARNING => "warning",
|
||||
DiagnosticSeverity::INFORMATION => "info",
|
||||
DiagnosticSeverity::HINT => "hint",
|
||||
_ => continue,
|
||||
};
|
||||
|
||||
diagnostic_count += 1;
|
||||
|
||||
writeln!(
|
||||
&mut diagnostic_content,
|
||||
"{} at line {}: {}",
|
||||
severity,
|
||||
start_point.row + 1,
|
||||
entry.diagnostic.message
|
||||
)?;
|
||||
}
|
||||
|
||||
if !diagnostic_content.is_empty() {
|
||||
file_chunks.push(sweep_ai::FileChunk {
|
||||
file_path: format!("Diagnostics for {}", full_path.display()),
|
||||
start_line: 0,
|
||||
end_line: diagnostic_count,
|
||||
content: diagnostic_content,
|
||||
timestamp: None,
|
||||
});
|
||||
}
|
||||
|
||||
let request_body = sweep_ai::AutocompleteRequest {
|
||||
debug_info,
|
||||
repo_name,
|
||||
file_path: full_path.clone(),
|
||||
file_contents: text.clone(),
|
||||
original_file_contents: text,
|
||||
cursor_position: offset,
|
||||
recent_changes: recent_changes.clone(),
|
||||
changes_above_cursor: true,
|
||||
multiple_suggestions: false,
|
||||
branch: None,
|
||||
file_chunks,
|
||||
retrieval_chunks: vec![],
|
||||
recent_user_actions: vec![],
|
||||
// TODO
|
||||
privacy_mode_enabled: false,
|
||||
};
|
||||
|
||||
let mut buf: Vec<u8> = Vec::new();
|
||||
let writer = brotli::CompressorWriter::new(&mut buf, 4096, 11, 22);
|
||||
serde_json::to_writer(writer, &request_body)?;
|
||||
let body: AsyncBody = buf.into();
|
||||
|
||||
let inputs = EditPredictionInputs {
|
||||
events,
|
||||
included_files: vec![cloud_llm_client::predict_edits_v3::IncludedFile {
|
||||
path: full_path.clone(),
|
||||
max_row: cloud_llm_client::predict_edits_v3::Line(snapshot.max_point().row),
|
||||
excerpts: vec![cloud_llm_client::predict_edits_v3::Excerpt {
|
||||
start_line: cloud_llm_client::predict_edits_v3::Line(0),
|
||||
text: request_body.file_contents.into(),
|
||||
}],
|
||||
}],
|
||||
cursor_point: cloud_llm_client::predict_edits_v3::Point {
|
||||
column: cursor_point.column,
|
||||
line: cloud_llm_client::predict_edits_v3::Line(cursor_point.row),
|
||||
},
|
||||
cursor_path: full_path.clone(),
|
||||
};
|
||||
|
||||
const SWEEP_API_URL: &str =
|
||||
"https://autocomplete.sweep.dev/backend/next_edit_autocomplete";
|
||||
|
||||
let request = http_client::Request::builder()
|
||||
.uri(SWEEP_API_URL)
|
||||
.header("Content-Type", "application/json")
|
||||
.header("Authorization", format!("Bearer {}", api_token))
|
||||
.header("Connection", "keep-alive")
|
||||
.header("Content-Encoding", "br")
|
||||
.method(Method::POST)
|
||||
.body(body)?;
|
||||
|
||||
let mut response = http_client.send(request).await?;
|
||||
|
||||
let mut body: Vec<u8> = Vec::new();
|
||||
response.body_mut().read_to_end(&mut body).await?;
|
||||
|
||||
let response_received_at = Instant::now();
|
||||
if !response.status().is_success() {
|
||||
anyhow::bail!(
|
||||
"Request failed with status: {:?}\nBody: {}",
|
||||
response.status(),
|
||||
String::from_utf8_lossy(&body),
|
||||
);
|
||||
};
|
||||
|
||||
let response: sweep_ai::AutocompleteResponse = serde_json::from_slice(&body)?;
|
||||
|
||||
let old_text = snapshot
|
||||
.text_for_range(response.start_index..response.end_index)
|
||||
.collect::<String>();
|
||||
let edits = language::text_diff(&old_text, &response.completion)
|
||||
.into_iter()
|
||||
.map(|(range, text)| {
|
||||
(
|
||||
snapshot.anchor_after(response.start_index + range.start)
|
||||
..snapshot.anchor_before(response.start_index + range.end),
|
||||
text,
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
anyhow::Ok((
|
||||
response.autocomplete_id,
|
||||
edits,
|
||||
snapshot,
|
||||
response_received_at,
|
||||
inputs,
|
||||
))
|
||||
}
|
||||
});
|
||||
|
||||
let buffer = active_buffer.clone();
|
||||
let project = project.clone();
|
||||
let active_buffer = active_buffer.clone();
|
||||
let task = match self.edit_prediction_model {
|
||||
ZetaEditPredictionModel::Zeta1 => request_prediction_with_zeta1(
|
||||
self,
|
||||
&project,
|
||||
&active_buffer,
|
||||
snapshot.clone(),
|
||||
position,
|
||||
events,
|
||||
cx,
|
||||
),
|
||||
ZetaEditPredictionModel::Zeta2 => self.request_prediction_with_zeta2(
|
||||
&project,
|
||||
&active_buffer,
|
||||
snapshot.clone(),
|
||||
position,
|
||||
events,
|
||||
cx,
|
||||
),
|
||||
ZetaEditPredictionModel::Sweep => self.sweep_ai.request_prediction_with_sweep(
|
||||
&project,
|
||||
&active_buffer,
|
||||
snapshot.clone(),
|
||||
position,
|
||||
events,
|
||||
&zeta_project.recent_paths,
|
||||
diagnostic_search_range.clone(),
|
||||
cx,
|
||||
),
|
||||
};
|
||||
|
||||
cx.spawn(async move |this, cx| {
|
||||
let (id, edits, old_snapshot, response_received_at, inputs) = result.await?;
|
||||
let prediction = task
|
||||
.await?
|
||||
.filter(|prediction| !prediction.edits.is_empty());
|
||||
|
||||
if edits.is_empty() {
|
||||
if prediction.is_none() && allow_jump {
|
||||
let cursor_point = position.to_point(&snapshot);
|
||||
if has_events
|
||||
&& allow_jump
|
||||
&& let Some((jump_buffer, jump_position)) = Self::next_diagnostic_location(
|
||||
active_buffer,
|
||||
active_buffer.clone(),
|
||||
&snapshot,
|
||||
diagnostic_search_range,
|
||||
cursor_point,
|
||||
@@ -1436,9 +1266,9 @@ impl Zeta {
|
||||
{
|
||||
return this
|
||||
.update(cx, |this, cx| {
|
||||
this.request_prediction_with_sweep(
|
||||
&project,
|
||||
&jump_buffer,
|
||||
this.request_prediction_internal(
|
||||
project,
|
||||
jump_buffer,
|
||||
jump_position,
|
||||
false,
|
||||
cx,
|
||||
@@ -1450,19 +1280,7 @@ impl Zeta {
|
||||
return anyhow::Ok(None);
|
||||
}
|
||||
|
||||
anyhow::Ok(
|
||||
EditPrediction::new(
|
||||
EditPredictionId(id.into()),
|
||||
&buffer,
|
||||
&old_snapshot,
|
||||
edits.into(),
|
||||
buffer_snapshotted_at,
|
||||
response_received_at,
|
||||
inputs,
|
||||
cx,
|
||||
)
|
||||
.await,
|
||||
)
|
||||
Ok(prediction)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1549,7 +1367,9 @@ impl Zeta {
|
||||
&mut self,
|
||||
project: &Entity<Project>,
|
||||
active_buffer: &Entity<Buffer>,
|
||||
active_snapshot: BufferSnapshot,
|
||||
position: language::Anchor,
|
||||
events: Vec<Arc<Event>>,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Task<Result<Option<EditPrediction>>> {
|
||||
let project_state = self.projects.get(&project.entity_id());
|
||||
@@ -1561,7 +1381,6 @@ impl Zeta {
|
||||
.map(|syntax_index| syntax_index.read_with(cx, |index, _cx| index.state().clone()))
|
||||
});
|
||||
let options = self.options.clone();
|
||||
let active_snapshot = active_buffer.read(cx).snapshot();
|
||||
let buffer_snapshotted_at = Instant::now();
|
||||
let Some(excerpt_path) = active_snapshot
|
||||
.file()
|
||||
@@ -1579,10 +1398,6 @@ impl Zeta {
|
||||
.collect::<Vec<_>>();
|
||||
let debug_tx = self.debug_tx.clone();
|
||||
|
||||
let events = project_state
|
||||
.map(|state| state.events(cx))
|
||||
.unwrap_or_default();
|
||||
|
||||
let diagnostics = active_snapshot.diagnostic_sets().clone();
|
||||
|
||||
let file = active_buffer.read(cx).file();
|
||||
|
||||
@@ -32,19 +32,17 @@ pub(crate) fn request_prediction_with_zeta1(
|
||||
zeta: &mut Zeta,
|
||||
project: &Entity<Project>,
|
||||
buffer: &Entity<Buffer>,
|
||||
snapshot: BufferSnapshot,
|
||||
position: language::Anchor,
|
||||
events: Vec<Arc<Event>>,
|
||||
cx: &mut Context<Zeta>,
|
||||
) -> Task<Result<Option<EditPrediction>>> {
|
||||
let buffer = buffer.clone();
|
||||
let buffer_snapshotted_at = Instant::now();
|
||||
let snapshot = buffer.read(cx).snapshot();
|
||||
let client = zeta.client.clone();
|
||||
let llm_token = zeta.llm_token.clone();
|
||||
let app_version = AppVersion::global(cx);
|
||||
|
||||
let zeta_project = zeta.get_or_init_zeta_project(project, cx);
|
||||
let events = Arc::new(zeta_project.events(cx));
|
||||
|
||||
let (git_info, can_collect_file) = if let Some(file) = snapshot.file() {
|
||||
let can_collect_file = zeta.can_collect_file(project, file, cx);
|
||||
let git_info = if can_collect_file {
|
||||
|
||||
@@ -42,43 +42,48 @@ actions!(
|
||||
|
||||
pub fn init(cx: &mut App) {
|
||||
cx.observe_new(move |workspace: &mut Workspace, _, _cx| {
|
||||
workspace.register_action(move |workspace, _: &OpenZeta2Inspector, window, cx| {
|
||||
let project = workspace.project();
|
||||
workspace.split_item(
|
||||
SplitDirection::Right,
|
||||
Box::new(cx.new(|cx| {
|
||||
Zeta2Inspector::new(
|
||||
&project,
|
||||
workspace.client(),
|
||||
workspace.user_store(),
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
})),
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
});
|
||||
})
|
||||
.detach();
|
||||
|
||||
cx.observe_new(move |workspace: &mut Workspace, _, _cx| {
|
||||
workspace.register_action(move |workspace, _: &OpenZeta2ContextView, window, cx| {
|
||||
let project = workspace.project();
|
||||
workspace.split_item(
|
||||
SplitDirection::Right,
|
||||
Box::new(cx.new(|cx| {
|
||||
Zeta2ContextView::new(
|
||||
project.clone(),
|
||||
workspace.client(),
|
||||
workspace.user_store(),
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
})),
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
workspace.register_action_renderer(|div, _, _, cx| {
|
||||
let has_flag = cx.has_flag::<Zeta2FeatureFlag>();
|
||||
div.when(has_flag, |div| {
|
||||
div.on_action(
|
||||
cx.listener(move |workspace, _: &OpenZeta2Inspector, window, cx| {
|
||||
let project = workspace.project();
|
||||
workspace.split_item(
|
||||
SplitDirection::Right,
|
||||
Box::new(cx.new(|cx| {
|
||||
Zeta2Inspector::new(
|
||||
&project,
|
||||
workspace.client(),
|
||||
workspace.user_store(),
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
})),
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
}),
|
||||
)
|
||||
.on_action(cx.listener(
|
||||
move |workspace, _: &OpenZeta2ContextView, window, cx| {
|
||||
let project = workspace.project();
|
||||
workspace.split_item(
|
||||
SplitDirection::Right,
|
||||
Box::new(cx.new(|cx| {
|
||||
Zeta2ContextView::new(
|
||||
project.clone(),
|
||||
workspace.client(),
|
||||
workspace.user_store(),
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
})),
|
||||
window,
|
||||
cx,
|
||||
);
|
||||
},
|
||||
))
|
||||
})
|
||||
});
|
||||
})
|
||||
.detach();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::{
|
||||
collections::{BTreeSet, HashMap},
|
||||
collections::HashMap,
|
||||
io::{IsTerminal, Write},
|
||||
sync::Arc,
|
||||
};
|
||||
@@ -125,21 +125,10 @@ fn write_aggregated_scores(
|
||||
.peekable();
|
||||
let has_edit_predictions = edit_predictions.peek().is_some();
|
||||
let aggregated_result = EvaluationResult {
|
||||
context: Scores::aggregate(successful.iter().map(|r| &r.context)),
|
||||
edit_prediction: has_edit_predictions.then(|| Scores::aggregate(edit_predictions)),
|
||||
prompt_len: successful.iter().map(|r| r.prompt_len).sum::<usize>() / successful.len(),
|
||||
generated_len: successful.iter().map(|r| r.generated_len).sum::<usize>()
|
||||
/ successful.len(),
|
||||
context_lines_found_in_context: successful
|
||||
.iter()
|
||||
.map(|r| r.context_lines_found_in_context)
|
||||
.sum::<usize>()
|
||||
/ successful.len(),
|
||||
context_lines_in_expected_patch: successful
|
||||
.iter()
|
||||
.map(|r| r.context_lines_in_expected_patch)
|
||||
.sum::<usize>()
|
||||
/ successful.len(),
|
||||
};
|
||||
|
||||
writeln!(w, "\n{}", "-".repeat(80))?;
|
||||
@@ -261,11 +250,8 @@ fn write_eval_result(
|
||||
#[derive(Debug, Default)]
|
||||
pub struct EvaluationResult {
|
||||
pub edit_prediction: Option<Scores>,
|
||||
pub context: Scores,
|
||||
pub prompt_len: usize,
|
||||
pub generated_len: usize,
|
||||
pub context_lines_in_expected_patch: usize,
|
||||
pub context_lines_found_in_context: usize,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
@@ -363,14 +349,6 @@ impl std::fmt::Display for EvaluationResult {
|
||||
|
||||
impl EvaluationResult {
|
||||
fn fmt_markdown(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
r#"
|
||||
### Context Scores
|
||||
{}
|
||||
"#,
|
||||
self.context.to_markdown(),
|
||||
)?;
|
||||
if let Some(prediction) = &self.edit_prediction {
|
||||
write!(
|
||||
f,
|
||||
@@ -387,34 +365,18 @@ impl EvaluationResult {
|
||||
writeln!(f, "### Scores\n")?;
|
||||
writeln!(
|
||||
f,
|
||||
" Prompt Generated RetrievedContext PatchContext TP FP FN Precision Recall F1"
|
||||
" Prompt Generated TP FP FN Precision Recall F1"
|
||||
)?;
|
||||
writeln!(
|
||||
f,
|
||||
"─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────"
|
||||
)?;
|
||||
writeln!(
|
||||
f,
|
||||
"Context Retrieval {:<7} {:<9} {:<16} {:<16} {:<6} {:<6} {:<6} {:>10.2} {:>7.2} {:>7.2}",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
self.context.true_positives,
|
||||
self.context.false_positives,
|
||||
self.context.false_negatives,
|
||||
self.context.precision() * 100.0,
|
||||
self.context.recall() * 100.0,
|
||||
self.context.f1_score() * 100.0
|
||||
"───────────────────────────────────────────────────────────────────────────────────────────────"
|
||||
)?;
|
||||
if let Some(edit_prediction) = &self.edit_prediction {
|
||||
writeln!(
|
||||
f,
|
||||
"Edit Prediction {:<7} {:<9} {:<16} {:<16} {:<6} {:<6} {:<6} {:>10.2} {:>7.2} {:>7.2}",
|
||||
"Edit Prediction {:<7} {:<9} {:<6} {:<6} {:<6} {:>9.2} {:>8.2} {:>7.2}",
|
||||
self.prompt_len,
|
||||
self.generated_len,
|
||||
self.context_lines_found_in_context,
|
||||
self.context_lines_in_expected_patch,
|
||||
edit_prediction.true_positives,
|
||||
edit_prediction.false_positives,
|
||||
edit_prediction.false_negatives,
|
||||
@@ -434,53 +396,6 @@ fn evaluate(example: &Example, preds: &PredictionDetails, predict: bool) -> Eval
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let actual_context_lines: HashSet<_> = preds
|
||||
.excerpts
|
||||
.iter()
|
||||
.flat_map(|excerpt| {
|
||||
excerpt
|
||||
.text
|
||||
.lines()
|
||||
.map(|line| format!("{}: {line}", excerpt.path.display()))
|
||||
})
|
||||
.collect();
|
||||
|
||||
let mut false_positive_lines = actual_context_lines.clone();
|
||||
|
||||
for entry in &example.expected_context {
|
||||
let mut best_alternative_score: Option<Scores> = None;
|
||||
|
||||
for alternative in &entry.alternatives {
|
||||
let expected: HashSet<_> = alternative
|
||||
.excerpts
|
||||
.iter()
|
||||
.flat_map(|excerpt| {
|
||||
excerpt
|
||||
.text
|
||||
.lines()
|
||||
.map(|line| format!("{}: {line}", excerpt.path.display()))
|
||||
})
|
||||
.collect();
|
||||
|
||||
let scores = Scores::new(&expected, &actual_context_lines);
|
||||
|
||||
false_positive_lines.retain(|line| !expected.contains(line));
|
||||
|
||||
if best_alternative_score
|
||||
.as_ref()
|
||||
.is_none_or(|best| scores.recall() > best.recall())
|
||||
{
|
||||
best_alternative_score = Some(scores);
|
||||
}
|
||||
}
|
||||
|
||||
let best_alternative = best_alternative_score.unwrap_or_default();
|
||||
eval_result.context.false_negatives += best_alternative.false_negatives;
|
||||
eval_result.context.true_positives += best_alternative.true_positives;
|
||||
}
|
||||
|
||||
eval_result.context.false_positives = false_positive_lines.len();
|
||||
|
||||
if predict {
|
||||
// todo: alternatives for patches
|
||||
let expected_patch = example
|
||||
@@ -493,25 +408,6 @@ fn evaluate(example: &Example, preds: &PredictionDetails, predict: bool) -> Eval
|
||||
.filter(|line| matches!(line, DiffLine::Addition(_) | DiffLine::Deletion(_)))
|
||||
.map(|line| line.to_string())
|
||||
.collect();
|
||||
let expected_context_lines = expected_patch
|
||||
.iter()
|
||||
.filter_map(|line| {
|
||||
if let DiffLine::Context(str) = line {
|
||||
Some(String::from(*str))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect::<BTreeSet<_>>();
|
||||
let actual_context_lines = preds
|
||||
.excerpts
|
||||
.iter()
|
||||
.flat_map(|excerpt| excerpt.text.lines().map(ToOwned::to_owned))
|
||||
.collect::<BTreeSet<_>>();
|
||||
|
||||
let matched = expected_context_lines
|
||||
.intersection(&actual_context_lines)
|
||||
.count();
|
||||
|
||||
let actual_patch_lines = preds
|
||||
.diff
|
||||
@@ -522,8 +418,6 @@ fn evaluate(example: &Example, preds: &PredictionDetails, predict: bool) -> Eval
|
||||
.collect();
|
||||
|
||||
eval_result.edit_prediction = Some(Scores::new(&expected_patch_lines, &actual_patch_lines));
|
||||
eval_result.context_lines_in_expected_patch = expected_context_lines.len();
|
||||
eval_result.context_lines_found_in_context = matched;
|
||||
}
|
||||
|
||||
eval_result
|
||||
|
||||
@@ -14,7 +14,6 @@ use anyhow::{Context as _, Result, anyhow};
|
||||
use clap::ValueEnum;
|
||||
use cloud_zeta2_prompt::CURSOR_MARKER;
|
||||
use collections::HashMap;
|
||||
use edit_prediction_context::Line;
|
||||
use futures::{
|
||||
AsyncWriteExt as _,
|
||||
lock::{Mutex, OwnedMutexGuard},
|
||||
@@ -53,7 +52,6 @@ pub struct Example {
|
||||
pub cursor_position: String,
|
||||
pub edit_history: String,
|
||||
pub expected_patch: String,
|
||||
pub expected_context: Vec<ExpectedContextEntry>,
|
||||
}
|
||||
|
||||
pub type ActualExcerpt = Excerpt;
|
||||
@@ -64,25 +62,6 @@ pub struct Excerpt {
|
||||
pub text: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct ExpectedContextEntry {
|
||||
pub heading: String,
|
||||
pub alternatives: Vec<ExpectedExcerptSet>,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct ExpectedExcerptSet {
|
||||
pub heading: String,
|
||||
pub excerpts: Vec<ExpectedExcerpt>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct ExpectedExcerpt {
|
||||
pub path: PathBuf,
|
||||
pub text: String,
|
||||
pub required_lines: Vec<Line>,
|
||||
}
|
||||
|
||||
#[derive(ValueEnum, Debug, Clone)]
|
||||
pub enum ExampleFormat {
|
||||
Json,
|
||||
@@ -132,7 +111,6 @@ impl NamedExample {
|
||||
cursor_position: String::new(),
|
||||
edit_history: String::new(),
|
||||
expected_patch: String::new(),
|
||||
expected_context: Vec::new(),
|
||||
},
|
||||
};
|
||||
|
||||
@@ -197,30 +175,10 @@ impl NamedExample {
|
||||
};
|
||||
}
|
||||
Event::End(TagEnd::Heading(HeadingLevel::H3)) => {
|
||||
let heading = mem::take(&mut text);
|
||||
match current_section {
|
||||
Section::ExpectedExcerpts => {
|
||||
named.example.expected_context.push(ExpectedContextEntry {
|
||||
heading,
|
||||
alternatives: Vec::new(),
|
||||
});
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
mem::take(&mut text);
|
||||
}
|
||||
Event::End(TagEnd::Heading(HeadingLevel::H4)) => {
|
||||
let heading = mem::take(&mut text);
|
||||
match current_section {
|
||||
Section::ExpectedExcerpts => {
|
||||
let expected_context = &mut named.example.expected_context;
|
||||
let last_entry = expected_context.last_mut().unwrap();
|
||||
last_entry.alternatives.push(ExpectedExcerptSet {
|
||||
heading,
|
||||
excerpts: Vec::new(),
|
||||
})
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
mem::take(&mut text);
|
||||
}
|
||||
Event::End(TagEnd::Heading(level)) => {
|
||||
anyhow::bail!("Unexpected heading level: {level}");
|
||||
@@ -253,41 +211,7 @@ impl NamedExample {
|
||||
named.example.cursor_position = mem::take(&mut text);
|
||||
}
|
||||
Section::ExpectedExcerpts => {
|
||||
let text = mem::take(&mut text);
|
||||
for excerpt in text.split("\n…\n") {
|
||||
let (mut text, required_lines) = extract_required_lines(&excerpt);
|
||||
if !text.ends_with('\n') {
|
||||
text.push('\n');
|
||||
}
|
||||
|
||||
if named.example.expected_context.is_empty() {
|
||||
named.example.expected_context.push(Default::default());
|
||||
}
|
||||
|
||||
let alternatives = &mut named
|
||||
.example
|
||||
.expected_context
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.alternatives;
|
||||
|
||||
if alternatives.is_empty() {
|
||||
alternatives.push(ExpectedExcerptSet {
|
||||
heading: String::new(),
|
||||
excerpts: vec![],
|
||||
});
|
||||
}
|
||||
|
||||
alternatives
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.excerpts
|
||||
.push(ExpectedExcerpt {
|
||||
path: block_info.into(),
|
||||
text,
|
||||
required_lines,
|
||||
});
|
||||
}
|
||||
mem::take(&mut text);
|
||||
}
|
||||
Section::ExpectedPatch => {
|
||||
named.example.expected_patch = mem::take(&mut text);
|
||||
@@ -561,47 +485,6 @@ impl NamedExample {
|
||||
}
|
||||
}
|
||||
|
||||
fn extract_required_lines(text: &str) -> (String, Vec<Line>) {
|
||||
const MARKER: &str = "[ZETA]";
|
||||
let mut new_text = String::new();
|
||||
let mut required_lines = Vec::new();
|
||||
let mut skipped_lines = 0_u32;
|
||||
|
||||
for (row, mut line) in text.split('\n').enumerate() {
|
||||
if let Some(marker_column) = line.find(MARKER) {
|
||||
let mut strip_column = marker_column;
|
||||
|
||||
while strip_column > 0 {
|
||||
let prev_char = line[strip_column - 1..].chars().next().unwrap();
|
||||
if prev_char.is_whitespace() || ['/', '#'].contains(&prev_char) {
|
||||
strip_column -= 1;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let metadata = &line[marker_column + MARKER.len()..];
|
||||
if metadata.contains("required") {
|
||||
required_lines.push(Line(row as u32 - skipped_lines));
|
||||
}
|
||||
|
||||
if strip_column == 0 {
|
||||
skipped_lines += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
line = &line[..strip_column];
|
||||
}
|
||||
|
||||
new_text.push_str(line);
|
||||
new_text.push('\n');
|
||||
}
|
||||
|
||||
new_text.pop();
|
||||
|
||||
(new_text, required_lines)
|
||||
}
|
||||
|
||||
async fn run_git(repo_path: &Path, args: &[&str]) -> Result<String> {
|
||||
let output = smol::process::Command::new("git")
|
||||
.current_dir(repo_path)
|
||||
@@ -656,37 +539,6 @@ impl Display for NamedExample {
|
||||
)?;
|
||||
}
|
||||
|
||||
if !self.example.expected_context.is_empty() {
|
||||
write!(f, "\n## {EXPECTED_CONTEXT_HEADING}\n\n")?;
|
||||
|
||||
for entry in &self.example.expected_context {
|
||||
write!(f, "\n### {}\n\n", entry.heading)?;
|
||||
|
||||
let skip_h4 =
|
||||
entry.alternatives.len() == 1 && entry.alternatives[0].heading.is_empty();
|
||||
|
||||
for excerpt_set in &entry.alternatives {
|
||||
if !skip_h4 {
|
||||
write!(f, "\n#### {}\n\n", excerpt_set.heading)?;
|
||||
}
|
||||
|
||||
for excerpt in &excerpt_set.excerpts {
|
||||
write!(
|
||||
f,
|
||||
"`````{}{}\n{}`````\n\n",
|
||||
excerpt
|
||||
.path
|
||||
.extension()
|
||||
.map(|ext| format!("{} ", ext.to_string_lossy()))
|
||||
.unwrap_or_default(),
|
||||
excerpt.path.display(),
|
||||
excerpt.text
|
||||
)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -707,38 +559,3 @@ pub async fn lock_repo(path: impl AsRef<Path>) -> OwnedMutexGuard<()> {
|
||||
.lock_owned()
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use indoc::indoc;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn test_extract_required_lines() {
|
||||
let input = indoc! {"
|
||||
zero
|
||||
one // [ZETA] required
|
||||
two
|
||||
// [ZETA] something
|
||||
three
|
||||
four # [ZETA] required
|
||||
five
|
||||
"};
|
||||
|
||||
let expected_updated_input = indoc! {"
|
||||
zero
|
||||
one
|
||||
two
|
||||
three
|
||||
four
|
||||
five
|
||||
"};
|
||||
|
||||
let expected_required_lines = vec![Line(1), Line(4)];
|
||||
|
||||
let (updated_input, required_lines) = extract_required_lines(input);
|
||||
assert_eq!(updated_input, expected_updated_input);
|
||||
assert_eq!(required_lines, expected_required_lines);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,8 +128,6 @@ pub struct PredictArguments {
|
||||
|
||||
#[derive(Clone, Debug, Args)]
|
||||
pub struct PredictionOptions {
|
||||
#[arg(long)]
|
||||
use_expected_context: bool,
|
||||
#[clap(flatten)]
|
||||
zeta2: Zeta2Args,
|
||||
#[clap(long)]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::example::{ActualExcerpt, ExpectedExcerpt, NamedExample};
|
||||
use crate::example::{ActualExcerpt, NamedExample};
|
||||
use crate::headless::ZetaCliAppState;
|
||||
use crate::paths::{CACHE_DIR, LATEST_EXAMPLE_RUN_DIR, RUN_DIR, print_run_data_dir};
|
||||
use crate::{
|
||||
@@ -7,16 +7,13 @@ use crate::{
|
||||
use ::serde::Serialize;
|
||||
use anyhow::{Context, Result, anyhow};
|
||||
use cloud_zeta2_prompt::{CURSOR_MARKER, write_codeblock};
|
||||
use collections::HashMap;
|
||||
use futures::StreamExt as _;
|
||||
use gpui::{AppContext, AsyncApp, Entity};
|
||||
use language::{Anchor, Buffer, Point};
|
||||
use project::Project;
|
||||
use project::buffer_store::BufferStoreEvent;
|
||||
use serde::Deserialize;
|
||||
use std::fs;
|
||||
use std::io::{IsTerminal, Write};
|
||||
use std::ops::Range;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
@@ -204,15 +201,12 @@ pub async fn perform_predict(
|
||||
let mut result = result.lock().unwrap();
|
||||
result.generated_len = response.chars().count();
|
||||
|
||||
if !options.use_expected_context {
|
||||
result.planning_search_time = Some(
|
||||
search_queries_generated_at.unwrap() - start_time.unwrap(),
|
||||
);
|
||||
result.running_search_time = Some(
|
||||
search_queries_executed_at.unwrap()
|
||||
- search_queries_generated_at.unwrap(),
|
||||
);
|
||||
}
|
||||
result.planning_search_time =
|
||||
Some(search_queries_generated_at.unwrap() - start_time.unwrap());
|
||||
result.running_search_time = Some(
|
||||
search_queries_executed_at.unwrap()
|
||||
- search_queries_generated_at.unwrap(),
|
||||
);
|
||||
result.prediction_time = prediction_finished_at - prediction_started_at;
|
||||
result.total_time = prediction_finished_at - start_time.unwrap();
|
||||
|
||||
@@ -224,37 +218,10 @@ pub async fn perform_predict(
|
||||
}
|
||||
});
|
||||
|
||||
if options.use_expected_context {
|
||||
let context_excerpts_tasks = example
|
||||
.example
|
||||
.expected_context
|
||||
.iter()
|
||||
.flat_map(|section| {
|
||||
section.alternatives[0].excerpts.iter().map(|excerpt| {
|
||||
resolve_context_entry(project.clone(), excerpt.clone(), cx.clone())
|
||||
})
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let context_excerpts_vec =
|
||||
futures::future::try_join_all(context_excerpts_tasks).await?;
|
||||
|
||||
let mut context_excerpts = HashMap::default();
|
||||
for (buffer, mut excerpts) in context_excerpts_vec {
|
||||
context_excerpts
|
||||
.entry(buffer)
|
||||
.or_insert(Vec::new())
|
||||
.append(&mut excerpts);
|
||||
}
|
||||
|
||||
zeta.update(cx, |zeta, _cx| {
|
||||
zeta.set_context(project.clone(), context_excerpts)
|
||||
})?;
|
||||
} else {
|
||||
zeta.update(cx, |zeta, cx| {
|
||||
zeta.refresh_context(project.clone(), cursor_buffer.clone(), cursor_anchor, cx)
|
||||
})?
|
||||
.await?;
|
||||
}
|
||||
zeta.update(cx, |zeta, cx| {
|
||||
zeta.refresh_context(project.clone(), cursor_buffer.clone(), cursor_anchor, cx)
|
||||
})?
|
||||
.await?;
|
||||
}
|
||||
|
||||
let prediction = zeta
|
||||
@@ -274,38 +241,6 @@ pub async fn perform_predict(
|
||||
anyhow::Ok(result)
|
||||
}
|
||||
|
||||
async fn resolve_context_entry(
|
||||
project: Entity<Project>,
|
||||
excerpt: ExpectedExcerpt,
|
||||
mut cx: AsyncApp,
|
||||
) -> Result<(Entity<Buffer>, Vec<Range<Anchor>>)> {
|
||||
let buffer = project
|
||||
.update(&mut cx, |project, cx| {
|
||||
let project_path = project.find_project_path(&excerpt.path, cx).unwrap();
|
||||
project.open_buffer(project_path, cx)
|
||||
})?
|
||||
.await?;
|
||||
|
||||
let ranges = buffer.read_with(&mut cx, |buffer, _| {
|
||||
let full_text = buffer.text();
|
||||
let offset = full_text
|
||||
.find(&excerpt.text)
|
||||
.expect("Expected context not found");
|
||||
let point = buffer.offset_to_point(offset);
|
||||
excerpt
|
||||
.required_lines
|
||||
.iter()
|
||||
.map(|line| {
|
||||
let row = point.row + line.0;
|
||||
let range = Point::new(row, 0)..Point::new(row + 1, 0);
|
||||
buffer.anchor_after(range.start)..buffer.anchor_before(range.end)
|
||||
})
|
||||
.collect()
|
||||
})?;
|
||||
|
||||
Ok((buffer, ranges))
|
||||
}
|
||||
|
||||
struct RunCache {
|
||||
cache_mode: CacheMode,
|
||||
example_run_dir: PathBuf,
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
- [Code Completions](./completions.md)
|
||||
- [Collaboration](./collaboration/overview.md)
|
||||
- [Channels](./collaboration/channels.md)
|
||||
- [Private Calls](./collaboration/private-calls.md)
|
||||
- [Contacts and Private Calls](./collaboration/contacts-and-private-calls.md)
|
||||
- [Git](./git.md)
|
||||
- [Debugger](./debugger.md)
|
||||
- [Diagnostics](./diagnostics.md)
|
||||
|
||||
@@ -1,50 +1,123 @@
|
||||
# Channels
|
||||
|
||||
## Overview
|
||||
|
||||
Channels provide a way to streamline collaborating for software engineers in many ways, but particularly:
|
||||
|
||||
- Pairing – when working on something together, you both have your own screen, mouse, and keyboard.
|
||||
- Mentoring – it’s easy to jump in to someone else’s context, and help them get unstuck, without the friction of pushing code up.
|
||||
- Mentoring – it's easy to jump in to someone else's context, and help them get unstuck, without the friction of pushing code up.
|
||||
- Refactoring – you can have multiple people join in on large refactoring without fear of conflict.
|
||||
- Ambient awareness – you can see what everyone else is working on with no need for status emails or meetings.
|
||||
|
||||
## Channels
|
||||
Each channel corresponds to an ongoing project or work-stream.
|
||||
You can see who's in a channel as their avatars will show up in the sidebar.
|
||||
This makes it easy to see what everyone is doing and where to find them if needed.
|
||||
|
||||
To open the collaboration panel hit {#kb collab_panel::ToggleFocus} or `collab panel: toggle focus`.
|
||||
Create a channel by clicking the `+` icon next to the `Channels` text in the collab panel.
|
||||
Create a subchannel by right clicking an existing channel and selecting `New Subchannel`.
|
||||
|
||||
Each channel corresponds to an ongoing project or work-stream. You can see who’s in a channel as their avatars will show up in the sidebar. This makes it easy to see what everyone is doing and where to find them if needed.
|
||||
|
||||
You can create as many channels as you need. As in the example above, you can mix channels for your day job, as well as side-projects in one instance of Zed.
|
||||
You can mix channels for your day job, as well as side-projects in your collab panel.
|
||||
|
||||
Joining a channel adds you to a shared room where you can work on projects together.
|
||||
|
||||
## Sharing projects
|
||||
_[Join our channel tree to get an idea of how you can organize yours.](https://zed.dev/community-links)_
|
||||
|
||||
After joining a channel, you can `Share` a project with the other people there. This will enable them to edit the code hosted on your machine as though they had it checked out locally.
|
||||
## Inviting People
|
||||
|
||||
When you are editing someone else’s project, you still have the full power of the editor at your fingertips, you can jump to definitions, use the AI assistant, and see any diagnostic errors. This is extremely powerful for pairing, as one of you can be implementing the current method while the other is reading and researching the correct solution to the next problem. And, because you have your own config running, it feels like you’re using your own machine.
|
||||
By default, channels you create can only be accessed by you.
|
||||
You can invite collaborators by right clicking and selecting `Manage members`.
|
||||
|
||||
See [our collaboration documentation](./private-calls.md) for more details about how this works.
|
||||
|
||||
## Notes
|
||||
|
||||
Each channel has a notes file associated with it to keep track of current status, new ideas, or to collaborate on building out the design for the feature that you’re working on before diving into code.
|
||||
|
||||
This is similar to a Google Doc, except powered by Zed's collaborative software and persisted to our servers.
|
||||
|
||||
## Inviting people
|
||||
|
||||
By default, channels you create can only be accessed by you. You can invite collaborators by right clicking and selecting `Manage members`.
|
||||
|
||||
When you have channels nested under each other, permissions are inherited. For instance, in the example above, we only need to add people to the `#zed` channel, and they will automatically gain access to `#core-editor`, `#new-languages`, and `#stability`.
|
||||
When you have subchannels nested under others, permissions are inherited.
|
||||
For instance, adding people to the top-level channel in your channel tree will automatically give them access to its subchannels.
|
||||
|
||||
Once you have added someone, they can either join your channel by clicking on it in their Zed sidebar, or you can share the link to the channel so that they can join directly.
|
||||
|
||||
## Voice Chat
|
||||
|
||||
You can mute/unmute your microphone via the microphone icon in the upper right-hand side of the window.
|
||||
|
||||
> Note: When joining a channel, Zed will automatically share your microphone with other users in the call, if your OS allows it.
|
||||
> If you'd prefer your microphone to be off when joining a channel, you can do so via the [`mute_on_join`](../configuring-zed.md#calls) setting.
|
||||
|
||||
## Sharing Projects
|
||||
|
||||
After joining a channel, you can share a project over the channel via the `Share` button in the upper right-hand side of the window.
|
||||
This will allow channel members to edit the code hosted on your machine as though they had it checked out locally.
|
||||
|
||||
When you are editing someone else's project, you still have the full power of the editor at your fingertips; you can jump to definitions, use the AI assistant, and see any diagnostic errors.
|
||||
This is extremely powerful for pairing, as one of you can be implementing the current method while the other is reading and researching the correct solution to the next problem.
|
||||
And, because you have your own config running, it feels like you're using your own machine.
|
||||
|
||||
We aim to eliminate the distinction between local and remote projects as much as possible.
|
||||
Collaborators can open, edit, and save files, perform searches, interact with the language server, etc.
|
||||
Guests have a read-only view of the project, including access to language server info.
|
||||
|
||||
### Unsharing a Project
|
||||
|
||||
You can remove a project from a channel by clicking on the `Unshare` button in the title bar.
|
||||
|
||||
Collaborators that are currently in that project will be disconnected from the project and will not be able to rejoin it unless you share it again.
|
||||
|
||||
## Channel Notes
|
||||
|
||||
Each channel has a Markdown notes file associated with it to keep track of current status, new ideas, or to collaborate on building out the design for the feature that you're working on before diving into code.
|
||||
|
||||
This is similar to a Google Doc, except powered by Zed's collaborative software and persisted to our servers.
|
||||
|
||||
Open the channel notes by clicking on the document icon to the right of the channel name in the collaboration panel.
|
||||
|
||||
> Note: You can view a channel's notes without joining the channel, if you'd just like to read up on what has been written.
|
||||
|
||||
## Following Collaborators
|
||||
|
||||
To follow a collaborator, click on their avatar in the top left of the title bar.
|
||||
You can also cycle through collaborators using {#kb workspace::FollowNextCollaborator} or `workspace: follow next collaborator` in the command palette.
|
||||
|
||||
When you join a project, you'll immediately start following the collaborator that invited you.
|
||||
|
||||
When you are in a pane that is following a collaborator, you will:
|
||||
|
||||
- follow their cursor and scroll position
|
||||
- follow them to other files in the same project
|
||||
- instantly swap to viewing their screenshare in that pane, if they are sharing their screen and leave the project
|
||||
|
||||
To stop following, simply move your mouse or make an edit via your keyboard.
|
||||
|
||||
### How Following Works
|
||||
|
||||
Following is confined to a particular pane.
|
||||
When a pane is following a collaborator, it is outlined in their cursor color.
|
||||
|
||||
Avatars of collaborators in the same project as you are in color, and have a cursor color.
|
||||
Collaborators in other projects are shown in gray.
|
||||
|
||||
This pane-specific behavior allows you to follow someone in one pane while navigating independently in another and can be an effective layout for some collaboration styles.
|
||||
|
||||
### Following a Terminal
|
||||
|
||||
You can follow what a collaborator is doing in their terminal by having them share their screen and following it.
|
||||
|
||||
In the future, we plan to allow you to collaborate in the terminal directly in a shared project.
|
||||
|
||||
## Screen Sharing
|
||||
|
||||
Share your screen with collaborators in the current channel by clicking on the `Share screen` (monitor icon) button in the top right of the title bar.
|
||||
If you have multiple displays, you can choose which one to share via the chevron to the right of the monitor icon.
|
||||
|
||||
After you've shared your screen, others can click on the `Screen` entry under your name in the collaboration panel to open a tab that always keeps it visible.
|
||||
If they are following you, Zed will automatically switch between following your cursor in their Zed instance and your screen share, depending on whether you are focused on Zed or another application, like a web browser.
|
||||
|
||||
> Note: Collaborators can see your entire screen when you are screen sharing, so be careful not to share anything you don't want to share.
|
||||
> Remember to stop screen sharing when you are finished.
|
||||
|
||||
## Livestreaming & Guests
|
||||
|
||||
A Channel can also be made Public. This allows anyone to join the channel by clicking on the link.
|
||||
A Channel can also be made Public.
|
||||
This allows anyone to join the channel by clicking on the link.
|
||||
|
||||
Guest users in channels can hear and see everything that is happening, and have read only access to projects and channel notes.
|
||||
|
||||
If you'd like to invite a guest to participate in a channel for the duration of a call you can do so by right clicking on them in the Collaboration Panel. "Allowing Write Access" will allow them to edit any projects shared into the call, and to use their microphone and share their screen if they wish.
|
||||
If you'd like to invite a guest to participate in a channel for the duration of a call you can do so by right clicking on them in the Collaboration Panel.
|
||||
"Allowing Write Access" will allow them to edit any projects shared into the call, and to use their microphone and share their screen if they wish.
|
||||
|
||||
## Leaving a Call
|
||||
|
||||
You can leave a channel by clicking on the `Leave call` button in the upper right-hand side of the window.
|
||||
|
||||
18
docs/src/collaboration/contacts-and-private-calls.md
Normal file
18
docs/src/collaboration/contacts-and-private-calls.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# Contacts and Private Calls
|
||||
|
||||
Zed allows you to have private calls / collaboration sessions with those in your contacts.
|
||||
These calls can be one-on-ones or contain any number of users from your contacts.
|
||||
|
||||
## Adding a Contact
|
||||
|
||||
1. In the collaboration panel, click the `+` button next to the `Contacts` section
|
||||
1. Search for the contact using their GitHub handle
|
||||
_Note: The contact must be an existing Zed user who has completed the GitHub authentication flow._
|
||||
1. Your contact will receive a notification.
|
||||
Once they accept, you'll both appear in each other's contact list.
|
||||
|
||||
## Private Calls
|
||||
|
||||
Simply click on a contact to start a private call.
|
||||
|
||||
_Aside from a few additional features (channel notes, etc.), collaboration in private calls is largely the same as it is in [channels](./channels.md)._
|
||||
@@ -2,12 +2,16 @@
|
||||
|
||||
At Zed, we believe that great things are built by great people working together.
|
||||
We have designed Zed to help individuals work faster and help teams of people work together more effectively.
|
||||
Zed has two mechanisms for collaborating:
|
||||
|
||||
In Zed, all collaboration happens in the collaboration panel, which can be opened via {#kb collab_panel::ToggleFocus} or `collab panel: toggle focus` from the command palette.
|
||||
You will need to [sign in](../authentication.md#signing-in) in order to access features within the collaboration panel.
|
||||
|
||||
## Collaboration panel
|
||||
|
||||
The collaboration panel is broken down into two sections:
|
||||
|
||||
1. [Channels](./channels.md): Ongoing project rooms where team members can share projects, collaborate on code, and maintain ambient awareness of what everyone is working on.
|
||||
1. [Private Calls](./private-calls.md): Ad-hoc private collaboration with those in your contacts list.
|
||||
|
||||
You will need to [sign in](../authentication.md#signing-in) in order to begin using Zed's collaboration features.
|
||||
1. [Contacts](./contacts-and-private-calls.md): Ad-hoc private collaboration with those in your contacts list.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
# Private Calls
|
||||
|
||||
## Adding a collaborator to a call
|
||||
|
||||
Before you can collaborate, you'll need to add a collaborator to your contacts. To do this:
|
||||
|
||||
1. Open the contacts menu by clicking on the `Show contacts menu` button in the upper right-hand corner of the window or by running `collab: toggle contacts menu` (`cmd-shift-c`).
|
||||
2. Click the add button to the right of the search box.
|
||||
3. Search for the contact you want to add using their GitHub handle. Note: the person you are trying to add as a contact must be an existing Zed user.
|
||||
|
||||
### Inviting a collaborator
|
||||
|
||||
You can add an existing Zed user as a contact from the contacts menu, deployed from the `Show contacts menu` button in the upper right-hand corner of the window or by `collab: toggle contacts menu` (`cmd-shift-c`) and then clicking the `Search for new contact` button to the right of the search box.
|
||||
|
||||

|
||||
|
||||
When you invite a collaborator to a project not in a call they will receive a notification to join, and a new call is created.
|
||||
|
||||

|
||||
|
||||
### Inviting non-Zed users
|
||||
|
||||
If someone you want to collaborate with has not yet signed up for Zed, they will need to [download the app](https://zed.dev/download) and sign in for the first time before you can add them. Identity is tied to GitHub accounts, so new users will need to authenticate with GitHub in order to sign into Zed.
|
||||
|
||||
### Voice chat
|
||||
|
||||
When joining a call, Zed will automatically share your microphone with other users in the call, if your OS allows it. This isn't tied to your project. You can disable this for your client via the [`mute_on_join`](../configuring-zed.md#calls) setting.
|
||||
|
||||
## Collaborating on a project
|
||||
|
||||
### Share a project
|
||||
|
||||
When you invite a collaborator to join your project, a new call begins. Your Zed windows will show the call participants in the title bar of the window.
|
||||
|
||||

|
||||
|
||||
Collaborators in the same project as you are in color, and have a cursor color. Collaborators in other projects are shown in gray. Collaborators that have access to the current project will have their own cursor color under their avatar.
|
||||
|
||||
We aim to eliminate the distinction between local and remote projects as much as possible. Collaborators can open, edit, and save files, perform searches, interact with the language server, etc. Guests have a read-only view of the project, including access to language server info.
|
||||
|
||||
#### Unshared Projects
|
||||
|
||||
If a collaborator is currently in a project that is not shared, you will not be able to jump to their project or follow them until they either share the project or return to a project that is shared.
|
||||
|
||||
If you are in a project that isn't shared, others will not be able to join it or see its contents.
|
||||
|
||||
### Follow a collaborator
|
||||
|
||||
To follow a collaborator, click on their avatar in the top right of the window. You can also cycle through collaborators using `workspace: follow next collaborator` (`ctrl-alt-cmd-f`).
|
||||
|
||||
When you join a project, you'll immediately start following the collaborator that invited you.
|
||||
|
||||

|
||||
|
||||
When you are in a pane that is following a collaborator, you will:
|
||||
|
||||
- follow their cursor and scroll position
|
||||
- follow them to other files in the same project
|
||||
- instantly swap to viewing their screen in that pane, if they are sharing their screen and leave the project
|
||||
|
||||
If you move your cursor or make an edit in that pane, you will stop following.
|
||||
|
||||
To start following again, you can click on a collaborator's avatar or cycle through following different participants by pressing `workspace: follow next collaborator` (`ctrl-alt-cmd-f`).
|
||||
|
||||
#### How following works
|
||||
|
||||
Following is confined to a particular pane. When a pane is following a collaborator, it is outlined in their cursor color.
|
||||
|
||||
This pane-specific behavior allows you to follow someone in one pane while navigating independently in another and can be an effective layout for some collaboration styles.
|
||||
|
||||
### Sharing your screen
|
||||
|
||||
Share your screen with collaborators in the current call by clicking on the `Share screen` button in the top right of the window.
|
||||
|
||||
Collaborators will see your screen if they are following you and you start viewing a window outside Zed or a project that is not shared.
|
||||
|
||||
Collaborators can see your entire screen when you are screen sharing, so be careful not to share anything you don't want to share. Remember to stop screen sharing when you are finished.
|
||||
|
||||
Call participants can open a dedicated tab for your screen share by opening the contacts menu in the top right and clicking on the `Screen` entry if you are sharing your screen.
|
||||
|
||||
### Adding a project
|
||||
|
||||
You can add a project to a call by clicking on the `Share` button next to the project name in the title bar.
|
||||
|
||||
### Removing a project
|
||||
|
||||
You can remove a project from a call by clicking on the `Unshare` button next to the project name in the title bar.
|
||||
|
||||
Collaborators that are currently in that project will be disconnected from the project and will not be able to rejoin it unless you share it again.
|
||||
|
||||
### Following a collaborator's terminal
|
||||
|
||||
You can follow what a collaborator is doing in their terminal by having them share their screen and following it.
|
||||
|
||||
In the future, we plan to allow you to collaborate in the terminal directly in a shared project.
|
||||
|
||||
### Leave call
|
||||
|
||||
You can leave a call by opening the contacts menu in the top right and clicking on the `Leave call` button.
|
||||
Reference in New Issue
Block a user