Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

chore: files changed crates/openhuman-app/src/deep_link_ipc.rs,crates/openhuman-app/src/deep_link_ip

Steven Enamakele8301a127836
diff --git a/crates/openhuman-app/src/deep_link_ipc.rs b/crates/openhuman-app/src/deep_link_ipc.rs
index 26e3c99913..423cd77900 100644
--- a/crates/openhuman-app/src/deep_link_ipc.rs
+++ b/crates/openhuman-app/src/deep_link_ipc.rs
@@ -24,12 +24,20 @@ use std::{
/// Stable socket path. Uses $XDG_RUNTIME_DIR when available (per-user,
/// per-session tmpfs, cleaned on reboot), falls back to /tmp with UID.
pub(crate) fn socket_path() -> PathBuf {
- if let Ok(dir) = std::env::var("XDG_RUNTIME_DIR") {
- return PathBuf::from(dir).join("com.openhuman.app-deeplink.sock");
+ let runtime_dir = std::env::var_os("XDG_RUNTIME_DIR").map(PathBuf::from);
+ socket_path_for(
+ runtime_dir.as_deref(),
+ &std::env::temp_dir(),
+ nix::unistd::getuid().as_raw(),
+ )
+}
+
+fn socket_path_for(runtime_dir: Option<&Path>, temp_dir: &Path, uid: u32) -> PathBuf {
+ if let Some(dir) = runtime_dir {
+ return dir.join("com.openhuman.app-deeplink.sock");
}
// Fallback: include UID so multi-user machines don't collide.
- let uid = nix::unistd::getuid().as_raw();
- std::env::temp_dir().join(format!("com_openhuman_app_deeplink_{uid}.sock"))
+ temp_dir.join(format!("com_openhuman_app_deeplink_{uid}.sock"))
}
/// Filter `openhuman://` URLs out of an argv-style iterator. Split out from
diff --git a/crates/openhuman-app/src/deep_link_ipc_tests.rs b/crates/openhuman-app/src/deep_link_ipc_tests.rs
index 6cf2a707a6..486e0723f9 100644
--- a/crates/openhuman-app/src/deep_link_ipc_tests.rs
+++ b/crates/openhuman-app/src/deep_link_ipc_tests.rs
@@ -26,8 +26,7 @@ impl Write for FailingWriter {
#[test]
fn socket_path_uses_xdg_runtime_dir() {
- std::env::set_var("XDG_RUNTIME_DIR", "/run/user/1234");
- let path = socket_path();
+ let path = socket_path_for(Some(Path::new("/run/user/1234")), Path::new("/tmp"), 5678);
assert_eq!(
path,
PathBuf::from("/run/user/1234/com.openhuman.app-deeplink.sock")
@@ -36,16 +35,15 @@ fn socket_path_uses_xdg_runtime_dir() {
#[test]
fn socket_path_fallback_has_uid() {
- std::env::remove_var("XDG_RUNTIME_DIR");
- let path = socket_path();
+ let path = socket_path_for(None, Path::new("/tmp"), 5678);
let name = path.file_name().unwrap().to_string_lossy();
assert!(
name.contains("com_openhuman_app_deeplink"),
"path {path:?} should contain identifier"
);
- // Should NOT be inside /run/user since XDG_RUNTIME_DIR is unset.
+ // The fallback uses the supplied temp directory when XDG_RUNTIME_DIR is absent.
assert!(
- !path.starts_with("/run/user"),
+ path.starts_with("/tmp"),
"path should use temp_dir fallback"
);
}