Skip to content

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.

Use window-specific workspace; handle adopted mux

RoversX1589fe826cd9
diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rs
index 662d8aed..ef6f3216 100644
--- a/wezterm-gui/src/termwindow/mod.rs
+++ b/wezterm-gui/src/termwindow/mod.rs
@@ -1368,7 +1368,14 @@ impl TermWindow {
}
crate::update::start_update_checker();
- front_end().record_known_window(window, mux_window_id);
+ // Register with the window's *current* mux id, not the one we were
+ // constructed with: restoring a saved thread above may have adopted
+ // this window onto a different (already-live) mux window via
+ // switch_to_mux_window. Recording the stale construction id would point
+ // known_windows at a mux window the restore just orphaned (and possibly
+ // killed), and the next reconcile would then close this brand-new window.
+ let adopted_mux_window_id = tw.borrow().mux_window_id;
+ front_end().record_known_window(window, adopted_mux_window_id);
Ok(())
}
diff --git a/wezterm-gui/src/termwindow/mouseevent.rs b/wezterm-gui/src/termwindow/mouseevent.rs
index a05cc9ee..592f9bac 100644
--- a/wezterm-gui/src/termwindow/mouseevent.rs
+++ b/wezterm-gui/src/termwindow/mouseevent.rs
@@ -1654,6 +1654,10 @@ impl super::TermWindow {
if !plan.needs_materialize {
self.adopt_workspace_in_this_window(&plan.workspace_name);
+ // Symmetric with the materialize branch below: if this switch
+ // orphaned a startup mux window, tidy it up. cleanup_orphaned_mux_window
+ // is a no-op when the window is still shown or has a thread binding.
+ cleanup_orphaned_mux_window(orphan_candidate_window_id);
context.invalidate();
return;
}
diff --git a/wezterm-gui/src/termwindow/ui/sidebar.rs b/wezterm-gui/src/termwindow/ui/sidebar.rs
index 3446f6ee..7914c38b 100644
--- a/wezterm-gui/src/termwindow/ui/sidebar.rs
+++ b/wezterm-gui/src/termwindow/ui/sidebar.rs
@@ -444,7 +444,12 @@ impl crate::TermWindow {
}
let mux = Mux::get();
- let active_workspace = mux.active_workspace();
+ // Use THIS window's own workspace, not the global active one: with
+ // multiple windows open, a non-focused window must still highlight the
+ // thread it is actually showing.
+ let active_workspace = self
+ .current_mux_workspace()
+ .unwrap_or_else(|| mux.active_workspace());
let workspaces = mux.iter_workspaces();
let view = workspace_threads::view_for_current_project(
&self.active_space_id,
@@ -486,7 +491,12 @@ impl crate::TermWindow {
}
let mux = Mux::get();
- let active_workspace = mux.active_workspace();
+ // Use THIS window's own workspace, not the global active one: with
+ // multiple windows open, a non-focused window must still highlight the
+ // thread it is actually showing.
+ let active_workspace = self
+ .current_mux_workspace()
+ .unwrap_or_else(|| mux.active_workspace());
let workspaces = mux.iter_workspaces();
let view = workspace_threads::view_for_current_project(
&self.active_space_id,
@@ -616,7 +626,12 @@ impl crate::TermWindow {
}
let mux = Mux::get();
- let active_workspace = mux.active_workspace();
+ // Use THIS window's own workspace, not the global active one: with
+ // multiple windows open, a non-focused window must still highlight the
+ // thread it is actually showing.
+ let active_workspace = self
+ .current_mux_workspace()
+ .unwrap_or_else(|| mux.active_workspace());
let workspaces = mux.iter_workspaces();
let view = workspace_threads::view_for_current_project(
&self.active_space_id,