feat(termio): port the IO thread, Exec backend and stream handler

Ports the remainder of ZIG/src/termio: Options, backend, message,
mailbox, Termio, Thread, Exec and stream_handler.

Threading model (replacing libxev): the IO thread owns Termio and runs a
single poll(2) loop over the mailbox eventfd, a stop eventfd, the child
pidfd and pty POLLOUT, driving Ghostty's timers (25 ms resize
coalescing, 1 s synchronized-output, 15 ms selection scroll, 200 ms
termios polling). A separate pty read thread locks the shared renderer
state and feeds the terminal. Renderer and surface interaction go
through RendererMailbox/SurfaceMailbox traits.

The stream handler answers all queries (DA, DSR, XTVERSION, DECRQM,
OSC color queries, XTGETTCAP, DECRQSS, ...) and forwards titles, pwd,
OSC 52, notifications, progress and bell as surface messages. Zig
unlocks the renderer mutex when a mailbox is full; here overflow goes to
an ordered outbox flushed after the locks drop.

IO1's local stand-ins are replaced with the real config types.

Open: RendererState lives in termio for now (renderer State.zig is
being ported); kitty graphics replies and tmux viewer are not hooked up;
wait-after-command lives in Surface (core); Flatpak stop path needs a
ghostty-os change.

Test Plan:
- cargo test -p ghostty-termio (102 unit + 21 end-to-end tests on a
  real pty, incl. backpressure, DA1 replies, resize coalescing, exits)
This commit is contained in:
ddidderr committed 2026-10-11 22:58:48 +02:00
1 parent 0c92dd0966
commit c81375e6f1
19 files changed
+6170 -195

No files matched your search

+8 -6
View File
@@ -4,17 +4,19 @@ version.workspace = true
edition.workspace = true
license.workspace = true
# NOTE: the `ghostty-config` and `ghostty-terminal` dependencies were removed
# for now (config is being written concurrently, terminal is in progress).
# TODO(integration): re-add them when Exec/Termio/stream_handler are ported and
# replace the local stand-ins (shell_integration::{Command, ShellIntegrationFeatures},
# command::{LinuxCgroup, GtkSingleInstance}).
[dependencies]
crossbeam-channel = "0.5.17"
ghostty-apprt.workspace = true
ghostty-config.workspace = true
ghostty-datastruct.workspace = true
ghostty-os.workspace = true
ghostty-renderer.workspace = true
ghostty-terminal.workspace = true
ghostty-vt.workspace = true
libc = "0.2.190"
log = "0.4.34"
nix = { version = "0.31.3", features = ["signal"] }
rustix = { version = "1.1.5", features = ["fs", "process", "pty", "termios", "stdio"] }
rustix = { version = "1.1.5", features = ["fs", "process", "pty", "termios", "stdio", "event", "pipe"] }
thiserror = "2.0.21"
# Termio forks/execs children and sets up ptys; unsafe is denied by default