Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 8 additions & 18 deletions .github/workflows/check-process-daemon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: mlugg/setup-zig@8d6198c65fb0feaa111df26e6b467fea8345e46f # v2.0.5
with:
version: 0.16.0
version: 0.17.0
- name: Install Rust
run: rustup toolchain install 1.90.0 --profile minimal --component rustfmt --component clippy
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2
with:
key: core-${{ matrix.os }}-zig-0.16.0
key: core-${{ matrix.os }}-zig-0.17.0
workspaces: packages/process-daemon -> target
cache-workspace-crates: true
- run: cargo fmt --check
Expand Down Expand Up @@ -108,28 +108,18 @@ jobs:
- uses: mlugg/setup-zig@8d6198c65fb0feaa111df26e6b467fea8345e46f # v2.0.5
if: matrix.arch == 'x64'
with:
version: 0.16.0
version: 0.17.0
cache-key: ${{ matrix.target }}
# Zig 0.16 crashes when building Ghostty on the native ARM64 host.
# Zig 0.16 crashed when building Ghostty on the native ARM64 host.
# Use x64-hosted compilers on this ARM64 runner, but execute ARM64 tests natively.
- name: Install x64 Zig for ARM64 cross-compilation
if: matrix.arch == 'arm64'
run: |
$archive = Join-Path $env:RUNNER_TEMP 'zig-x64.zip'
Invoke-WebRequest 'https://ziglang.org/download/0.16.0/zig-x86_64-windows-0.16.0.zip' -OutFile $archive
if ((Get-FileHash $archive -Algorithm SHA256).Hash -ne '68659eb5f1e4eb1437a722f1dd889c5a322c9954607f5edcf337bc3684a75a7e') { throw 'Zig archive checksum mismatch' }
Invoke-WebRequest 'https://ziglang.org/download/0.17.0/zig-x86_64-windows-0.17.0.zip' -OutFile $archive
if ((Get-FileHash $archive -Algorithm SHA256).Hash -ne 'b5663f69581dcf391293fbf16c06cb80d81d806545ce618b4d0bab7f0eb8c428') { throw 'Zig archive checksum mismatch' }
Expand-Archive $archive -DestinationPath $env:RUNNER_TEMP
Join-Path $env:RUNNER_TEMP 'zig-x86_64-windows-0.16.0' >> $env:GITHUB_PATH
- name: Fix Zig 0.16 ARM64 function-pointer alignment
if: matrix.arch == 'arm64'
run: |
# ARM64 function pointers require 4-byte alignment, unlike *anyopaque.
# Zig 0.16's Windows stack-trace helper omits the required alignment assertion.
$file = Join-Path $env:RUNNER_TEMP 'zig-x86_64-windows-0.16.0/lib/std/debug/SelfInfo/Windows.zig'
$source = [System.IO.File]::ReadAllText($file)
$old = '@ptrCast(try si.loadNtdllProc(@tagName(proc)))'
if (!$source.Contains($old)) { throw 'Zig alignment workaround no longer matches; re-evaluate it' }
[System.IO.File]::WriteAllText($file, $source.Replace($old, '@ptrCast(@alignCast(try si.loadNtdllProc(@tagName(proc))))'))
Join-Path $env:RUNNER_TEMP 'zig-x86_64-windows-0.17.0' >> $env:GITHUB_PATH
- name: Install Rust toolchain and target
run: rustup toolchain install $env:RUSTUP_TOOLCHAIN --force-non-host --profile minimal --component rustfmt --component clippy --target $env:CARGO_BUILD_TARGET
- name: Verify runner and compiler architecture
Expand All @@ -148,7 +138,7 @@ jobs:
# No cache-on-failure: a timed-out run once saved a partial cache that broke re-runs.
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2
with:
key: windows-${{ matrix.target }}-zig-0.16.0
key: windows-${{ matrix.target }}-zig-0.17.0
workspaces: packages/process-daemon -> target
# The native Ghostty build is now an output of the workspace crate.
cache-workspace-crates: true
Expand Down
18 changes: 5 additions & 13 deletions .github/workflows/release-process-daemon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ defaults:

env:
CARGO_TERM_COLOR: always
ZIG_VERSION: 0.16.0
ZIG_VERSION: 0.17.0
GNU_GLIBC_VERSION: "2.30"
CARGO_ZIGBUILD_VERSION: 0.23.2

Expand Down Expand Up @@ -188,24 +188,16 @@ jobs:
with:
version: ${{ env.ZIG_VERSION }}
cache-key: release-${{ matrix.target }}
# Zig 0.16 crashes when building Ghostty on the native ARM64 host, so use
# Zig 0.16 crashed when building Ghostty on the native ARM64 host, so use
# the x64-hosted compiler there (matching check-process-daemon.yml).
- name: Install x64 Zig for ARM64 cross-compilation
if: matrix.arch == 'arm64'
run: |
$archive = Join-Path $env:RUNNER_TEMP 'zig-x64.zip'
Invoke-WebRequest 'https://ziglang.org/download/0.16.0/zig-x86_64-windows-0.16.0.zip' -OutFile $archive
if ((Get-FileHash $archive -Algorithm SHA256).Hash -ne '68659eb5f1e4eb1437a722f1dd889c5a322c9954607f5edcf337bc3684a75a7e') { throw 'Zig archive checksum mismatch' }
Invoke-WebRequest 'https://ziglang.org/download/0.17.0/zig-x86_64-windows-0.17.0.zip' -OutFile $archive
if ((Get-FileHash $archive -Algorithm SHA256).Hash -ne 'b5663f69581dcf391293fbf16c06cb80d81d806545ce618b4d0bab7f0eb8c428') { throw 'Zig archive checksum mismatch' }
Expand-Archive $archive -DestinationPath $env:RUNNER_TEMP
Join-Path $env:RUNNER_TEMP 'zig-x86_64-windows-0.16.0' >> $env:GITHUB_PATH
- name: Fix Zig 0.16 ARM64 function-pointer alignment
if: matrix.arch == 'arm64'
run: |
$file = Join-Path $env:RUNNER_TEMP 'zig-x86_64-windows-0.16.0/lib/std/debug/SelfInfo/Windows.zig'
$source = [System.IO.File]::ReadAllText($file)
$old = '@ptrCast(try si.loadNtdllProc(@tagName(proc)))'
if (!$source.Contains($old)) { throw 'Zig alignment workaround no longer matches; re-evaluate it' }
[System.IO.File]::WriteAllText($file, $source.Replace($old, '@ptrCast(@alignCast(try si.loadNtdllProc(@tagName(proc))))'))
Join-Path $env:RUNNER_TEMP 'zig-x86_64-windows-0.17.0' >> $env:GITHUB_PATH
- name: Install Rust toolchain and target
run: rustup toolchain install $env:RUSTUP_TOOLCHAIN --force-non-host --profile minimal --target $env:CARGO_BUILD_TARGET
- name: Build
Expand Down
10 changes: 4 additions & 6 deletions packages/process-daemon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ to the complete response including metadata.

## Verification

Install Git, Rust 1.90.0, and Zig 0.16.0. Normal builds do not need bindgen or
Install Git, Rust 1.90.0, and Zig 0.17.0. Normal builds do not need bindgen or
libclang and do not depend on a third-party Ghostty Rust crate.

```sh
Expand All @@ -238,7 +238,7 @@ printf 'demo\nlist\nquit\n' | cargo run -- play --name play
### Direct Ghostty bindings

`ghostty-revision` pins the official [ghostty-org/ghostty](https://github.com/ghostty-org/ghostty)
source. `build.rs` fetches that commit, builds libghostty with Zig 0.16, and
source. `build.rs` fetches that commit, builds libghostty with Zig 0.17, and
links its static archive (`ghostty-vt-static.lib` on Windows, not the DLL
import library). It uses an isolated checkout under Cargo's build directory.
The package declares `links = "ghostty-vt"` so Cargo rejects dependency graphs
Expand Down Expand Up @@ -292,10 +292,8 @@ MIRIFLAGS=-Zmiri-tree-borrows cargo +nightly-2026-09-02 miri test --locked --man
The Windows jobs in the monorepo's
`.github/workflows/check-process-daemon.yml` build for Windows x64 and ARM64 and execute
tests natively on `windows-2025` and `windows-11-arm`, respectively. The ARM64
job uses x64-hosted compilers targeting ARM64 because native ARM64 Zig 0.16
crashes while building Ghostty; the tests themselves remain native ARM64.
The job also applies a guarded one-line alignment fix to Zig 0.16's Windows
stack-trace helper, which otherwise fails to compile for ARM64.
job uses x64-hosted compilers targeting ARM64; the tests themselves remain
native ARM64.
The workflow runs on pull requests and pushes to `dev` that touch
`packages/process-daemon`, independently of the release workflow.
It checks formatting, builds the executable, runs all enabled tests, and checks
Expand Down
2 changes: 1 addition & 1 deletion packages/process-daemon/ghostty-revision
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ab0b9da9e88fcb4b0533a1854e84628f663930af
83fb95624b0439ee660c2679b43b38c8b63769cd
71 changes: 45 additions & 26 deletions packages/process-daemon/src/ghostty/ffi.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* automatically generated by rust-bindgen 0.72.1 */

// Ghostty revision: ab0b9da9e88fcb4b0533a1854e84628f663930af
// Ghostty revision: 83fb95624b0439ee660c2679b43b38c8b63769cd
// Generated from the official C API; regenerate with script/ghostty-bindings.
#![allow(
dead_code,
Expand All @@ -15,6 +15,9 @@ pub const GHOSTTY_OUT_OF_MEMORY: GhosttyResult = -1;
pub const GHOSTTY_INVALID_VALUE: GhosttyResult = -2;
pub const GHOSTTY_OUT_OF_SPACE: GhosttyResult = -3;
pub const GHOSTTY_NO_VALUE: GhosttyResult = -4;
pub const GHOSTTY_IO_ERROR: GhosttyResult = -5;
pub const GHOSTTY_LIMIT_EXCEEDED: GhosttyResult = -6;
pub const GHOSTTY_REJECTED: GhosttyResult = -7;
pub const GHOSTTY_RESULT_MAX_VALUE: GhosttyResult = 2147483647;
pub type GhosttyResult = ::std::os::raw::c_int;
#[repr(C)]
Expand All @@ -33,7 +36,7 @@ pub const GHOSTTY_FORMATTER_FORMAT_PLAIN: GhosttyFormatterFormat = 0;
pub const GHOSTTY_FORMATTER_FORMAT_VT: GhosttyFormatterFormat = 1;
pub const GHOSTTY_FORMATTER_FORMAT_HTML: GhosttyFormatterFormat = 2;
pub const GHOSTTY_FORMATTER_FORMAT_MAX_VALUE: GhosttyFormatterFormat = 2147483647;
pub type GhosttyFormatterFormat = ::std::os::raw::c_uint;
pub type GhosttyFormatterFormat = ::std::os::raw::c_int;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct GhosttyString {
Expand Down Expand Up @@ -187,7 +190,7 @@ pub const GHOSTTY_POINT_TAG_VIEWPORT: GhosttyPointTag = 1;
pub const GHOSTTY_POINT_TAG_SCREEN: GhosttyPointTag = 2;
pub const GHOSTTY_POINT_TAG_HISTORY: GhosttyPointTag = 3;
pub const GHOSTTY_POINT_TAG_MAX_VALUE: GhosttyPointTag = 2147483647;
pub type GhosttyPointTag = ::std::os::raw::c_uint;
pub type GhosttyPointTag = ::std::os::raw::c_int;
#[repr(C)]
#[derive(Copy, Clone)]
pub union GhosttyPointValue {
Expand Down Expand Up @@ -308,36 +311,19 @@ unsafe extern "C" {
out_written: *mut usize,
) -> GhosttyResult;
}
#[repr(C)]
#[derive(Debug, Default, Copy, Clone)]
pub struct GhosttyTerminalOptions {
pub cols: u16,
pub rows: u16,
pub max_scrollback: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of GhosttyTerminalOptions"][::std::mem::size_of::<GhosttyTerminalOptions>() - 16usize];
["Alignment of GhosttyTerminalOptions"]
[::std::mem::align_of::<GhosttyTerminalOptions>() - 8usize];
["Offset of field: GhosttyTerminalOptions::cols"]
[::std::mem::offset_of!(GhosttyTerminalOptions, cols) - 0usize];
["Offset of field: GhosttyTerminalOptions::rows"]
[::std::mem::offset_of!(GhosttyTerminalOptions, rows) - 2usize];
["Offset of field: GhosttyTerminalOptions::max_scrollback"]
[::std::mem::offset_of!(GhosttyTerminalOptions, max_scrollback) - 8usize];
};
pub const GHOSTTY_SCROLL_VIEWPORT_TOP: GhosttyTerminalScrollViewportTag = 0;
pub const GHOSTTY_SCROLL_VIEWPORT_BOTTOM: GhosttyTerminalScrollViewportTag = 1;
pub const GHOSTTY_SCROLL_VIEWPORT_DELTA: GhosttyTerminalScrollViewportTag = 2;
pub const GHOSTTY_SCROLL_VIEWPORT_ROW: GhosttyTerminalScrollViewportTag = 3;
pub const GHOSTTY_SCROLL_VIEWPORT_DELTA_PROMPT: GhosttyTerminalScrollViewportTag = 4;
pub const GHOSTTY_SCROLL_VIEWPORT_MAX_VALUE: GhosttyTerminalScrollViewportTag = 2147483647;
pub type GhosttyTerminalScrollViewportTag = ::std::os::raw::c_uint;
pub type GhosttyTerminalScrollViewportTag = ::std::os::raw::c_int;
#[repr(C)]
#[derive(Copy, Clone)]
pub union GhosttyTerminalScrollViewportValue {
pub delta: isize,
pub row: usize,
pub delta_prompt: isize,
pub _padding: [u64; 2usize],
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
Expand All @@ -350,6 +336,8 @@ const _: () = {
[::std::mem::offset_of!(GhosttyTerminalScrollViewportValue, delta) - 0usize];
["Offset of field: GhosttyTerminalScrollViewportValue::row"]
[::std::mem::offset_of!(GhosttyTerminalScrollViewportValue, row) - 0usize];
["Offset of field: GhosttyTerminalScrollViewportValue::delta_prompt"]
[::std::mem::offset_of!(GhosttyTerminalScrollViewportValue, delta_prompt) - 0usize];
["Offset of field: GhosttyTerminalScrollViewportValue::_padding"]
[::std::mem::offset_of!(GhosttyTerminalScrollViewportValue, _padding) - 0usize];
};
Expand Down Expand Up @@ -426,8 +414,29 @@ pub const GHOSTTY_TERMINAL_OPT_DEFAULT_CURSOR_BLINK: GhosttyTerminalOption = 23;
pub const GHOSTTY_TERMINAL_OPT_GLYPH_PROTOCOL: GhosttyTerminalOption = 24;
pub const GHOSTTY_TERMINAL_OPT_PWD_CHANGED: GhosttyTerminalOption = 25;
pub const GHOSTTY_TERMINAL_OPT_CLIPBOARD_WRITE: GhosttyTerminalOption = 26;
pub const GHOSTTY_TERMINAL_OPT_SCROLLBACK_MAX_BYTES: GhosttyTerminalOption = 27;
pub const GHOSTTY_TERMINAL_OPT_SCROLLBACK_MAX_LINES: GhosttyTerminalOption = 28;
pub const GHOSTTY_TERMINAL_OPT_DESKTOP_NOTIFICATION: GhosttyTerminalOption = 29;
pub const GHOSTTY_TERMINAL_OPT_PROGRESS_REPORT: GhosttyTerminalOption = 30;
pub const GHOSTTY_TERMINAL_OPT_CONTINUATION_MAX_BYTES: GhosttyTerminalOption = 31;
pub const GHOSTTY_TERMINAL_OPT_TITLE_REPORT: GhosttyTerminalOption = 32;
pub const GHOSTTY_TERMINAL_OPT_MODE_DEFAULT: GhosttyTerminalOption = 33;
pub const GHOSTTY_TERMINAL_OPT_MODE: GhosttyTerminalOption = 34;
pub const GHOSTTY_TERMINAL_OPT_UNKNOWN_SEQUENCE: GhosttyTerminalOption = 35;
pub const GHOSTTY_TERMINAL_OPT_UNKNOWN_MAX_BYTES: GhosttyTerminalOption = 36;
pub const GHOSTTY_TERMINAL_OPT_TERMINFO_NAME: GhosttyTerminalOption = 37;
pub const GHOSTTY_TERMINAL_OPT_CLIPBOARD_READ: GhosttyTerminalOption = 38;
pub const GHOSTTY_TERMINAL_OPT_CLIPBOARD_WRITE_MAX_BYTES: GhosttyTerminalOption = 39;
pub const GHOSTTY_TERMINAL_OPT_RESIZE_PULL_SCROLLBACK: GhosttyTerminalOption = 40;
pub const GHOSTTY_TERMINAL_OPT_RENDER_HOLD: GhosttyTerminalOption = 41;
pub const GHOSTTY_TERMINAL_OPT_SEMANTIC_PROMPT: GhosttyTerminalOption = 42;
pub const GHOSTTY_TERMINAL_OPT_RESET: GhosttyTerminalOption = 43;
pub const GHOSTTY_TERMINAL_OPT_XT_CHECKSUM_REPORT: GhosttyTerminalOption = 44;
pub const GHOSTTY_TERMINAL_OPT_XT_CHECKSUM_EXTENSION: GhosttyTerminalOption = 45;
pub const GHOSTTY_TERMINAL_OPT_PROGRAM_STATUS: GhosttyTerminalOption = 46;
pub const GHOSTTY_TERMINAL_OPT_RESIZE_WINDOW: GhosttyTerminalOption = 47;
pub const GHOSTTY_TERMINAL_OPT_MAX_VALUE: GhosttyTerminalOption = 2147483647;
pub type GhosttyTerminalOption = ::std::os::raw::c_uint;
pub type GhosttyTerminalOption = ::std::os::raw::c_int;
pub const GHOSTTY_TERMINAL_DATA_INVALID: GhosttyTerminalData = 0;
pub const GHOSTTY_TERMINAL_DATA_COLS: GhosttyTerminalData = 1;
pub const GHOSTTY_TERMINAL_DATA_ROWS: GhosttyTerminalData = 2;
Expand Down Expand Up @@ -462,13 +471,23 @@ pub const GHOSTTY_TERMINAL_DATA_KITTY_GRAPHICS: GhosttyTerminalData = 30;
pub const GHOSTTY_TERMINAL_DATA_SELECTION: GhosttyTerminalData = 31;
pub const GHOSTTY_TERMINAL_DATA_VIEWPORT_ACTIVE: GhosttyTerminalData = 32;
pub const GHOSTTY_TERMINAL_DATA_VT_PROCESSING_ERROR: GhosttyTerminalData = 33;
pub const GHOSTTY_TERMINAL_DATA_SCROLLBACK_MAX_BYTES: GhosttyTerminalData = 34;
pub const GHOSTTY_TERMINAL_DATA_SCROLLBACK_MAX_LINES: GhosttyTerminalData = 35;
pub const GHOSTTY_TERMINAL_DATA_CONTINUATION_MAX_BYTES: GhosttyTerminalData = 36;
pub const GHOSTTY_TERMINAL_DATA_MODE: GhosttyTerminalData = 37;
pub const GHOSTTY_TERMINAL_DATA_VT_GROUND: GhosttyTerminalData = 38;
pub const GHOSTTY_TERMINAL_DATA_CURSOR_AT_PROMPT: GhosttyTerminalData = 39;
pub const GHOSTTY_TERMINAL_DATA_CLIPBOARD_WRITE_MAX_BYTES: GhosttyTerminalData = 40;
pub const GHOSTTY_TERMINAL_DATA_MOUSE_SHAPE: GhosttyTerminalData = 41;
pub const GHOSTTY_TERMINAL_DATA_MEMORY_USAGE: GhosttyTerminalData = 42;
pub const GHOSTTY_TERMINAL_DATA_MAX_VALUE: GhosttyTerminalData = 2147483647;
pub type GhosttyTerminalData = ::std::os::raw::c_uint;
pub type GhosttyTerminalData = ::std::os::raw::c_int;
unsafe extern "C" {
pub fn ghostty_terminal_new(
allocator: *const GhosttyAllocator,
terminal: *mut GhosttyTerminal,
options: GhosttyTerminalOptions,
cols: u16,
rows: u16,
) -> GhosttyResult;
}
unsafe extern "C" {
Expand Down
19 changes: 9 additions & 10 deletions packages/process-daemon/src/ghostty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,24 @@ impl Terminal {
let mut raw = ptr::null_mut();
// SAFETY: options match the pinned C header; NULL selects Ghostty's allocator.
check(unsafe {
ffi::ghostty_terminal_new(
ptr::null(),
&mut raw,
ffi::GhosttyTerminalOptions {
cols: options.cols,
rows: options.rows,
max_scrollback: options.max_scrollback,
},
)
ffi::ghostty_terminal_new(ptr::null(), &mut raw, options.cols, options.rows)
})?;
let terminal = Self {
raw: NonNull::new(raw).context("Ghostty returned a null terminal")?,
effects: Effects::default(),
_actor: PhantomData,
};

// SAFETY: userdata is an Rc-derived shared pointer retained until after terminal_free.
// SAFETY: the scrollback value is a usize for the duration of the call, and
// userdata is an Rc-derived shared pointer retained until after terminal_free.
// These callbacks only copy responses/mark a title change; they never reenter Ghostty.
unsafe {
let max_scrollback = options.max_scrollback;
check(ffi::ghostty_terminal_set(
raw,
ffi::GHOSTTY_TERMINAL_OPT_SCROLLBACK_MAX_BYTES,
&max_scrollback as *const usize as *const _,
))?;
check(ffi::ghostty_terminal_set(
raw,
ffi::GHOSTTY_TERMINAL_OPT_USERDATA,
Expand Down
2 changes: 1 addition & 1 deletion packages/process-daemon/src/musl.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::ffi::{c_char, c_int, c_uint, c_void};

/// Zig 0.16 assumes musl provides `statx` (added in musl 1.2.5), so libghostty
/// Zig 0.17 assumes musl provides `statx` (added in musl 1.2.5), so libghostty
/// references it, but Rust's self-contained musl is older. Forward to the raw
/// syscall exactly as musl's own wrapper does.
///
Expand Down
Loading