A personal assistant that lives on your desktop, remembers what matters, and can use your Mac for you.
TypeScript
fix(desktop): build the shell on Windows with the daemon unavailable for now
Marcelito051152850129
diff --git a/apps/desktop/src-tauri/src/app_channel.rs b/apps/desktop/src-tauri/src/app_channel.rsindex 1b0d2f0..178cd8f 100644--- a/apps/desktop/src-tauri/src/app_channel.rs+++ b/apps/desktop/src-tauri/src/app_channel.rs@@ -25,7 +25,10 @@ use serde_json::{json, Value};use std::collections::HashMap;use std::io::{self, BufRead, BufReader, Read, Write};use std::net::Shutdown;+#[cfg(unix)]use std::os::unix::net::UnixStream;+#[cfg(windows)]+use unavailable::UnixStream;use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};use std::sync::{mpsc, Arc, Mutex, PoisonError};use std::time::Duration;@@ -288,7 +291,44 @@ impl AppChannel {}}-#[cfg(test)]+/// Temporary seam of the Windows port (gentle-dot#89): the channel's Windows transport lands with+/// the daemon lifecycle. Until then this stream only lets the module compile on Windows, where no+/// daemon is spawned, so no value of it can exist.+#[cfg(windows)]+mod unavailable {+ use std::io;+ use std::net::Shutdown;++ pub enum UnixStream {}++ impl UnixStream {+ pub fn try_clone(&self) -> io::Result<Self> {+ match *self {}+ }++ pub fn shutdown(&self, _how: Shutdown) -> io::Result<()> {+ match *self {}+ }+ }++ impl io::Read for UnixStream {+ fn read(&mut self, _buf: &mut [u8]) -> io::Result<usize> {+ match *self {}+ }+ }++ impl io::Write for UnixStream {+ fn write(&mut self, _buf: &[u8]) -> io::Result<usize> {+ match *self {}+ }++ fn flush(&mut self) -> io::Result<()> {+ match *self {}+ }+ }+}++#[cfg(all(test, unix))]mod tests {use super::*;use crate::approvals::fake::{Answer, FakePrompt};diff --git a/apps/desktop/src-tauri/src/daemon_unavailable.rs b/apps/desktop/src-tauri/src/daemon_unavailable.rsnew file mode 100644index 0000000..5d597c9--- /dev/null+++ b/apps/desktop/src-tauri/src/daemon_unavailable.rs@@ -0,0 +1,118 @@+//! Temporary seam of the Windows port (gentle-dot#89). `daemon.rs` spawns the daemon with Unix+//! primitives (fd 3, signals, file modes); its Windows side lands later in the chain and replaces+//! this file. Until then the shell builds and opens on Windows, and every start fails with+//! [`UNAVAILABLE`] instead of spawning anything.++use crate::app_channel::{AppChannel, Handler};+use crate::health::check_health;+use std::path::PathBuf;+use std::sync::Arc;+use std::thread;+use std::time::{Duration, Instant};++const HEALTH_TIMEOUT: Duration = Duration::from_millis(300);++/// Why the assistant does not start on Windows yet.+pub const UNAVAILABLE: &str = "The Gentle Dot assistant does not run on Windows yet.";++/// Same message as the Unix build: one the app did not launch holds the port.+pub fn foreign_daemon_message(port: u16) -> String {+ format!(+ "Another Gentle Dot assistant is already running on port {port}, and this app did not start it \+(for example `pnpm dev`, or one left running by an older version of the app). Gentle Dot only uses an \+assistant it started itself, so connectors stay safe. Stop the other one (press Ctrl+C where `pnpm dev` \+runs, or quit the process listening on port {port}), then choose \"Restart assistant\" in the Gentle Dot menu."+ )+}++/// Where a bundled runtime would live, as on Unix.+pub fn runtime_dir(env: impl Fn(&str) -> Option<String>, resource_dir: Option<PathBuf>) -> Option<PathBuf> {+ env("GENTLE_DOT_RUNTIME_DIR")+ .filter(|v| !v.is_empty())+ .map(PathBuf::from)+ .or_else(|| resource_dir.map(|dir| dir.join("runtime")))+}++#[derive(Debug, PartialEq, Eq)]+pub enum RestartOutcome {+ Restarted,+ /// The daemon answers but was not started by this app.+ External,+ Failed(String),+}++/// The Unix `Daemon`'s interface, without a daemon behind it.+pub struct Daemon {+ port: u16,+}++impl Daemon {+ pub fn new(port: u16, _data_dir: PathBuf, _runtime_dir: Option<PathBuf>) -> Self {+ Self { port }+ }++ pub fn with_channel(self, _handler: Arc<dyn Handler>) -> Self {+ self+ }++ pub fn on_ready(self, _ready: Arc<dyn Fn() + Send + Sync>) -> Self {+ self+ }++ pub fn channel(&self) -> Option<Arc<AppChannel>> {+ None+ }++ pub fn is_healthy(&self) -> bool {+ check_health(self.port, HEALTH_TIMEOUT)+ }++ /// This app never launches a daemon here, so it would refuse any on the port.+ pub fn refusal(&self) -> Option<String> {+ None+ }++ pub fn wait_ready(&self, _timeout: Duration) -> Result<(), String> {+ Err(UNAVAILABLE.into())+ }++ pub fn wait_healthy(&self, timeout: Duration) -> bool {+ let deadline = Instant::now() + timeout;+ while Instant::now() < deadline {+ if self.is_healthy() {+ return true;+ }+ thread::sleep(Duration::from_millis(100));+ }+ false+ }++ pub fn ensure_running(&self, _timeout: Duration) -> Result<(), String> {+ Err(UNAVAILABLE.into())+ }++ pub fn owns_running(&self) -> bool {+ false+ }++ pub fn stop(&self) {}++ pub fn restart(&self, _timeout: Duration) -> RestartOutcome {+ RestartOutcome::Failed(UNAVAILABLE.into())+ }+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn every_start_fails_with_the_unavailable_message() {+ let daemon = Daemon::new(0, PathBuf::new(), None);+ assert_eq!(daemon.ensure_running(Duration::ZERO), Err(UNAVAILABLE.to_string()));+ assert_eq!(daemon.wait_ready(Duration::ZERO), Err(UNAVAILABLE.to_string()));+ assert_eq!(daemon.restart(Duration::ZERO), RestartOutcome::Failed(UNAVAILABLE.to_string()));+ assert!(daemon.channel().is_none());+ assert!(!daemon.owns_running());+ }+}diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rsindex ce18d00..46e45da 100644--- a/apps/desktop/src-tauri/src/lib.rs+++ b/apps/desktop/src-tauri/src/lib.rs@@ -3,6 +3,12 @@ pub mod app_channel;pub mod approvals;pub mod computer;pub mod config;+#[cfg(unix)]+pub mod daemon;+// Temporary seam of the Windows port (gentle-dot#89): the daemon lifecycle is Unix only until its+// Windows side lands, so on Windows the shell starts with an assistant that refuses to start.+#[cfg(windows)]+#[path = "daemon_unavailable.rs"]pub mod daemon;#[cfg(target_os = "macos")]pub mod disclaimed;