Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T00:54:34.569Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git

Revision diff

b4e29e1f 83862c2a
diff --git a/crates/paths/src/paths.rs b/crates/paths/src/paths.rs
index b1c82e97f6..9cc3ac6093 100644
--- a/crates/paths/src/paths.rs
+++ b/crates/paths/src/paths.rs
@@ -23,6 +23,18 @@ pub fn app_storage_slug() -> &'static str {
2323     app_identity::CHANNEL.storage_slug()
2424 }
2525 
26+/// The custom data directory, if one was set.
27+///
28+/// Two Omega instances pointed at different data directories share no state,
29+/// so they are not the same instance. The macOS single-instance lock keys its
30+/// port on release channel and uid only, which meant a second instance with
31+/// its own `--user-data-dir` was refused by the first — and `ZED_RELEASE_CHANNEL`
32+/// is `debug_assertions`-only, so a release build had no way out. Proving
33+/// anything on a clean profile therefore required quitting the running Omega.
34+pub fn custom_data_dir() -> Option<&'static PathBuf> {
35+    CUSTOM_DATA_DIR.get()
36+}
37+
2638 /// A custom data directory override, set only by `set_custom_data_dir`.
2739 /// This is used to override the default data directory location.
2840 /// The directory will be created if it doesn't exist when set.
diff --git a/crates/zed/src/zed/mac_only_instance.rs b/crates/zed/src/zed/mac_only_instance.rs
index ebf9e044ee..a85853835e 100644
--- a/crates/zed/src/zed/mac_only_instance.rs
+++ b/crates/zed/src/zed/mac_only_instance.rs
@@ -52,6 +52,31 @@ fn address() -> SocketAddr {
5252         user_port += wrapped_uid;
5353     }
5454 
55+    // A custom data directory is a different instance, so it gets its own lock.
56+    //
57+    // The lock exists to stop two processes sharing one profile. Two processes
58+    // pointed at different `--user-data-dir` roots share nothing, yet the port
59+    // above keys only on release channel and uid, so the second was refused
60+    // with "omega is already running". `ZED_RELEASE_CHANNEL` is
61+    // `debug_assertions`-only, so a release build had no way to move the port
62+    // either, and every clean-profile proof had to begin by quitting the
63+    // owner's live session.
64+    //
65+    // The offset is derived from the directory path, so the same profile keeps
66+    // the same port across launches — a custom instance still refuses a second
67+    // copy of *itself*, which is the property worth keeping.
68+    if let Some(custom_dir) = paths::custom_data_dir() {
69+        let mut hash: u32 = 2_166_136_261;
70+        for byte in custom_dir.as_os_str().as_encoded_bytes() {
71+            hash ^= u32::from(*byte);
72+            hash = hash.wrapping_mul(16_777_619);
73+        }
74+        // Land well clear of the four release-channel blocks above.
75+        const CUSTOM_BASE: u16 = 45_737;
76+        const CUSTOM_SPAN: u32 = 4_000;
77+        user_port = CUSTOM_BASE + (hash % CUSTOM_SPAN) as u16;
78+    }
79+
5580     SocketAddr::V4(SocketAddrV4::new(LOCALHOST, user_port))
5681 }
Served at tenant.openagents/omega Member data and write actions are omitted.