From baeaac722de177951a8a1a44d2ef39cd5d39a033 Mon Sep 17 00:00:00 2001 From: skylar taylor-barrick Date: Thu, 26 Nov 2026 02:00:17 -0600 Subject: [PATCH] Nightly: stop blocking a refused launch on macOS (#4752) Nightly launch fix under Skylar's Exec 454: the Launcher's trailing `--` no longer reaches the file list where that applied, and a refused launch no longer blocks on macOS (the reason goes to stderr and the app exits 2). The red sonarcloud / SonarCloud Scan check is inherited: coverage shards 1, 3, 4, 7 and 8 each report three teardown SIGSEGVs in lightcraft-ui-egui UI tests, with zero FAILED tests and zero panics. It is the GPU warm-up thread still running at process exit, which lightcraft #4697 fixes (awaiting Fred). Every gate and test job on this PR is green. --- apps/lightcraft/src/main.rs | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/apps/lightcraft/src/main.rs b/apps/lightcraft/src/main.rs index 2c3b4cac2f..9d609aa20c 100644 --- a/apps/lightcraft/src/main.rs +++ b/apps/lightcraft/src/main.rs @@ -266,13 +266,22 @@ fn initialize_nightly_process_identity() -> Result<(), process_identity::Identit ) } -/// A launcher script has no terminal: say why it refused, in a native dialog on a desktop session. +/// Whether a refusal may also open a native message box. Standard error always carries the reason; +/// this only adds a box where one renders without the app's event loop. Never on macOS: rfd's alert +/// there needs the AppKit run loop this start has not reached, so a refused nightly launch hung in +/// an invisible modal instead of exiting (GridCraft Mac smoke, 2026-11-26). +fn refusal_dialog(flavor: build_flavor::BuildFlavor, desktop_session: bool, macos: bool) -> bool { + build_flavor::needs_native_error(flavor, desktop_session) && !macos +} + +/// A launcher script has no terminal: say why it refused, in a native dialog on a Windows or +/// X11/Wayland desktop session. macOS gets the console line only (`refusal_dialog`). fn report_launch_profile_error(error: &str) { eprintln!("LightCraft launch profile: {error}"); let desktop_session = cfg!(windows) || cfg!(target_os = "macos") || (cfg!(target_os = "linux") && ["DISPLAY", "WAYLAND_DISPLAY"].into_iter().any(|key| std::env::var_os(key).is_some_and(|v| !v.is_empty()))); - if build_flavor::needs_native_error(build_flavor::COMPILED, desktop_session) { + if refusal_dialog(build_flavor::COMPILED, desktop_session, cfg!(target_os = "macos")) { if let Err(error) = initialize_nightly_process_identity() { eprintln!("LightCraft launch profile: {error}"); return; @@ -714,3 +723,17 @@ fn main() -> eframe::Result { #[cfg(test)] #[allow(clippy::unwrap_used)] mod tests; + +#[cfg(test)] +mod refusal_dialog_tests { + use super::refusal_dialog; + use crate::build_flavor::BuildFlavor; + + #[test] + fn a_refusal_never_blocks_on_a_modal_before_the_event_loop_on_macos() { + assert!(refusal_dialog(BuildFlavor::NightlyV1, true, false), "a desktop refusal still shows the box where one renders"); + assert!(!refusal_dialog(BuildFlavor::NightlyV1, true, true), "macOS has no run loop yet: the modal would hang"); + assert!(!refusal_dialog(BuildFlavor::NightlyV1, false, false), "a headless session has no box"); + assert!(!refusal_dialog(BuildFlavor::Stable, true, false), "only a nightly refusal explains itself in a box"); + } +}