Visual Studio Code, rebuilt in Rust
Rust
build(macos): require macOS 13.0, as libghostty-vt is built for it
rokartur85c22fda7bd1
diff --git a/port/notes.md b/port/notes.mdindex 8a6fcc3c5bf..492d557cf37 100644--- a/port/notes.md+++ b/port/notes.md@@ -630,7 +630,7 @@ Scope (milestone 13): diagnostics, hover, completion, go to definition and peek,## Milestone 15: integrated terminal- Backend: libghostty-vt 1.0.2 (MIT, tag `vt-1.0.2`, Ghostty's C API VT library) is the VT parser and screen model in place of xterm.js, behind `native/crates/ghostty_vt`, a safe `Term` with no `unsafe` of its own on the libghostty-rs bindings (`libghostty-vt` and `libghostty-vt-sys`, MIT OR Apache-2.0, https://github.com/uzaaft/libghostty-rs); the PTY is the port's own node-pty (`terminal/pty.rs`: openpty, setsid, TIOCSCTTY, PWD set to the cwd as `unixTerminal.ts` does; ConPTY on Windows). Wu's `terminal` crate is GPL-3.0 and is not used. It replaced `alacritty_terminal` 0.25 for the parser's throughput and for a maintained VT core with a stable C ABI; `Term` keeps alacritty's shapes (`Line` relative to the active area's top, negative into the scrollback, `Point`, `Cell`, `Flags`, `TermMode`) so the call sites read the same.-- libghostty-rs is a git dependency on the port's fork, https://github.com/rokartur/libghostty-rs branch `vsrustium` (rev 10df3e18), one commit over uzaaft's d3a306c, not crates.io 0.2.2: 0.2.2's `libghostty-vt-sys` builds Ghostty a887df42, 2333 commits before `vt-1.0.2`, and d3a306c builds `vt-1.0.2` (573c4a21). The fork's commit touches only `libghostty-vt-sys/build.rs`: (1) VS16 patch: Ghostty 1.0.2 drops U+FE0F after an emoji modifier base (U+270C, U+1F44D) outside mode 2027, as uucode gives those `emoji_modifier_base` rather than `extended_pictographic`, while xterm.js keeps it, so copied text keeps it (`ghostty_vt` `a_variation_selector_stays_with_its_emoji`, `prompt_input` `emoji_input`); the build stops when the patched line in `Terminal.zig` is not there exactly once, and Ghostty main still has the bug; (2) an MSVC cross build from a non-Windows host (`port/tools/windows-build`) builds the `*-windows-gnu` archive, as Zig 0.17 cannot compile the bundled simdutf and highway against cargo-xwin's MSVC SDK (Microsoft's link.exe rejects that archive's COMDATs, LNK1143, lld-link takes it); (3) the static Windows archive links ntdll. Drop the fork when upstream takes these: (2) and (3) fit an upstream PR, (1) belongs in Ghostty. The pin is the rev in Cargo.lock plus the Ghostty commit in the sys crate's `build.rs`, which clones Ghostty by commit (SHA-1, where the old build checked the release tarballs' SHA-256) and builds it with Zig 0.17 (`-Dcpu=baseline`); `zig build` checks the dependencies against `build.zig.zon`'s hashes. `native/.cargo/config.toml` sets `LIBGHOSTTY_VT_SYS_OPTIMIZE=ReleaseFast`: the sys build picks Zig Debug whenever cargo's `DEBUG` is true, which the release profile's `debug = "limited"` makes it, and Debug's page integrity checks made a 32 MB `cat` take minutes. On a macOS host Ghostty's `Config.zig` replaces any `-Dtarget` with its generic macOS 13.0 target, so the library's objects say `minos 13.0` (with the old build too) while `package-app` writes `LSMinimumSystemVersion` 12.0. The paint path reads the viewport through the render state (`Term::viewport_rows`): libghostty-rs's examples (`example/ghostling_rs`, `example/rust-vt-render`) read each cell's style through `CellIteration::style`, while `viewport_rows` reads a row's raw cells in one call and looks a style up once per style id in the row. macOS arm64 and Linux arm64/x64 build their own target; Windows builds `*-windows-msvc` from source on Windows (windows.yml). Zig is in the Linux image, linux.yml and `.github/actions/setup`.+- libghostty-rs is a git dependency on the port's fork, https://github.com/rokartur/libghostty-rs branch `vsrustium` (rev 10df3e18), one commit over uzaaft's d3a306c, not crates.io 0.2.2: 0.2.2's `libghostty-vt-sys` builds Ghostty a887df42, 2333 commits before `vt-1.0.2`, and d3a306c builds `vt-1.0.2` (573c4a21). The fork's commit touches only `libghostty-vt-sys/build.rs`: (1) VS16 patch: Ghostty 1.0.2 drops U+FE0F after an emoji modifier base (U+270C, U+1F44D) outside mode 2027, as uucode gives those `emoji_modifier_base` rather than `extended_pictographic`, while xterm.js keeps it, so copied text keeps it (`ghostty_vt` `a_variation_selector_stays_with_its_emoji`, `prompt_input` `emoji_input`); the build stops when the patched line in `Terminal.zig` is not there exactly once, and Ghostty main still has the bug; (2) an MSVC cross build from a non-Windows host (`port/tools/windows-build`) builds the `*-windows-gnu` archive, as Zig 0.17 cannot compile the bundled simdutf and highway against cargo-xwin's MSVC SDK (Microsoft's link.exe rejects that archive's COMDATs, LNK1143, lld-link takes it); (3) the static Windows archive links ntdll. Drop the fork when upstream takes these: (2) and (3) fit an upstream PR, (1) belongs in Ghostty. The pin is the rev in Cargo.lock plus the Ghostty commit in the sys crate's `build.rs`, which clones Ghostty by commit (SHA-1, where the old build checked the release tarballs' SHA-256) and builds it with Zig 0.17 (`-Dcpu=baseline`); `zig build` checks the dependencies against `build.zig.zon`'s hashes. `native/.cargo/config.toml` sets `LIBGHOSTTY_VT_SYS_OPTIMIZE=ReleaseFast`: the sys build picks Zig Debug whenever cargo's `DEBUG` is true, which the release profile's `debug = "limited"` makes it, and Debug's page integrity checks made a 32 MB `cat` take minutes. On a macOS host Ghostty's `Config.zig` replaces any `-Dtarget` with its generic macOS 13.0 target, so the library's objects say `minos 13.0` (with the old build too); Artur raised `package-app`'s `LSMinimumSystemVersion` from 12.0 to 13.0 to match, which is also Ghostty's own minimum (Apple's oldest supported macOS). The paint path reads the viewport through the render state (`Term::viewport_rows`): libghostty-rs's examples (`example/ghostling_rs`, `example/rust-vt-render`) read each cell's style through `CellIteration::style`, while `viewport_rows` reads a row's raw cells in one call and looks a style up once per style id in the row. macOS arm64 and Linux arm64/x64 build their own target; Windows builds `*-windows-msvc` from source on Windows (windows.yml). Zig is in the Linux image, linux.yml and `.github/actions/setup`.- What the port takes from libghostty-vt and what it keeps: the grid, scrollback, modes, cursor style, OSC 4/10/11/12 colors, title, bell, DA1/DA2/XTVERSION replies (set to xterm.js 6.1.0-beta.337's: `?1;2c`, `>0;276;0c`) come from libghostty-vt's callbacks; OSC 52, OSC 633/133/1337/7 stay with `terminal/shell_integration.rs` (it splits the stream before the parser), OSC 99 with `terminal/osc99.rs`, keys and mouse reports with `terminal/keys.rs` and `terminal/mouse.rs` (xterm.js's encodings, not libghostty-vt's key encoder). Selection follows alacritty 0.25's rules (`ghostty_vt/src/selection.rs`: simple, semantic, lines, block) with its anchors as libghostty-vt tracked references, so a selection moves with scrolled output as xterm.js's does. libghostty-rs's `selection::Gesture` is not used: it is Ghostty's click and drag model (its click counts, word boundaries and text formatting), while the port's selection tests pin xterm.js-shaped results.- Terminal throughput and typing (Mac Studio, release): `cat` of 32 MB of colored `ls -l` lines into a 120x40 terminal with 10000 lines of scrollback, 143 MB/s with alacritty_terminal, 700 MB/s with libghostty-vt; reading the 4800 visible cells after one echoed key, p95 8 us with alacritty, 120 us with libghostty-vt (each cell is a grid reference call); a key echoed and the workbench drawn (`terminal_typing_frame_time`), p95 4.0 to 4.4 ms before and 4.0 to 5.1 ms after, against the 16 ms gate. Moving to libghostty-rs, same Studio under load, one run each after a warm build: the in-process `Term::advance` of the same 32 MB, 484 MB/s on the port's own bindings and 487 MB/s on libghostty-rs; the 4800 visible cells, median 119 us (p95 128) cell by cell on the port's bindings, 291 us (p95 294) cell by cell on libghostty-rs, which `viewport_rows` brings to 122 us (p95 125); `terminal_typing_frame_time` p95 5.16 ms before and 4.40 ms after.- Keys follow xterm.js `Keyboard.ts` (`terminal/keys.rs`), mouse reports `CoreMouseService` DEFAULT and SGR (`terminal/mouse.rs`). `terminal/skip_shell.rs` is `DEFAULT_COMMANDS_TO_SKIP_SHELL` plus the terminalContrib lists of 1.147.0: a keybinding to one of them runs instead of reaching the shell.diff --git a/port/tools/package-app b/port/tools/package-appindex 3a6a8d237b9..6ccf389112d 100755--- a/port/tools/package-app+++ b/port/tools/package-app@@ -101,7 +101,8 @@ const plist = {CFBundleDocumentTypes: reference.CFBundleDocumentTypes,CFBundleURLTypes: [{ CFBundleTypeRole: 'Viewer', CFBundleURLName: product.nameLong, CFBundleURLSchemes: [product.urlProtocol] }],LSApplicationCategoryType: 'public.app-category.developer-tools',- LSMinimumSystemVersion: '12.0',+ // libghostty-vt builds for macOS 13.0 at the least: Ghostty's Config.zig forces it on a macOS host.+ LSMinimumSystemVersion: '13.0',NSHighResolutionCapable: true,NSSupportsAutomaticGraphicsSwitching: true,NSPrincipalClass: 'NSApplication',