Use Project's EntityId as the "window id" for Alacritty PTYs (#35876)

It's unfortunate to need to have access to a GPUI window in order to
create a terminal, because it forces to take a `Window` parameter in
entities that otherwise would have been pure models.

This pull request changes it so that we pass the `Project`'s entity id,
which is equally stable as the window id.

Release Notes:

- N/A

Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com>
This commit is contained in:
Antonio Scandurra 2025-08-08 16:30:49 +02:00 committed by GitHub
parent 95547f099c
commit 51298b6912
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 17 additions and 39 deletions

View file

@ -1654,7 +1654,6 @@ impl Item for TerminalView {
window: &mut Window,
cx: &mut Context<Self>,
) -> Option<Entity<Self>> {
let window_handle = window.window_handle();
let terminal = self
.project
.update(cx, |project, cx| {
@ -1666,7 +1665,6 @@ impl Item for TerminalView {
project.create_terminal_with_venv(
TerminalKind::Shell(working_directory),
python_venv_directory,
window_handle,
cx,
)
})
@ -1802,7 +1800,6 @@ impl SerializableItem for TerminalView {
window: &mut Window,
cx: &mut App,
) -> Task<anyhow::Result<Entity<Self>>> {
let window_handle = window.window_handle();
window.spawn(cx, async move |cx| {
let cwd = cx
.update(|_window, cx| {
@ -1826,7 +1823,7 @@ impl SerializableItem for TerminalView {
let terminal = project
.update(cx, |project, cx| {
project.create_terminal(TerminalKind::Shell(cwd), window_handle, cx)
project.create_terminal(TerminalKind::Shell(cwd), cx)
})?
.await?;
cx.update(|window, cx| {