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:
parent
425f32e068
commit
545ae27079
37 changed files with 1255 additions and 567 deletions
|
@ -23,7 +23,7 @@ use project::{
|
|||
Project, ProjectItem as _, ProjectPath, lsp_store::FormatTrigger,
|
||||
project_settings::ProjectSettings, search::SearchQuery,
|
||||
};
|
||||
use rpc::proto::{self, PeerId, update_view};
|
||||
use rpc::proto::{self, update_view};
|
||||
use settings::Settings;
|
||||
use std::{
|
||||
any::TypeId,
|
||||
|
@ -39,7 +39,7 @@ use theme::{Theme, ThemeSettings};
|
|||
use ui::{IconDecorationKind, prelude::*};
|
||||
use util::{ResultExt, TryFutureExt, paths::PathExt};
|
||||
use workspace::{
|
||||
ItemId, ItemNavHistory, ToolbarItemLocation, ViewId, Workspace, WorkspaceId,
|
||||
CollaboratorId, ItemId, ItemNavHistory, ToolbarItemLocation, ViewId, Workspace, WorkspaceId,
|
||||
item::{FollowableItem, Item, ItemEvent, ProjectItem},
|
||||
searchable::{Direction, SearchEvent, SearchableItem, SearchableItemHandle},
|
||||
};
|
||||
|
@ -170,14 +170,14 @@ impl FollowableItem for Editor {
|
|||
}))
|
||||
}
|
||||
|
||||
fn set_leader_peer_id(
|
||||
fn set_leader_id(
|
||||
&mut self,
|
||||
leader_peer_id: Option<PeerId>,
|
||||
leader_id: Option<CollaboratorId>,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
self.leader_peer_id = leader_peer_id;
|
||||
if self.leader_peer_id.is_some() {
|
||||
self.leader_id = leader_id;
|
||||
if self.leader_id.is_some() {
|
||||
self.buffer.update(cx, |buffer, cx| {
|
||||
buffer.remove_active_selections(cx);
|
||||
});
|
||||
|
@ -350,6 +350,30 @@ impl FollowableItem for Editor {
|
|||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn update_agent_location(
|
||||
&mut self,
|
||||
location: language::Anchor,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
let buffer = self.buffer.read(cx);
|
||||
let buffer = buffer.read(cx);
|
||||
let Some((excerpt_id, _, _)) = buffer.as_singleton() else {
|
||||
return;
|
||||
};
|
||||
let position = buffer.anchor_in_excerpt(*excerpt_id, location).unwrap();
|
||||
let selection = Selection {
|
||||
id: 0,
|
||||
reversed: false,
|
||||
start: position,
|
||||
end: position,
|
||||
goal: SelectionGoal::None,
|
||||
};
|
||||
drop(buffer);
|
||||
self.set_selections_from_remote(vec![selection], None, window, cx);
|
||||
self.request_autoscroll_remotely(Autoscroll::center(), cx);
|
||||
}
|
||||
}
|
||||
|
||||
async fn update_editor_from_message(
|
||||
|
@ -1293,7 +1317,7 @@ impl ProjectItem for Editor {
|
|||
|
||||
fn for_project_item(
|
||||
project: Entity<Project>,
|
||||
pane: &Pane,
|
||||
pane: Option<&Pane>,
|
||||
buffer: Entity<Buffer>,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
|
@ -1304,7 +1328,7 @@ impl ProjectItem for Editor {
|
|||
{
|
||||
if WorkspaceSettings::get(None, cx).restore_on_file_reopen {
|
||||
if let Some(restoration_data) = Self::project_item_kind()
|
||||
.and_then(|kind| pane.project_item_restoration_data.get(&kind))
|
||||
.and_then(|kind| pane.as_ref()?.project_item_restoration_data.get(&kind))
|
||||
.and_then(|data| data.downcast_ref::<EditorRestorationData>())
|
||||
.and_then(|data| {
|
||||
let file = project::File::from_dyn(buffer.read(cx).file())?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue