A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.
Rust agentagent-orchestrationaiai-agentsclaude-codecodexcoding-agentlinuxmacosmultiplayermultiplexerrustterminalterminal-emulatorterminal-multiplexertmuxtuiweztermwindows
Scope runtime files to build profile
RoversX08eb94fb305e
diff --git a/config/src/daemon.rs b/config/src/daemon.rsindex bc54ae01..5c02a8fd 100644--- a/config/src/daemon.rs+++ b/config/src/daemon.rs@@ -50,21 +50,21 @@ impl DaemonOptions {self.pid_file.as_ref().cloned()- .unwrap_or_else(|| RUNTIME_DIR.join("pid"))+ .unwrap_or_else(|| RUNTIME_DIR.join(runtime_file_name("pid")))}pub fn stdout(&self) -> PathBuf {self.stdout.as_ref().cloned()- .unwrap_or_else(|| RUNTIME_DIR.join("log"))+ .unwrap_or_else(|| RUNTIME_DIR.join(runtime_file_name("log")))}pub fn stderr(&self) -> PathBuf {self.stderr.as_ref().cloned()- .unwrap_or_else(|| RUNTIME_DIR.join("log"))+ .unwrap_or_else(|| RUNTIME_DIR.join(runtime_file_name("log")))}pub fn open_stdout(&self) -> anyhow::Result<File> {diff --git a/config/src/lib.rs b/config/src/lib.rsindex 72c9713a..66afe1a9 100644--- a/config/src/lib.rs+++ b/config/src/lib.rs@@ -85,6 +85,31 @@ thread_local! {static LUA_CONFIG: RefCell<Option<LuaConfigState>> = RefCell::new(None);}+/// Name a file under [`RUNTIME_DIR`], scoped to the build profile.+///+/// A debug build gets its own socket, pid file and log, so that a binary+/// built while developing can never adopt -- or be adopted by -- the+/// release mux server that serves the user's real work. Both ends of the+/// protocol derive their paths from here, so a debug client reaches the+/// debug server and nothing else.+///+/// The protocol's own guard is not enough on its own: `CODEC_VERSION`+/// advances only when the wire format changes, so two builds that differ+/// by a behaviour change alone still handshake happily. A development+/// server left running days ago therefore goes on serving live shells+/// while looking perfectly healthy to a freshly built client.+pub fn runtime_file_name(base: &str) -> String {+ scoped_runtime_file_name(base, cfg!(debug_assertions))+}++fn scoped_runtime_file_name(base: &str, debug_build: bool) -> String {+ if debug_build {+ format!("{base}-debug")+ } else {+ base.to_string()+ }+}+fn toml_table_has_numeric_keys(t: &toml::value::Table) -> bool {t.keys().all(|k| k.parse::<isize>().is_ok())}@@ -855,3 +880,24 @@ fn default_one_point_oh() -> f32 {fn default_true() -> bool {true}++#[cfg(test)]+mod runtime_file_name_tests {+ use super::scoped_runtime_file_name;++ #[test]+ fn a_release_build_keeps_the_documented_runtime_file_names() {+ assert_eq!(scoped_runtime_file_name("sock", false), "sock");+ assert_eq!(scoped_runtime_file_name("pid", false), "pid");+ assert_eq!(scoped_runtime_file_name("log", false), "log");+ }++ #[test]+ fn a_debug_build_never_shares_a_runtime_file_with_the_release_one() {+ for base in ["sock", "pid", "log"] {+ let debug = scoped_runtime_file_name(base, true);+ assert_ne!(debug, scoped_runtime_file_name(base, false));+ assert_eq!(debug, format!("{base}-debug"));+ }+ }+}diff --git a/config/src/unix.rs b/config/src/unix.rsindex 12369198..f918559e 100644--- a/config/src/unix.rs+++ b/config/src/unix.rs@@ -93,7 +93,7 @@ impl UnixDomain {self.socket_path.as_ref().cloned()- .unwrap_or_else(|| RUNTIME_DIR.join("sock"))+ .unwrap_or_else(|| RUNTIME_DIR.join(runtime_file_name("sock")))}pub fn target(&self) -> UnixTarget {diff --git a/wezterm-client/src/client.rs b/wezterm-client/src/client.rsindex b54072ab..095dc4ab 100644--- a/wezterm-client/src/client.rs+++ b/wezterm-client/src/client.rs@@ -266,6 +266,30 @@ pub struct IncompatibleVersionError {pub codec_vers: usize,}+/// Describe a server whose build differs from ours, or `None` when they match.+///+/// [`CODEC_VERSION`] guards the wire format, not behaviour: two builds that+/// differ only by a behaviour change still carry the same codec version and+/// handshake without complaint. That is how a mux server left running from a+/// days-old build goes on serving live shells while looking healthy to a+/// freshly built client -- the failure this reports is invisible otherwise.+///+/// Reported through the log rather than the connection UI on purpose. A+/// *remote* server legitimately runs its own build, and nagging on every+/// connect would train the warning away before it ever caught the local case+/// it exists for.+pub(crate) fn describe_server_build_mismatch(local: &str, remote: &str) -> Option<String> {+ if local == remote {+ return None;+ }+ Some(format!(+ "mux server is running {remote}, this client is {local}. \+ Codec version {CODEC_VERSION} matches, so they interoperate, but the \+ server may be serving behaviour from an older build; restart it if \+ that is not deliberate."+ ))+}+macro_rules! rpc {($method_name:ident, $request_type:ident, $response_type:ident) => {pub async fn $method_name(&self, pdu: $request_type) -> anyhow::Result<$response_type> {@@ -1843,6 +1867,12 @@ impl Client {info.version_string,info.codec_vers);+ if let Some(mismatch) = describe_server_build_mismatch(+ config::wezterm_version(),+ &info.version_string,+ ) {+ log::warn!("{mismatch}");+ }match self.send_bootstrap_pdu(Pdu::SetClientId(SetClientId {client_id: self.client_id.clone(),@@ -2140,7 +2170,32 @@ impl Client {#[cfg(test)]mod tests {- use super::{Reconnectable, RegistrationBarrier};+ use super::{describe_server_build_mismatch, Reconnectable, RegistrationBarrier};++ #[test]+ fn an_identical_build_is_not_worth_warning_about() {+ assert_eq!(+ describe_server_build_mismatch(+ "20260814-011230-aaef9bfb",+ "20260814-011230-aaef9bfb"+ ),+ None+ );+ }++ #[test]+ fn a_server_from_another_build_names_both_sides() {+ let mismatch = describe_server_build_mismatch(+ "20260815-150100-eab2bf7c",+ "20260813-012155-816da4db",+ )+ .expect("differing builds are reported");+ // Which side is which is the whole point of the message: the same two+ // version strings in the wrong order sends the user to restart the+ // wrong process.+ assert!(mismatch.contains("server is running 20260813-012155-816da4db"));+ assert!(mismatch.contains("client is 20260815-150100-eab2bf7c"));+ }#[test]fn registration_barrier_sends_bootstrap_before_deferred_rpcs() {diff --git a/wezterm-client/src/discovery.rs b/wezterm-client/src/discovery.rsindex 9a97bd92..38526c2f 100644--- a/wezterm-client/src/discovery.rs+++ b/wezterm-client/src/discovery.rs@@ -177,9 +177,14 @@ mod windows {/// Computes the names of the objects; they use Local scoped/// names so that we have one per desktop, rather than one/// system wide.+ /// Scoped to the build profile as well as the desktop, so that a debug+ /// GUI and the release one do not publish to a single pair of objects+ /// and leave `thinkterm cli` addressing whichever started last. See+ /// [`config::runtime_file_name`].fn compute_names(class_name: &str) -> (String, String) {- let mutex_name = format!("Local\\wezterm-sock-mutex-{}", class_name);- let map_name = format!("Local\\wezterm-sock-{}", class_name);+ let scoped = config::runtime_file_name(class_name);+ let mutex_name = format!("Local\\wezterm-sock-mutex-{}", scoped);+ let map_name = format!("Local\\wezterm-sock-{}", scoped);(mutex_name, map_name)}@@ -269,7 +274,18 @@ mod unix {}impl NameHolder {+ /// Name the symlink that points `thinkterm cli` at the running GUI.+ ///+ /// Scoped to the build profile for the same reason the mux socket is+ /// (see [`config::runtime_file_name`]): a debug GUI and the release+ /// one otherwise publish to a single name, last writer wins, and CLI+ /// commands silently address whichever process started most recently+ /// rather than the one the user meant.fn compute_name(class_name: &str) -> String {+ config::runtime_file_name(&Self::compute_display_name(class_name))+ }++ fn compute_display_name(class_name: &str) -> String {#[cfg(not(target_os = "macos"))]{let config = config::configuration();@@ -315,6 +331,25 @@ mod unix {std::fs::read_link(&name).with_context(|| format!("reading symlink {}", name.display()))}}++ #[cfg(test)]+ mod tests {+ use super::NameHolder;++ #[test]+ fn the_published_name_is_scoped_to_the_build_profile() {+ let class = "com.example.thinkterm";+ let name = NameHolder::compute_name(class);+ assert!(+ name.contains(class),+ "{} no longer identifies the class it publishes for",+ name+ );+ // Tests are built with debug_assertions, which is precisely the+ // profile that must not land on the release GUI's name.+ assert_ne!(name, NameHolder::compute_display_name(class));+ }+ }}#[cfg(windows)]