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 7b3fffded3
commit da9599140b
21 files changed
+479 -133

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
# Z13: RV10 codex gaps
1. action_c.rs: key-table name, mouse-over-link and open-url use `Keep::counted_bytes` (full bytes + NUL, len always equals the allocation). Audited config_capi/embedded: other pointer+len pairs already match. Test `counted_buffers_hold_exactly_len_bytes`.
2. bench/args.rs keeps every occurrence in order (empty resets default, first error wins, parseBool spellings); lib/benchmark.rs uses `ghostty_os::arg_iterator::ArgIteratorGeneral`.
3. termio `window_title` takes bytes; OSC 7 forwards the raw path.
4. apprt `DesktopNotification`/`MouseOverLink` carry `EncodedOs`; core passes raw bytes; C actions decode them. GTK uses lossy text at the UI boundary.
5. Diagnostic getter decodes the internal encoding (`cstring_value`).
6. `StringError::Utf8CannotEncodeSurrogateHalf`.
7. NaN: both formatters use `format_float_d`.
8. `AppRuntime` + `Config::finalize_for`; process-wide `app_runtime()` (default Gtk on Linux/BSD, None elsewhere); embedded lib / wasm set None. termio installs the cgroup pre-exec/post-fork hooks only for Gtk (Zig `@hasDecl(apprt.runtime, "pre_exec")`).
Gate: workspace tests pass; clippy clean except ghostty-terminal/difftest (DF in-progress edits), which also stops `just check-macos`/`check-windows` at ghostty-terminal; check-wasm passes.