From 004d736f8d5bee8a6d6af743d55949febce77a8f Mon Sep 17 00:00:00 2001 From: iamtoruk Date: Tue, 1 Sep 2026 14:59:38 -0700 Subject: [PATCH] fix(windows): warn when launched on a hidden window station The invisible Capacity Dock was not a rendering bug. The debug exe had been started through the QEMU guest agent's guest-exec, which runs as a service in session 0, so the dock window was created on a window station that no desktop shows. The stderr trace ("window created and shown") was accurate; the window was simply never visible. Launched from the interactive session, the same binary docks the rail at the right edge, shows the quiet "--" row without providers, expands on hover, closes on toggle off and comes back on toggle on. Debug builds on Windows now check the process window station for WSF_VISIBLE at startup and print a warning when it is missing, so the next service session launch explains itself. Verified: fires under a SYSTEM scheduled task, silent from a terminal. Only a feature flag is added to the existing windows-sys dependency; no versions change. --- windows/src-tauri/Cargo.toml | 2 +- windows/src-tauri/src/lib.rs | 37 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/windows/src-tauri/Cargo.toml b/windows/src-tauri/Cargo.toml index a11a240d..723d3a75 100644 --- a/windows/src-tauri/Cargo.toml +++ b/windows/src-tauri/Cargo.toml @@ -28,7 +28,7 @@ reqwest = { version = "0.12", default-features = false, features = ["json", "rus fontdue = "0.9" [target.'cfg(target_os = "windows")'.dependencies] -windows-sys = { version = "0.59", features = ["Win32_Foundation", "Win32_Graphics_Dwm", "Win32_UI_WindowsAndMessaging"] } +windows-sys = { version = "0.59", features = ["Win32_Foundation", "Win32_Graphics_Dwm", "Win32_System_StationsAndDesktops", "Win32_UI_WindowsAndMessaging"] } [target.'cfg(target_os = "linux")'.dependencies] ksni = "0.3" diff --git a/windows/src-tauri/src/lib.rs b/windows/src-tauri/src/lib.rs index f53df25c..335da82a 100644 --- a/windows/src-tauri/src/lib.rs +++ b/windows/src-tauri/src/lib.rs @@ -70,6 +70,9 @@ pub fn run() { plan: plan::PlanClient::new(), }); + #[cfg(all(debug_assertions, target_os = "windows"))] + warn_if_window_station_hidden(); + #[cfg(not(target_os = "linux"))] build_tray_tauri(app.handle())?; @@ -281,6 +284,40 @@ fn parse_click(payload: &str) -> Option<(i32, i32)> { Some((x, y)) } +/// A process started from a service session (the QEMU guest agent's guest-exec, SSH, a +/// scheduled task) gets a window station nobody is looking at: the tray icon and every window, +/// dock included, report success and never reach the desktop. That exact trace cost a full +/// debugging round on the VM, so debug builds now say so on startup. +#[cfg(all(debug_assertions, target_os = "windows"))] +fn warn_if_window_station_hidden() { + use windows_sys::Win32::System::StationsAndDesktops::{ + GetProcessWindowStation, GetUserObjectInformationW, UOI_FLAGS, USEROBJECTFLAGS, + }; + const WSF_VISIBLE: u32 = 0x0001; + + let mut flags = USEROBJECTFLAGS { + fInherit: 0, + fReserved: 0, + dwFlags: 0, + }; + let mut needed = 0u32; + let ok = unsafe { + GetUserObjectInformationW( + GetProcessWindowStation(), + UOI_FLAGS, + &mut flags as *mut USEROBJECTFLAGS as *mut std::ffi::c_void, + std::mem::size_of::() as u32, + &mut needed, + ) + }; + if ok != 0 && flags.dwFlags & WSF_VISIBLE == 0 { + eprintln!( + "codeburn: running on a non-interactive window station (service session launch); \ + the tray icon and windows will never appear on the desktop" + ); + } +} + /// Undecorated windows are square by default; ask DWM for the Windows 11 rounded corner so /// the acrylic backdrop is clipped to the same shape as the popover card. Silently ignored /// on Windows 10, where the corners stay square.