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

@ -63,9 +63,9 @@ use std::{
use thiserror::Error;
use gpui::{
AnyWindowHandle, App, AppContext as _, Bounds, ClipboardItem, Context, EventEmitter, Hsla,
Keystroke, Modifiers, MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, Pixels, Point,
Rgba, ScrollWheelEvent, SharedString, Size, Task, TouchPhase, Window, actions, black, px,
App, AppContext as _, Bounds, ClipboardItem, Context, EventEmitter, Hsla, Keystroke, Modifiers,
MouseButton, MouseDownEvent, MouseMoveEvent, MouseUpEvent, Pixels, Point, Rgba,
ScrollWheelEvent, SharedString, Size, Task, TouchPhase, Window, actions, black, px,
};
use crate::mappings::{colors::to_alac_rgb, keys::to_esc_str};
@ -351,7 +351,7 @@ impl TerminalBuilder {
alternate_scroll: AlternateScroll,
max_scroll_history_lines: Option<usize>,
is_ssh_terminal: bool,
window: AnyWindowHandle,
window_id: u64,
completion_tx: Sender<Option<ExitStatus>>,
cx: &App,
) -> Result<TerminalBuilder> {
@ -463,11 +463,7 @@ impl TerminalBuilder {
let term = Arc::new(FairMutex::new(term));
//Setup the pty...
let pty = match tty::new(
&pty_options,
TerminalBounds::default().into(),
window.window_id().as_u64(),
) {
let pty = match tty::new(&pty_options, TerminalBounds::default().into(), window_id) {
Ok(pty) => pty,
Err(error) => {
bail!(TerminalError {