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
Space menu: real remote-delete semantics; attach on switch; GUI reconnect badge
RoversX12b9316f7f9f
diff --git a/config/src/keyassignment.rs b/config/src/keyassignment.rsindex 1464ac10..d9f58acc 100644--- a/config/src/keyassignment.rs+++ b/config/src/keyassignment.rs@@ -593,6 +593,9 @@ pub enum KeyAssignment {CreateSpace,SwitchSpace(String),DeleteSpace(String),+ /// Like DeleteSpace, but for a remote (mux-domain) Space also kill its+ /// sessions on the remote mux server before detaching.+ DeleteSpaceAndRemoteSessions(String),CreateWorkspaceThread(String),ToggleWorkspaceThreadsCollapsed(String),RemoveProject(String),diff --git a/wezterm-gui/src/commands.rs b/wezterm-gui/src/commands.rsindex c8a3fa93..5426bc78 100644--- a/wezterm-gui/src/commands.rs+++ b/wezterm-gui/src/commands.rs@@ -960,6 +960,16 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option<Commmenubar: &[],icon: Some("md_delete"),},+ DeleteSpaceAndRemoteSessions(_) => CommandDef {+ brief: "Delete Space & End Remote Sessions".into(),+ doc: "Kills the Space's sessions on the remote mux server, then \+ deletes the local records"+ .into(),+ keys: vec![],+ args: &[ArgType::ActiveWindow],+ menubar: &[],+ icon: Some("md_delete"),+ },CreateWorkspaceThread(_) => CommandDef {brief: "New Thread".into(),doc: "Creates a new ThinkTerm thread for the workspace".into(),diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rsindex 2711e75b..11384e8f 100644--- a/wezterm-gui/src/termwindow/mod.rs+++ b/wezterm-gui/src/termwindow/mod.rs@@ -950,6 +950,10 @@ pub struct TermWindow {line_quad_cache: RefCell<LfuCache<LineQuadCacheKey, LineQuadCacheValue>>,last_status_call: Instant,+ /// Whether the last status tick found a lagging client pane (the+ /// "Reconnecting…" badge was drawn); used to repaint once more after+ /// recovery so a stale badge doesn't linger on an idle pane.+ connection_badge_was_visible: bool,cursor_blink_state: RefCell<ColorEase>,blink_state: RefCell<ColorEase>,rapid_blink_state: RefCell<ColorEase>,@@ -1540,6 +1544,7 @@ impl TermWindow {&config,)),last_status_call: Instant::now(),+ connection_badge_was_visible: false,cursor_blink_state: RefCell::new(ColorEase::new(config.cursor_blink_rate,config.cursor_blink_ease_in,@@ -2272,6 +2277,20 @@ impl TermWindow {TermWindowNotif::EmitStatusUpdate => {self.emit_status_event();self.refresh_all_thread_work();+ // Drive the per-pane "Reconnecting…" badge: a lagging+ // session produces no output, so nothing else would+ // repaint it (or clear a stale badge after recovery).+ let lagging = self+ .get_panes_to_render()+ .iter()+ .any(|pos| {+ crate::termwindow::render::pane::client_pane_lag_ms(pos.pane.as_ref())+ .is_some()+ });+ if lagging || self.connection_badge_was_visible {+ window.invalidate();+ }+ self.connection_badge_was_visible = lagging;}TermWindowNotif::OpenProjectPath(path) => {let path = path.to_string_lossy();@@ -2655,6 +2674,45 @@ impl TermWindow {}}+ /// Delete a remote Space AND end its sessions on the server: send a+ /// remote kill for every pane of the Space's client domain, then delete+ /// the Space (which detaches). The deletion is deferred a moment so the+ /// KillPane PDUs can flush before the detach tears the transport down.+ fn delete_space_and_remote_sessions(&mut self, space_id: &str) {+ let attached_domain = crate::workspace_threads::client_domain_for_space(space_id)+ .and_then(|name| Mux::get().get_domain_by_name(&name))+ .filter(|domain| domain.state() == mux::domain::DomainState::Attached);++ let Some(domain) = attached_domain else {+ let window = self.window.clone();+ self.delete_space(space_id, window.as_ref());+ return;+ };++ let domain_id = domain.domain_id();+ for pane in Mux::get().iter_panes() {+ if pane.domain_id() == domain_id {+ pane.kill();+ }+ }++ let space_id = space_id.to_string();+ let gui_window = self.window.clone();+ promise::spawn::spawn(async move {+ smol::Timer::after(Duration::from_millis(400)).await;+ if let Some(gui_window) = gui_window {+ gui_window.notify(TermWindowNotif::Apply(Box::new(move |term_window| {+ let window = term_window.window.clone();+ term_window.delete_space(&space_id, window.as_ref());+ if let Some(window) = window {+ window.invalidate();+ }+ })));+ }+ })+ .detach();+ }+fn delete_space(&mut self, space_id: &str, window: Option<&Window>) {match crate::workspace_threads::delete_space_for_window(self.space_owner_id, space_id) {Ok(deleted) => {@@ -4862,6 +4920,12 @@ impl TermWindow {window.invalidate();}}+ DeleteSpaceAndRemoteSessions(space_id) => {+ self.delete_space_and_remote_sessions(space_id);+ if let Some(window) = window.as_ref() {+ window.invalidate();+ }+ }CreateWorkspaceThread(project_id) => {if let Some(window) = window.as_ref() {self.create_workspace_thread(project_id, window);diff --git a/wezterm-gui/src/termwindow/mouseevent.rs b/wezterm-gui/src/termwindow/mouseevent.rsindex 649deab2..3599447e 100644--- a/wezterm-gui/src/termwindow/mouseevent.rs+++ b/wezterm-gui/src/termwindow/mouseevent.rs@@ -2812,7 +2812,7 @@ impl super::TermWindow {// are untouched. Label it accordingly.ContextMenuItem::item_with_icon(if space.is_remote {- format!("Disconnect & Remove \"{}\" (Local Only)", space.name)+ format!("Disconnect \"{}\" (Server Keeps Running)", space.name)} else {format!("Delete \"{}\"", space.name)},@@ -2830,7 +2830,23 @@ impl super::TermWindow {.find(|space| active_space_id.as_deref() == Some(space.id.as_str())).cloned();if let Some(space) = active_delete {+ // For a currently-connected remote Space, also offer really+ // ending the sessions on the server before removing it.+ let offer_remote_kill = space.is_remote+ && crate::workspace_threads::client_domain_for_space(&space.id)+ .and_then(|name| Mux::get().get_domain_by_name(&name))+ .map_or(false, |domain| {+ domain.state() == mux::domain::DomainState::Attached+ });+ let (name, id) = (space.name.clone(), space.id.clone());items.push(delete_item(space));+ if offer_remote_kill {+ items.push(ContextMenuItem::item_with_icon(+ format!("Delete \"{name}\" & End Remote Sessions"),+ "trash",+ KeyAssignment::DeleteSpaceAndRemoteSessions(id),+ ));+ }}let other_delete_candidates = delete_candidatesdiff --git a/wezterm-gui/src/termwindow/render/pane.rs b/wezterm-gui/src/termwindow/render/pane.rsindex 8b086f68..e189a7af 100644--- a/wezterm-gui/src/termwindow/render/pane.rs+++ b/wezterm-gui/src/termwindow/render/pane.rs@@ -37,6 +37,23 @@ use wezterm_term::{Line, StableRowIndex};use window::color::LinearRgba;use window::MouseEventKind as WMEK;+/// Milliseconds since the mux server last responded, when the pane's+/// connection looks unhealthy (a reconnect is pending or in progress).+/// None for local panes and for healthy client panes.+pub(crate) fn client_pane_lag_ms(pane: &dyn mux::pane::Pane) -> Option<u64> {+ let Value::Object(map) = pane.get_metadata() else {+ return None;+ };+ match map.get(&Value::String("is_tardy".to_string())) {+ Some(Value::Bool(true)) => {}+ _ => return None,+ }+ match map.get(&Value::String("since_last_response_ms".to_string())) {+ Some(Value::U64(ms)) => Some(*ms),+ _ => Some(0),+ }+}+impl crate::TermWindow {/// Height of the nav bar for this pane: the metric height, clamped so/// that at least one terminal row of the pane's cell remains visible.@@ -948,6 +965,68 @@ impl crate::TermWindow {Ok(())}+ /// GUI-level connection-health badge for mux client panes: while the+ /// server has stopped responding (a reconnect is pending or running),+ /// draw a pill at the pane's top-right, below the nav bar, instead of+ /// writing into the terminal content. The periodic status update keeps+ /// invalidating the window while any pane lags, so the counter is live.+ fn paint_pane_connection_badge(+ &mut self,+ pos: &PositionedPane,+ layers: &mut TripleLayerQuadAllocator,+ nav_height: usize,+ ) -> anyhow::Result<()> {+ let Some(lag_ms) = client_pane_lag_ms(pos.pane.as_ref()) else {+ return Ok(());+ };++ let (pane_x, pane_y) = self.pane_content_origin(pos)?;+ let pane_width = pos.width as f32 * self.render_metrics.cell_size.width as f32;++ let ui_font = self+ .fonts+ .title_font_with_size(crate::native_settings::pane_header_font_size())+ .context("connection badge font")?;+ let ui_metrics = RenderMetrics::with_font_metrics(&ui_font.metrics());++ let text = format!("Reconnecting… {}s", lag_ms / 1000);+ let text_cell_w = ui_metrics.cell_size.width as usize;+ let text_h = ui_metrics.cell_size.height as usize;+ let text_w = wezterm_term::unicode_column_width(&text, None) * text_cell_w;++ const PAD_X: usize = 10;+ const PAD_Y: usize = 5;+ const MARGIN: usize = 10;+ let badge_w = (text_w + PAD_X * 2) as f32;+ let badge_h = (text_h + PAD_Y * 2) as f32;+ let badge_x = pane_x + pane_width - badge_w - MARGIN as f32;+ let badge_y = pane_y + nav_height as f32 + MARGIN as f32;+ if badge_x < pane_x {+ // Pane too narrow for the badge; don't overdraw the neighbour.+ return Ok(());+ }++ self.fill_rounded_rectangle(+ layers,+ 1,+ euclid::rect(badge_x, badge_y, badge_w, badge_h),+ LinearRgba::with_srgba(0xc2, 0x6a, 0x1d, 0xe8),+ (badge_h / 2.0).min(10.0),+ )+ .context("connection badge background")?;+ self.paint_pane_nav_text(+ layers,+ &ui_font,+ ui_metrics,+ &text,+ (badge_x as usize) + PAD_X,+ (badge_y as usize) + PAD_Y,+ text_w + text_cell_w,+ LinearRgba::with_srgba(0xff, 0xff, 0xff, 0xff),+ )?;+ Ok(())+ }+fn paint_pane_box_model(&mut self, pos: &PositionedPane) -> anyhow::Result<()> {let computed = self.build_pane(pos)?;let mut ui_items = computed.ui_items();@@ -1166,6 +1245,8 @@ impl crate::TermWindow {let pane_nav_height = self.paint_pane_nav_bar(pos, layers, &palette).context("paint_pane_nav_bar")?;+ self.paint_pane_connection_badge(pos, layers, pane_nav_height)+ .context("paint_pane_connection_badge")?;if self.collapsed_pane_layouts.contains_key(&pos.pane_stack_id) {return Ok(());}