fix: close remaining gaps found by the completeness audit

Addresses the partial ports listed in
docs/rewrite/notes/review-completeness-codex.md (details in
docs/rewrite/notes/gaps-X2.md):
- Flatpak: the exit watcher no longer consumes the host command; a
  shared FlatpakSignalHandle lets closing a surface still SIGHUP the
  host process group.
- Child environment is byte-preserving end to end (ghostty_os::EnvMap
  of OsStrings) and Snap paths are filtered like filterSnapPaths.
- argv handling no longer panics on non-UTF-8 arguments.
- URI percent-decoding keeps raw bytes; OSC 7 pwd is passed through
  without lossy conversion.
- Keybinding comparison/hashing uses full Unicode case folding from a
  table generated from CaseFolding.txt (Unicode 17.0.0).
- Link regexes set Oniguruma's whole-search retry limit through the new
  minimal ghostty-onig crate (one SAFETY-commented FFI call).
- OSC 9 NUL-capacity check ordering matches Zig.
- Wayland registry binds/clears globals advertised after startup.
- Custom shaders may pass sampler2D to helper functions (naga adapter).
- +list-themes preview renders OSC 8 links, styled underlines and
  follows color-scheme reports.

Also includes the inspector's integration edits in shared files
(renderer state hook, termio VT recording, core/apprt-gtk wiring), X1's
config/input/cli additions for completion generation, and a fix for a
race in the termio backpressure test (it wrote before `stty raw`
applied, so the cooked line discipline dropped bytes past MAX_CANON).

Test Plan:
- cargo test --workspace
- cargo clippy --workspace --all-targets -- -D warnings
This commit is contained in:
ddidderr committed 2026-10-12 04:39:24 +02:00
1 parent d1a5e55198
commit 2aa2a12de0
61 files changed
+4210 -298

No files matched your search

+39 -2
View File
@@ -65,11 +65,39 @@ impl From<crate::comma_splitter::Error> for ArgError {
}
}
/// Coarse classification of a field's Zig type, used by the build-data
/// generator (shell completions) which switches on `@typeInfo(field.type)`.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum FieldKind {
/// `bool`
Bool,
/// `?bool`
OptionalBool,
/// An enum with the given variant names.
Enum(&'static [&'static str]),
/// `?Enum`
OptionalEnum(&'static [&'static str]),
/// An optional of any other type (`?T`).
OptionalOther,
/// A packed struct of bools without `parseCLI`, with its field names.
Packed(&'static [&'static str]),
/// `RepeatablePath`
RepeatablePath,
/// Anything else.
Other,
}
/// A type that can be the value of a configuration / CLI field.
pub trait ConfigField: Clone + PartialEq + Default + fmt::Debug {
/// For enum types, the list of valid values (used in error messages).
const VALID_VALUES: Option<&'static [&'static str]> = None;
/// Classification of this type for completion generation.
const KIND: FieldKind = match Self::VALID_VALUES {
Some(v) => FieldKind::Enum(v),
None => FieldKind::Other,
};
/// Parse `value` (the text after `=`, `None` if there was no `=`) into
/// `self`. Repeatable types accumulate; scalar types overwrite.
fn parse_cli(&mut self, value: Option<&str>) -> Result<(), ArgError>;
@@ -424,6 +452,8 @@ pub fn parse_int_base0(s: &str) -> Option<i128> {
// ConfigField impls for primitives
impl ConfigField for bool {
const KIND: FieldKind = FieldKind::Bool;
fn parse_cli(&mut self, value: Option<&str>) -> Result<(), ArgError> {
*self = parse_bool(value.unwrap_or("t"))?;
Ok(())
@@ -481,6 +511,12 @@ impl ConfigField for String {
}
impl<T: ConfigField> ConfigField for Option<T> {
const KIND: FieldKind = match T::KIND {
FieldKind::Bool => FieldKind::OptionalBool,
FieldKind::Enum(v) => FieldKind::OptionalEnum(v),
_ => FieldKind::OptionalOther,
};
fn parse_cli(&mut self, value: Option<&str>) -> Result<(), ArgError> {
// For optional fields, we just treat it as the child type.
if let Some(v) = self {
@@ -550,8 +586,9 @@ impl<I: Iterator<Item = String>> ArgIter for ArgsIterator<I> {
/// Create an args iterator for the process args. This will skip argv0.
#[must_use]
pub fn args_iterator() -> ArgsIterator<std::iter::Skip<std::env::Args>> {
ArgsIterator::new(std::env::args().skip(1))
pub fn args_iterator() -> ArgsIterator<std::iter::Skip<std::vec::IntoIter<String>>> {
// Byte-safe: never panics on non-UTF-8 arguments.
ArgsIterator::new(ghostty_os::args::collect_lossy().into_iter().skip(1))
}
/// An iterator valid for arg parsing from a slice.
+6
View File
@@ -31,6 +31,8 @@ pub struct FieldInfo<T> {
pub name: &'static str,
/// Raw doc comment lines.
pub doc: &'static [&'static str],
/// Classification of the field's type (for completion generation).
pub kind: crate::cli_args::FieldKind,
/// Deep equality of this field between two structs.
pub eq: fn(&T, &T) -> bool,
/// Format this field as in `+show-config`.
@@ -139,6 +141,7 @@ macro_rules! config_struct {
$crate::macros::FieldInfo {
name: $key,
doc: &[$($doc),*],
kind: <$ty as $crate::cli_args::ConfigField>::KIND,
eq: |a: &$name, b: &$name| a.$field == b.$field,
format: |a: &$name, name: &str, w: &mut dyn ::core::fmt::Write| {
let mut f = $crate::formatter::EntryFormatter::new(name, w);
@@ -268,6 +271,9 @@ macro_rules! config_packed {
}
impl $crate::cli_args::ConfigField for $name {
const KIND: $crate::cli_args::FieldKind =
$crate::cli_args::FieldKind::Packed(Self::NAMES);
fn parse_cli(
&mut self,
value: ::core::option::Option<&str>,
+2
View File
@@ -206,6 +206,8 @@ impl RepeatablePath {
}
impl ConfigField for RepeatablePath {
const KIND: crate::cli_args::FieldKind = crate::cli_args::FieldKind::RepeatablePath;
fn parse_cli(&mut self, input: Option<&str>) -> Result<(), ArgError> {
let Some(item) = Path::parse(input)? else {
self.value.clear();