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
mux: keep the resize note until the snapshot shows the size; the spawn path keeps its cwd policy
RoversX1b6181b6034a
diff --git a/mux/src/lib.rs b/mux/src/lib.rsindex a5d157c5..b96b3ecb 100644--- a/mux/src/lib.rs+++ b/mux/src/lib.rs@@ -2886,13 +2886,12 @@ impl Mux {command_dir.or_else(|| {match pane {// Without waiting for the pane's parser: this is the- // spawn path, on the main thread. The listing summary- // carries the divined directory the blocking read would.- Some(pane) if pane.domain_id() == target_domain => {- let _ = policy;- pane.listing_summary().working_dir- }- .and_then(|url| {+ // spawn path, on the main thread. The policy still+ // applies to the divined directory, so a spawn right+ // after a `cd` finds the new one.+ Some(pane) if pane.domain_id() == target_domain => pane+ .working_dir_without_waiting(policy)+ .and_then(|url| {percent_decode_str(url.path()).decode_utf8().ok()diff --git a/mux/src/localpane.rs b/mux/src/localpane.rsindex fc01c114..44f611e8 100644--- a/mux/src/localpane.rs+++ b/mux/src/localpane.rs@@ -845,6 +845,15 @@ impl Pane for LocalPane {self.working_dir_or_divined(reported, policy)}+ fn working_dir_without_waiting(&self, policy: CachePolicy) -> Option<Url> {+ // The reported directory from the terminal if it can be read+ // now, from the stored copy otherwise; the divination keeps the+ // caller's policy, since a spawn right after a `cd` in a shell+ // that reports nothing wants the process looked at now.+ let reported = self.summary_without_waiting().working_dir;+ self.working_dir_or_divined(reported, policy)+ }+fn tty_name(&self) -> Option<String> {#[cfg(unix)]{@@ -1461,12 +1470,22 @@ impl LocalPane {/// output written in answer to the resize is parsed at the new size;/// after, for a resize that arrived during the batch.fn apply_pending_resize(&self, term: &mut Terminal) {- // The note is taken and its lock let go before the resize: a- // resize reflows the scrollback, and `summary_without_waiting`- // reads the note on the thread that must not wait.- let pending = self.pending_resize.lock().take();+ // The note's lock is not held across the resize: a resize+ // reflows the scrollback, and `summary_without_waiting` reads+ // the note on the thread that must not wait. Nor is the note+ // taken before the resize: until the stored snapshot shows the+ // new size, a reader must still find the note, or it would take+ // the old snapshot for the size the pane has. So the note stays+ // until the snapshot is stored, and goes only if it is still the+ // size just applied; a newer one waits for the next look.+ let pending = *self.pending_resize.lock();if let Some(size) = pending {term.resize(size);+ self.store_summary(term);+ let mut note = self.pending_resize.lock();+ if *note == Some(size) {+ *note = None;+ }}}@@ -1773,6 +1792,29 @@ mod summary_tests {assert!(pane.pending_resize.lock().is_none());}+ /// While the parser is applying a noted resize, a reader that cannot+ /// take the terminal still finds the note: the old snapshot without+ /// it would say the pane has its old size.+ #[test]+ fn the_note_outlives_the_reflow_until_the_snapshot_shows_the_size() {+ let (pane, _sizes, _exit) = pane();+ let guard = pane.terminal.lock();+ pane.resize(size(100, 30)).unwrap();+ drop(guard);+ // What the parser does, step by step: the resize itself first.+ let mut term = pane.terminal.lock();+ let before = *pane.pending_resize.lock();+ assert_eq!(before.map(|s| s.cols), Some(100));+ pane.apply_pending_resize(&mut term);+ assert!(+ pane.pending_resize.lock().is_none(),+ "gone once the snapshot shows it"+ );+ assert_eq!(pane.last_summary.lock().dimensions.cols, 100);+ drop(term);+ assert_eq!(pane.summary_without_waiting().terminal_size().cols, 100);+ }+/// A resize that lands while the parser is between its last look at/// the note and letting go of the terminal is still applied by the/// parser, without another batch of output.diff --git a/mux/src/pane.rs b/mux/src/pane.rsindex 732b27a8..e4263382 100644--- a/mux/src/pane.rs+++ b/mux/src/pane.rs@@ -392,6 +392,12 @@ pub trait Pane: Downcast + Send + Sync {self.summary_without_waiting().title}+ /// `get_current_working_dir`, without waiting for the parser; the+ /// policy still governs how fresh a divined directory has to be.+ fn working_dir_without_waiting(&self, policy: CachePolicy) -> Option<Url> {+ self.get_current_working_dir(policy)+ }+fn copy_user_vars(&self) -> HashMap<String, String> {HashMap::new()}