feat(daemon): per-surface status (set_state/state), idle-on-spawn, SPACESH_SOCK override

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-09 22:13:50 +07:00
parent 4bd4aa4a36
commit 635f9f4356
3 changed files with 114 additions and 2 deletions
+15
View File
@@ -10,6 +10,11 @@ pub fn spacesh_dir() -> Result<PathBuf> {
}
pub fn socket_path() -> Result<PathBuf> {
if let Ok(p) = std::env::var("SPACESH_SOCK") {
if !p.is_empty() {
return Ok(PathBuf::from(p));
}
}
Ok(spacesh_dir()?.join("sock"))
}
@@ -67,4 +72,14 @@ mod tests {
assert!(second.is_none(), "second acquire should be blocked");
drop(first);
}
#[test]
fn socket_path_honors_env_override() {
// Note: set/remove around the assertion; tests in this module run serially enough,
// but guard by restoring afterwards.
std::env::set_var("SPACESH_SOCK", "/tmp/spacesh-test-override.sock");
let p = socket_path().unwrap();
std::env::remove_var("SPACESH_SOCK");
assert_eq!(p, std::path::PathBuf::from("/tmp/spacesh-test-override.sock"));
}
}