acp: Clean up entry views on rewind (#36197)

We were leaking diffs and terminals on rewind, we'll now clean them up.
This PR also introduces a refactor of how we mantain the entry view
state to use a `Vec` that's kept in sync with the thread entries.

Release Notes:

- N/A
This commit is contained in:
Agus Zubiaga 2025-08-14 15:30:18 -03:00 committed by GitHub
parent 2acfa5e948
commit 43ee604179
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 758 additions and 346 deletions

View file

@ -1575,11 +1575,7 @@ mod tests {
let project = Project::test(fs, [], cx).await;
let connection = Rc::new(FakeAgentConnection::new());
let thread = cx
.spawn(async move |mut cx| {
connection
.new_thread(project, Path::new(path!("/test")), &mut cx)
.await
})
.update(|cx| connection.new_thread(project, Path::new(path!("/test")), cx))
.await
.unwrap();
@ -1699,11 +1695,7 @@ mod tests {
));
let thread = cx
.spawn(async move |mut cx| {
connection
.new_thread(project, Path::new(path!("/test")), &mut cx)
.await
})
.update(|cx| connection.new_thread(project, Path::new(path!("/test")), cx))
.await
.unwrap();
@ -1786,7 +1778,7 @@ mod tests {
.unwrap();
let thread = cx
.spawn(|mut cx| connection.new_thread(project, Path::new(path!("/tmp")), &mut cx))
.update(|cx| connection.new_thread(project, Path::new(path!("/tmp")), cx))
.await
.unwrap();
@ -1849,11 +1841,7 @@ mod tests {
}));
let thread = cx
.spawn(async move |mut cx| {
connection
.new_thread(project, Path::new(path!("/test")), &mut cx)
.await
})
.update(|cx| connection.new_thread(project, Path::new(path!("/test")), cx))
.await
.unwrap();
@ -1961,10 +1949,11 @@ mod tests {
}
}));
let thread = connection
.new_thread(project, Path::new(path!("/test")), &mut cx.to_async())
let thread = cx
.update(|cx| connection.new_thread(project, Path::new(path!("/test")), cx))
.await
.unwrap();
cx.update(|cx| thread.update(cx, |thread, cx| thread.send(vec!["Hi".into()], cx)))
.await
.unwrap();
@ -2021,8 +2010,8 @@ mod tests {
.boxed_local()
}
}));
let thread = connection
.new_thread(project, Path::new(path!("/test")), &mut cx.to_async())
let thread = cx
.update(|cx| connection.new_thread(project, Path::new(path!("/test")), cx))
.await
.unwrap();
@ -2227,7 +2216,7 @@ mod tests {
self: Rc<Self>,
project: Entity<Project>,
_cwd: &Path,
cx: &mut gpui::AsyncApp,
cx: &mut gpui::App,
) -> Task<gpui::Result<Entity<AcpThread>>> {
let session_id = acp::SessionId(
rand::thread_rng()
@ -2237,9 +2226,8 @@ mod tests {
.collect::<String>()
.into(),
);
let thread = cx
.new(|cx| AcpThread::new("Test", self.clone(), project, session_id.clone(), cx))
.unwrap();
let thread =
cx.new(|cx| AcpThread::new("Test", self.clone(), project, session_id.clone(), cx));
self.sessions.lock().insert(session_id, thread.downgrade());
Task::ready(Ok(thread))
}