fix: C action buffer lengths, byte-faithful callbacks, runtime finalize

Resolves the 8 gaps in docs/rewrite/notes/review-rv10-codex.md
(final-Z13.md):
- P1 memory safety: the C key-table action (and hovered-link/open-URL
  payloads) could advertise a length larger than the NUL-truncated
  allocation. A counted_bytes helper now passes the full bytes plus a
  trailing NUL with len == byte count, like Zig's backing slices; all
  C pointer+len structs were audited and tested to read exactly len.
- ghostty-bench args follow cli/args.zig (ordered duplicates, empty
  value resets, first bad value errors, parseBool spellings); the C
  benchmark tokenizer uses the ArgIteratorGeneral port.
- OSC 7 derived titles, desktop notifications and OSC 8 hover links
  forward raw bytes to the runtime; GTK converts only for display.
- C diagnostic getter exports original bytes; escaped surrogates report
  Utf8CannotEncodeSurrogateHalf; config float formatters print `nan`.
- Config::finalize_for(AppRuntime): GTK-only finalization (gtk-single-
  instance=detect) and termio's cgroup hooks apply only to the GTK
  runtime, so libghostty keeps `detect` like Zig.

Test Plan:
- cargo test --workspace --no-fail-fast (exit 0)
- cargo test -p ghostty-lib --features test-platform
- just check-wasm (macOS/Windows clippy re-run after the concurrent
  terminal changes land)
This commit is contained in:
ddidderr committed 2026-10-12 13:09:04 +02:00
1 parent 95fe02b55a
commit f2ccb04aa4
21 files changed
+479 -133

No files matched your search

+8 -4
View File
@@ -613,7 +613,8 @@ pub enum PromptTitle {
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct MouseOverLink {
pub url: String,
/// Raw bytes (Zig `[]const u8`), in the reversible byte encoding.
pub url: ghostty_os::osbytes::EncodedOs,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -664,8 +665,10 @@ impl std::fmt::Display for Pwd {
/// The desktop notification to show.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct DesktopNotification {
pub title: String,
pub body: String,
/// Raw bytes (Zig `[:0]const u8`), in the reversible byte encoding.
pub title: ghostty_os::osbytes::EncodedOs,
/// Raw bytes, like `title`.
pub body: ghostty_os::osbytes::EncodedOs,
}
impl std::fmt::Display for DesktopNotification {
@@ -673,7 +676,8 @@ impl std::fmt::Display for DesktopNotification {
write!(
f,
"DesktopNotification{{ title: {}, body: {} }}",
self.title, self.body
self.title.to_text_lossy(),
self.body.to_text_lossy()
)
}
}