Skip to content

A personal assistant that lives on your desktop, remembers what matters, and can use your Mac for you.

TypeScript

ci: check the desktop shell on windows-latest, with the Windows platform defaults

Marcelitodf3f20b90cc7
diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml
new file mode 100644
index 0000000..d9b2446
--- /dev/null
+++ b/.github/workflows/windows.yml
@@ -0,0 +1,48 @@
+# Windows checks for the native Windows port.
+#
+# The desktop shell is mostly written on Linux and macOS, where its `cfg(windows)` code never
+# compiles, so this is where that code meets a real `x86_64-pc-windows-msvc` toolchain.
+name: Windows
+
+on:
+ push:
+ # `ci/**` branches try workflow changes before they reach `main`.
+ branches: [main, 'ci/**']
+ pull_request:
+ workflow_dispatch:
+
+concurrency:
+ group: windows-${{ github.ref }}
+ cancel-in-progress: true
+
+env:
+ CARGO_TERM_COLOR: always
+
+jobs:
+ rust:
+ name: Rust shell
+ runs-on: windows-latest
+ steps:
+ - uses: actions/checkout@v7
+
+ # The toolchain the Windows port is built and tested with.
+ - uses: dtolnay/[email protected]
+
+ - uses: Swatinem/[email protected]
+ with:
+ workspaces: apps/desktop/src-tauri
+
+ # `tauri.conf.json` points `frontendDist` at the built UI. A debug build does not embed it,
+ # but the folder has to exist, and building the UI here would add the whole pnpm install.
+ - name: UI folder for the build script
+ shell: pwsh
+ run: New-Item -ItemType Directory -Force -Path packages/ui/dist/app | Out-Null
+
+ - name: cargo check
+ working-directory: apps/desktop/src-tauri
+ run: cargo check --locked --all-targets
+
+ - name: cargo test
+ working-directory: apps/desktop/src-tauri
+ run: cargo test --locked --lib
+
diff --git a/apps/desktop/src-tauri/Cargo.lock b/apps/desktop/src-tauri/Cargo.lock
index af698da..f5a049b 100644
--- a/apps/desktop/src-tauri/Cargo.lock
+++ b/apps/desktop/src-tauri/Cargo.lock
@@ -1438,6 +1438,8 @@ dependencies = [
"tauri-plugin-single-instance",
"tiny_http",
"ureq",
+ "windows",
+ "windows-sys 0.61.2",
]
[[package]]
diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.toml
index dd21608..8eaccc6 100644
--- a/apps/desktop/src-tauri/Cargo.toml
+++ b/apps/desktop/src-tauri/Cargo.toml
@@ -36,6 +36,13 @@ sha2 = "0.10"
tar = { version = "0.4", default-features = false }
bzip2 = "0.6"
+# Private daemon transport/lifecycle (T1); pinned to the version already in Cargo.lock.
+[target.'cfg(windows)'.dependencies]
+windows-sys = { version = "=0.61.2", features = ["Win32_Foundation", "Win32_Globalization", "Win32_Security", "Win32_Security_Authorization", "Win32_Security_Cryptography", "Win32_UI_Shell", "Win32_System_Com", "Win32_System_Diagnostics_ToolHelp", "Win32_Storage_FileSystem", "Win32_System_Pipes", "Win32_System_Threading", "Win32_System_JobObjects", "Win32_System_IO", "Win32_System_Registry", "Win32_UI_Controls", "Win32_Graphics_Dwm", "Win32_Graphics_Gdi", "Win32_UI_HiDpi", "Win32_UI_Input_KeyboardAndMouse", "Win32_UI_WindowsAndMessaging"] }
+# Voice capture through WASAPI and computer control through UI Automation and shell links (COM interfaces
+# windows-sys does not bind); the version Tauri already uses.
+windows = { version = "=0.62.2", features = ["Win32_Media_Audio", "Win32_System_Com", "Win32_System_Com_StructuredStorage", "Win32_Storage_FileSystem", "Win32_System_Variant", "Win32_UI_Accessibility", "Win32_UI_Shell"] }
+
# The computer-control helper (S24) is macOS only.
[target.'cfg(target_os = "macos")'.dependencies]
objc2 = "0.6"
diff --git a/apps/desktop/src-tauri/build.rs b/apps/desktop/src-tauri/build.rs
index d4ad26f..d8ee619 100644
--- a/apps/desktop/src-tauri/build.rs
+++ b/apps/desktop/src-tauri/build.rs
@@ -41,17 +41,29 @@ fn main() {
// the absolute `node`, the daemon entry point, and PATH itself (the daemon
// needs it to find `gentle-shell`). Runtime env vars override the first two.
let path = env::var("PATH").unwrap_or_default();
- let node = find_in_path("node", &path)
+ // Select for the Cargo target, not the build-script host (cross builds differ).
+ // GENTLE_DOT_NODE remains a runtime override; no bundled Windows runtime is implied.
+ let program = if env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows") { "node.exe" } else { "node" };
+ let node = find_in_path(program, &path)
.map(|p| p.display().to_string())
- .unwrap_or_else(|| "node".into());
+ .unwrap_or_else(|| program.into());
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
let script = manifest_dir.join("../../../packages/daemon/src/cli.ts");
+ // Windows canonicalize adds a verbatim (\\?\) prefix that Node 24's
+ // entry-point realpathSync rejects. Keep Cargo's absolute manifest path;
+ // Node resolves its parent components without the verbatim prefix.
+ #[cfg(not(windows))]
let script = script.canonicalize().unwrap_or(script);
println!("cargo:rustc-env=GENTLE_DOT_BUILD_NODE={node}");
println!("cargo:rustc-env=GENTLE_DOT_BUILD_DAEMON_SCRIPT={}", script.display());
println!("cargo:rustc-env=GENTLE_DOT_BUILD_PATH={path}");
println!("cargo:rerun-if-env-changed=PATH");
+ // Only package-windows opts in. A normal release checkout must still run from source.
+ let packaged_required = env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows")
+ && env::var("GENTLE_DOT_WINDOWS_PACKAGED_REQUIRED").as_deref() == Ok("1");
+ println!("cargo:rustc-env=GENTLE_DOT_WINDOWS_PACKAGED_REQUIRED={}", if packaged_required { "1" } else { "0" });
+ println!("cargo:rerun-if-env-changed=GENTLE_DOT_WINDOWS_PACKAGED_REQUIRED");
println!(
"cargo:rerun-if-changed={}",
Path::new("../../../packages/daemon/src/cli.ts").display()
diff --git a/apps/desktop/src-tauri/icons/icon.ico b/apps/desktop/src-tauri/icons/icon.ico
new file mode 100644
index 0000000..e8aa0f3
Binary files /dev/null and b/apps/desktop/src-tauri/icons/icon.ico differ
diff --git a/apps/desktop/src-tauri/src/config.rs b/apps/desktop/src-tauri/src/config.rs
index 7aef110..c7f498a 100644
--- a/apps/desktop/src-tauri/src/config.rs
+++ b/apps/desktop/src-tauri/src/config.rs
@@ -4,7 +4,8 @@ use serde::Serialize;
use std::path::{Path, PathBuf};
pub const DEFAULT_PORT: u16 = 4317;
-pub const DEFAULT_SHORTCUT: &str = "Alt+Space";
+/// Windows keeps Alt+Space for the window menu, and overlays such as NVIDIA's claim it as well.
+pub const DEFAULT_SHORTCUT: &str = if cfg!(windows) { "Ctrl+Alt+Space" } else { "Alt+Space" };
#[derive(Debug, Clone, PartialEq)]
pub struct DesktopConfig {
@@ -61,10 +62,21 @@ pub fn parse_config(
DesktopConfig { data_dir, port, shortcut }
}
+/// HOME keeps precedence on every platform; USERPROFILE is a Windows-only fallback.
+/// Pure so profile selection can be checked without reading a real user's environment.
+fn home_dir(env: impl Fn(&str) -> Option<std::ffi::OsString>, windows: bool) -> PathBuf {
+ env("HOME")
+ .filter(|value| !value.is_empty())
+ .or_else(|| windows.then(|| env("USERPROFILE").filter(|value| !value.is_empty())).flatten())
+ .map(PathBuf::from)
+ .unwrap_or_default()
+}
+
/// Reads the real environment and `<data dir>/config.json`.
pub fn load_config() -> DesktopConfig {
let env = |key: &str| std::env::var(key).ok();
- let home = std::env::var_os("HOME").map(PathBuf::from).unwrap_or_default();
+ // OS strings preserve non-UTF-8 Unix HOME paths too.
+ let home = home_dir(|key| std::env::var_os(key), cfg!(windows));
let dir = data_dir(env, &home);
let file = std::fs::read_to_string(dir.join("config.json")).ok();
parse_config(dir, file.as_deref(), env)
@@ -140,10 +152,35 @@ mod tests {
move |key| pairs.iter().find(|(k, _)| *k == key).map(|(_, v)| v.to_string())
}
+ fn os_env_of(pairs: &'static [(&'static str, &'static str)]) -> impl Fn(&str) -> Option<std::ffi::OsString> {
+ move |key| env_of(pairs)(key).map(Into::into)
+ }
+
fn dir() -> PathBuf {
PathBuf::from("/data")
}
+ #[test]
+ fn home_keeps_home_precedence_and_limits_userprofile_to_windows() {
+ let both = || os_env_of(&[("HOME", "/home/me"), ("USERPROFILE", "C:\\Users\\me")]);
+ assert_eq!(home_dir(both(), true), PathBuf::from("/home/me"));
+ assert_eq!(home_dir(both(), false), PathBuf::from("/home/me"));
+ let profile = || os_env_of(&[("USERPROFILE", "C:\\Users\\me")]);
+ assert_eq!(home_dir(profile(), true), PathBuf::from("C:\\Users\\me"));
+ assert_eq!(home_dir(profile(), false), PathBuf::new());
+ assert_eq!(home_dir(os_env_of(&[("HOME", ""), ("USERPROFILE", "C:\\Users\\me")]), true), PathBuf::from("C:\\Users\\me"));
+ assert_eq!(home_dir(os_env_of(&[]), true), PathBuf::new());
+ }
+
+ #[cfg(windows)]
+ #[test]
+ fn windows_profile_default_and_override_use_native_paths() {
+ let home = home_dir(os_env_of(&[("USERPROFILE", "C:\\Users\\me")]), cfg!(windows));
+ assert_eq!(data_dir(env_of(&[]), &home), home.join(".gentle-dot"));
+ assert_eq!(data_dir(env_of(&[("GENTLE_DOT_DATA_DIR", "D:\\dot")]), &home), PathBuf::from("D:\\dot"));
+ assert_eq!(data_dir(env_of(&[("GENTLE_DOT_DATA_DIR", "~/other")]), &home), home.join("other"));
+ }
+
#[test]
fn data_dir_defaults_to_home_dot_folder() {
assert_eq!(data_dir(env_of(&[]), Path::new("/Users/me")), PathBuf::from("/Users/me/.gentle-dot"));
@@ -163,6 +200,16 @@ mod tests {
assert_eq!(config, DesktopConfig { data_dir: dir(), port: DEFAULT_PORT, shortcut: DEFAULT_SHORTCUT.into() });
}
+ #[test]
+ fn windows_default_shortcut_avoids_the_system_window_menu() {
+ // Windows owns Alt+Space (window menu) and overlays such as NVIDIA's claim it too.
+ let expected = if cfg!(windows) { "Ctrl+Alt+Space" } else { "Alt+Space" };
+ assert_eq!(DEFAULT_SHORTCUT, expected);
+ assert_eq!(parse_config(dir(), Some(r#"{ "port": 5000 }"#), env_of(&[])).shortcut, expected);
+ // A saved shortcut still wins, including Alt+Space chosen explicitly.
+ assert_eq!(parse_config(dir(), Some(r#"{ "shortcut": "Alt+Space" }"#), env_of(&[])).shortcut, "Alt+Space");
+ }
+
#[test]
fn reads_port_and_shortcut_from_file() {
let config = parse_config(dir(), Some(r#"{ "port": 5000, "shortcut": "Cmd+Shift+K", "workspace": "~" }"#), env_of(&[]));
diff --git a/apps/desktop/src-tauri/src/platform.rs b/apps/desktop/src-tauri/src/platform.rs
index 76ffd58..59f1b5a 100644
--- a/apps/desktop/src-tauri/src/platform.rs
+++ b/apps/desktop/src-tauri/src/platform.rs
@@ -6,12 +6,25 @@
pub enum Os {
MacOs,
Linux,
+ Windows,
}
impl Os {
- pub const CURRENT: Os = if cfg!(target_os = "macos") { Os::MacOs } else { Os::Linux };
+ pub const CURRENT: Os = if cfg!(target_os = "macos") {
+ Os::MacOs
+ } else if cfg!(target_os = "windows") {
+ Os::Windows
+ } else {
+ Os::Linux
+ };
+
+ /// Windows uses app-managed placement. Preserve the existing environment-based
+ /// placement decision on the original platforms.
+ pub fn compositor_places_windows(self, env: impl Fn(&str) -> Option<String>) -> bool {
+ self != Os::Windows && compositor_places_windows(env)
+ }
- /// Only macOS blurs the desktop behind the panel (`HudWindow`); Linux has no window effects.
+ /// Only macOS blurs the desktop behind the panel (`HudWindow`).
pub fn has_vibrancy(self) -> bool {
self == Os::MacOs
}
@@ -175,6 +188,31 @@ mod tests {
assert_eq!(launch_request(&[]), LaunchRequest::Show);
}
+ #[test]
+ fn windows_frontend_dist_is_a_directory_not_a_cannot_be_base_url() {
+ use tauri::utils::config::FrontendDist;
+
+ // Reproduce the production config ambiguity without opening a webview.
+ let absolute: FrontendDist =
+ serde_json::from_value(serde_json::json!(r"C:\staged runtime\ui")).unwrap();
+ let FrontendDist::Url(url) = absolute else {
+ panic!("expected the absolute drive path to reproduce URL classification");
+ };
+ assert_eq!(url.scheme(), "c");
+ assert!(url.cannot_be_a_base());
+ assert!(url.join(panel_url(Os::Windows)).is_err());
+
+ // Packaging emits forward slashes and a ./ prefix, including when the
+ // first component could otherwise look like a URL scheme.
+ for relative in ["./../../../staged runtime/ui", "./ui", "./c:assets/ui"] {
+ let dist: FrontendDist = serde_json::from_value(serde_json::json!(relative)).unwrap();
+ let FrontendDist::Directory(directory) = dist else {
+ panic!("relative frontend must embed a directory: {relative}");
+ };
+ assert_eq!(directory, std::path::PathBuf::from(relative));
+ }
+ }
+
#[test]
fn the_panel_uses_vibrancy_only_on_macos() {
assert!(Os::MacOs.has_vibrancy());
@@ -183,9 +221,22 @@ mod tests {
assert_eq!(panel_url(Os::Linux), "index.html?surface=panel&effects=none");
}
+ #[test]
+ fn windows_placement_does_not_change_original_platform_decisions() {
+ assert!(!Os::Windows.compositor_places_windows(env_of(GNOME_WAYLAND)));
+ assert_eq!(
+ Os::MacOs.compositor_places_windows(env_of(GNOME_WAYLAND)),
+ compositor_places_windows(env_of(GNOME_WAYLAND)),
+ );
+ assert!(Os::Linux.compositor_places_windows(env_of(GNOME_WAYLAND)));
+ }
+
#[test]
fn current_os_matches_the_build_target() {
assert_eq!(Os::CURRENT == Os::MacOs, cfg!(target_os = "macos"));
+ assert_eq!(Os::CURRENT == Os::Windows, cfg!(target_os = "windows"));
+ #[cfg(windows)]
+ assert_eq!(Os::CURRENT, Os::Windows);
}
#[test]
diff --git a/apps/desktop/src-tauri/src/status.rs b/apps/desktop/src-tauri/src/status.rs
index a1f5128..5994f83 100644
--- a/apps/desktop/src-tauri/src/status.rs
+++ b/apps/desktop/src-tauri/src/status.rs
@@ -6,6 +6,7 @@ use crate::platform::Os;
/// rendered by `apps/desktop/scripts/make-icon.mjs`. On macOS they are 36 px template
/// images, drawn at 18 pt on Retina menu bars. Linux panels can be light or dark and
/// do not tint icons, so Linux gets 32 px glyphs in a light gray with a dark outline.
+/// Windows reuses those colored glyphs without template tinting.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum TrayGlyph {
Ready,
@@ -30,10 +31,10 @@ impl TrayGlyph {
pub fn image(self, os: Os) -> &'static [u8] {
match (os, self) {
(Os::MacOs, _) => self.png(),
- (Os::Linux, Self::Ready) => include_bytes!("../icons/tray/linux/ready.png"),
- (Os::Linux, Self::Working) => include_bytes!("../icons/tray/linux/working.png"),
- (Os::Linux, Self::NeedsYou) => include_bytes!("../icons/tray/linux/needs-you.png"),
- (Os::Linux, Self::Unavailable) => include_bytes!("../icons/tray/linux/unavailable.png"),
+ (Os::Linux | Os::Windows, Self::Ready) => include_bytes!("../icons/tray/linux/ready.png"),
+ (Os::Linux | Os::Windows, Self::Working) => include_bytes!("../icons/tray/linux/working.png"),
+ (Os::Linux | Os::Windows, Self::NeedsYou) => include_bytes!("../icons/tray/linux/needs-you.png"),
+ (Os::Linux | Os::Windows, Self::Unavailable) => include_bytes!("../icons/tray/linux/unavailable.png"),
}
}
}
@@ -137,6 +138,15 @@ mod tests {
}
}
+ #[test]
+ fn windows_reuses_colored_non_template_tray_glyphs() {
+ assert!(!is_template(Os::Windows));
+ for glyph in [TrayGlyph::Ready, TrayGlyph::Working, TrayGlyph::NeedsYou, TrayGlyph::Unavailable] {
+ assert_eq!(glyph.image(Os::Windows), glyph.image(Os::Linux));
+ assert_ne!(glyph.image(Os::Windows), glyph.image(Os::MacOs));
+ }
+ }
+
#[test]
fn only_the_macos_menu_bar_tints_template_glyphs() {
assert!(is_template(Os::MacOs));