diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-22 02:53:42 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-22 02:53:42 +0000 |
| commit | 927950e552b37165327c587818c03d5f45d2c161 (patch) | |
| tree | 87b2b5ea0102d1d23036573f9e7b78e9dd2c0ef4 /bundle | |
| parent | 21eb7861f1ca534b39b81a08a49c843c29ee48b6 (diff) | |
fix(bundle): stop running programs when macOS terminates the app
macOS termination such as Dock Quit skips ExitRequested and window
destruction, so running programs outlived the app. Stop them on
RunEvent::Exit, which every shutdown path reaches.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'bundle')
| -rw-r--r-- | bundle/AGENTS/DEVELOPMENT.md | 2 | ||||
| -rw-r--r-- | bundle/src-tauri/src/main.rs | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/bundle/AGENTS/DEVELOPMENT.md b/bundle/AGENTS/DEVELOPMENT.md index 84270e1..df9ca28 100644 --- a/bundle/AGENTS/DEVELOPMENT.md +++ b/bundle/AGENTS/DEVELOPMENT.md @@ -26,7 +26,7 @@ Windows and macOS nightly jobs cache Rust dependencies from `src-tauri/target` a The language editing core (grammar, configuration, indentation, lexical masking and bracket matching) is shared in full. Platform editor API adapters, file dialogs and process management are separate. Keep the plugin free of Bundle runtime dependencies. -The Rust runner launches the packaged compiler directly, using the source directory as cwd. On Windows its absolute path is captured after extracting into the startup working directory; elsewhere it is the sibling `cpsc` executable. Tokio concurrently writes prefilled stdin and drains both output pipes; stdin is dropped after writing. Each window label has its own Runner, so windows run independently; a watch signal kills and reaps the process on Stop, when its window is destroyed, or on application exit. The output Channel sends raw byte chunks (one streaming TextDecoder per stream in the frontend), then a finished event after both pipes reach EOF. EMBEDDED execution disables the host CRT stdout buffer before JIT initialization; Windows JIT lookups prefer the same msvcrt runtime. Do not introduce a shell or pseudo-terminal. The runner passes `-fdiagnostics-color=always`; `src/ansi.js` renders SGR bold and foreground colors from stderr only, so program stdout stays verbatim. Colors use `--vscode-terminal-ansi*`, which fall back to VS Code's terminal dark defaults pinned in `vendor/vscode/terminal-colors.json` because 2026 Dark does not set them. +The Rust runner launches the packaged compiler directly, using the source directory as cwd. On Windows its absolute path is captured after extracting into the startup working directory; elsewhere it is the sibling `cpsc` executable. Tokio concurrently writes prefilled stdin and drains both output pipes; stdin is dropped after writing. Each window label has its own Runner, so windows run independently; a watch signal kills and reaps the process on Stop, when its window is destroyed, or on `RunEvent::Exit`, which macOS also reaches when it terminates without closing windows (Dock Quit). The output Channel sends raw byte chunks (one streaming TextDecoder per stream in the frontend), then a finished event after both pipes reach EOF. EMBEDDED execution disables the host CRT stdout buffer before JIT initialization; Windows JIT lookups prefer the same msvcrt runtime. Do not introduce a shell or pseudo-terminal. The runner passes `-fdiagnostics-color=always`; `src/ansi.js` renders SGR bold and foreground colors from stderr only, so program stdout stays verbatim. Colors use `--vscode-terminal-ansi*`, which fall back to VS Code's terminal dark defaults pinned in `vendor/vscode/terminal-colors.json` because 2026 Dark does not set them. After building the compiler, run `cargo test --release --manifest-path src-tauri/Cargo.toml`. The two native tests exercise real compilation, prefilled input, EOF, Unicode, diagnostics, output before process exit, stopping, single-run exclusion and restart, including source paths with spaces. CI runs them on all three native platforms. diff --git a/bundle/src-tauri/src/main.rs b/bundle/src-tauri/src/main.rs index 0da6815..37b7431 100644 --- a/bundle/src-tauri/src/main.rs +++ b/bundle/src-tauri/src/main.rs @@ -110,7 +110,8 @@ fn main() { .build(tauri::generate_context!()) .expect("Could not start CPSC Bundle") .run(|app, event| match event { - tauri::RunEvent::ExitRequested { .. } => { + // Also reached when macOS terminates without closing windows, such as Dock Quit. + tauri::RunEvent::Exit => { let runners: Vec<Runner> = app .state::<Runners>() .0 |
