Add the ability to follow the agent as it makes edits (#29839)

Nathan here: I also tacked on a bunch of UI refinement.

Release Notes:

- Introduced the ability to follow the agent around as it reads and
edits files.

---------

Co-authored-by: Nathan Sobo <nathan@zed.dev>
Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
Antonio Scandurra 2025-05-04 10:28:39 +02:00 committed by GitHub
parent 425f32e068
commit 545ae27079
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
37 changed files with 1255 additions and 567 deletions

View file

@ -19,8 +19,8 @@ pub use crate::{
};
use anyhow::{Context as _, Result, anyhow};
use async_watch as watch;
use clock::Lamport;
pub use clock::ReplicaId;
use clock::{AGENT_REPLICA_ID, Lamport};
use collections::HashMap;
use fs::MTime;
use futures::channel::oneshot;
@ -2132,6 +2132,31 @@ impl Buffer {
}
}
pub fn set_agent_selections(
&mut self,
selections: Arc<[Selection<Anchor>]>,
line_mode: bool,
cursor_shape: CursorShape,
cx: &mut Context<Self>,
) {
let lamport_timestamp = self.text.lamport_clock.tick();
self.remote_selections.insert(
AGENT_REPLICA_ID,
SelectionSet {
selections: selections.clone(),
lamport_timestamp,
line_mode,
cursor_shape,
},
);
self.non_text_state_update_count += 1;
cx.notify();
}
pub fn remove_agent_selections(&mut self, cx: &mut Context<Self>) {
self.set_agent_selections(Arc::default(), false, Default::default(), cx);
}
/// Replaces the buffer's entire text.
pub fn set_text<T>(&mut self, text: T, cx: &mut Context<Self>) -> Option<clock::Lamport>
where