ai_usagebar/process.rs
1//! Child-process conventions shared by every vendor that shells out.
2//!
3//! `ai-usagebar-tray` is a `windows_subsystem = "windows"` process: a console
4//! child spawned from it gets a brand-new console window, which takes the
5//! foreground and blurs the popover (which then hides). Every helper that runs
6//! a CLI for its data must therefore pass [`CREATE_NO_WINDOW`] on Windows.
7
8/// `CREATE_NO_WINDOW` from `PROCESS_CREATION_FLAGS`. Spelled out rather than
9/// imported so the vendor modules stay free of the `windows-sys` feature list.
10#[cfg(windows)]
11pub const CREATE_NO_WINDOW: u32 = 0x0800_0000;
12
13#[cfg(test)]
14mod tests {
15 /// Every non-interactive `Command::new` a vendor runs while collecting a
16 /// report must carry the flag; interactive launches (TUI, `claude` login,
17 /// opening a browser) are exempt by name.
18 #[test]
19 fn report_time_child_processes_never_open_a_console_window() {
20 for file in ["src/supergrok/acp.rs", "src/copilot/credentials.rs"] {
21 let text = std::fs::read_to_string(file).unwrap();
22 assert!(
23 text.contains("creation_flags(crate::process::CREATE_NO_WINDOW)"),
24 "{file} spawns a child without CREATE_NO_WINDOW"
25 );
26 }
27 }
28}