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
fix(gui): show local Space connection state without idle repaints
RoversX7d80505da645
diff --git a/wezterm-gui/src/local_sessions.rs b/wezterm-gui/src/local_sessions.rsindex 625d4aff..8f5c71cf 100644--- a/wezterm-gui/src/local_sessions.rs+++ b/wezterm-gui/src/local_sessions.rs@@ -220,6 +220,16 @@ pub(crate) fn host_domain_name() -> Option<String> {HOST.get().cloned().flatten()}+/// The connection that serves a Space. Local Spaces keep their local+/// identity even when their terminals are hosted by the background mux.+pub(crate) fn connection_domain_for_space(space_id: &str) -> Option<String> {+ space_connection_domain(crate::workspace_threads::client_domain_for_space(space_id), host_domain_name())+}++fn space_connection_domain(remote: Option<String>, local_host: Option<String>) -> Option<String> {+ remote.or(local_host)+}+/// Whether `name` is the host domain of this launch.pub(crate) fn is_host_domain_name(name: &str) -> bool {host_domain_name().as_deref() == Some(name)@@ -492,3 +502,15 @@ mod tests {assert_eq!(alias_for("unix", None), None);}}++#[cfg(test)]+mod connection_state_tests {+ use super::space_connection_domain;++ #[test]+ fn local_spaces_follow_their_session_host_without_overriding_remote_spaces() {+ assert_eq!(space_connection_domain(None, Some("unix".into())), Some("unix".into()));+ assert_eq!(space_connection_domain(Some("server-a".into()), Some("unix".into())), Some("server-a".into()));+ assert_eq!(space_connection_domain(None, None), None);+ }+}diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rsindex f4b7e61d..e640a985 100644--- a/wezterm-gui/src/termwindow/mod.rs+++ b/wezterm-gui/src/termwindow/mod.rs@@ -2941,6 +2941,9 @@ pub struct TermWindow {/// sidebar Reconnect button); suppresses double-clicks and drives the/// row's "Connecting…" label.space_reconnects_in_flight: HashSet<String>,+ /// The sidebar Space's connection state at the last status heartbeat.+ watched_space_connection_state:+ Option<crate::termwindow::ui::sidebar::SpaceConnectionState>,workspace_layout_structure_fingerprint: Option<u64>,workspace_sidebar_width: usize,workspace_sidebar_pending_thread_selection: Option<String>,@@ -4569,6 +4572,7 @@ impl TermWindow {active_space_id,dies_with_mux_window,space_reconnects_in_flight: HashSet::new(),+ watched_space_connection_state: None,workspace_layout_structure_fingerprint,workspace_sidebar_width,workspace_sidebar_pending_thread_selection: None,@@ -5851,6 +5855,7 @@ impl TermWindow {self.schedule_next_status_update();self.emit_status_event();self.refresh_all_thread_work();+ self.watch_space_connection_state();self.terminal_render_watchdog();self.maybe_release_occluded_memory();self.maybe_release_idle_preview_cache();@@ -6066,7 +6071,7 @@ impl TermWindow {/// fresh, registering it from the SSH host store when needed.pub(crate) fn reconnect_space_domain(&mut self) {let Some(domain_name) =- crate::workspace_threads::client_domain_for_space(&self.active_space_id)+ crate::local_sessions::connection_domain_for_space(&self.active_space_id)else {return;};diff --git a/wezterm-gui/src/termwindow/ui/sidebar.rs b/wezterm-gui/src/termwindow/ui/sidebar.rsindex b8c46cbf..81a820ab 100644--- a/wezterm-gui/src/termwindow/ui/sidebar.rs+++ b/wezterm-gui/src/termwindow/ui/sidebar.rs@@ -26,7 +26,7 @@ use std::rc::Rc;use std::time::{Duration, Instant};use wezterm_font::LoadedFont;use window::color::LinearRgba;-use window::{MouseEventKind as WMEK, RectF};+use window::{MouseEventKind as WMEK, RectF, WindowOps};const SIDEBAR_SCROLLBAR_VISIBLE_MS: u64 = 900;const SIDEBAR_SETTINGS_FOOTER_HEIGHT: usize = 72;@@ -77,7 +77,8 @@ const NOTIFICATION_BADGE_FRAME_MS: u64 = 33;const SIDEBAR_SECTION_ACTION_ICON_INSET: usize = 6;/// Connection health of the active Space's mux client domain, as shown by-/// the sidebar indicator. Local Spaces are always Connected.+/// the sidebar indicator. A local Space reports its link to the session+/// host, and is always Connected without one.#[derive(Debug, Clone, Copy, PartialEq, Eq)]pub(crate) enum SpaceConnectionState {Connected,@@ -558,15 +559,21 @@ impl crate::TermWindow {/// Connection health of a client-domain Space. While the Space is/// remote we keep a slow self-driven repaint tick going: a dead/// connection produces no output, so nothing else would repaint the- /// indicator when the state flips.+ /// indicator when the state flips. A local Space's link to the session+ /// host is checked by the status heartbeat instead (see+ /// `watch_space_connection_state`), so idle local windows stay idle.pub(crate) fn space_connection_state(&self, space_id: &str) -> SpaceConnectionState {const SUSTAINED_LAG_MS: u64 = 5000;- let Some(domain_name) = workspace_threads::client_domain_for_space(space_id) else {+ let remote = workspace_threads::client_domain_for_space(space_id);+ let is_remote = remote.is_some();+ let Some(domain_name) = remote.or_else(crate::local_sessions::host_domain_name) else {return SpaceConnectionState::Connected;};- self.update_next_frame_time(Some(- std::time::Instant::now() + std::time::Duration::from_secs(1),- ));+ if is_remote {+ self.update_next_frame_time(Some(+ std::time::Instant::now() + std::time::Duration::from_secs(1),+ ));+ }let mux = Mux::get();let Some(domain) = mux.get_domain_by_name(&domain_name) else {// Not even registered: never connected in this session.@@ -601,6 +608,12 @@ impl crate::TermWindow {if domain.state() != mux::domain::DomainState::Attached {return SpaceConnectionState::Disconnected;}+ // Pane lag below measures the network to a server. One busy local+ // pane is not a broken link to the session host, and must not mark+ // every local Space as reconnecting.+ if !is_remote {+ return SpaceConnectionState::Connected;+ }// Attached but silent despite outstanding requests: transport not// (yet) declared dead. Panes report tardy after ~3s, which ordinary// latency spikes trip all the time; require a longer sustained@@ -617,6 +630,22 @@ impl crate::TermWindow {}}+ /// Called from the status heartbeat: repaint only when the sidebar+ /// Space's connection state has changed since the last check. Remote+ /// Spaces already tick while their indicator is painted.+ pub(crate) fn watch_space_connection_state(&mut self) {+ let space_id = self.workspace_sidebar_space_id();+ if workspace_threads::client_domain_for_space(space_id).is_some() {+ return;+ }+ let state = self.space_connection_state(space_id);+ if self.watched_space_connection_state.replace(state) != Some(state) {+ if let Some(window) = self.window.as_ref() {+ window.invalidate();+ }+ }+ }+/// `suppress_active` carries "a thread reference's workspace is on/// screen": the Space's own active-thread pointer is then stale for/// selection (ref activation never repoints it), so the Space's OWN rows@@ -1004,7 +1033,7 @@ impl crate::TermWindow {// local set still bridges the click-to-spawn gap for the button.let reconnect_in_flight = self.space_connection_state(self.workspace_sidebar_space_id())== SpaceConnectionState::Connecting- || workspace_threads::client_domain_for_space(self.workspace_sidebar_space_id())+ || crate::local_sessions::connection_domain_for_space(self.workspace_sidebar_space_id()).map_or(false, |name| {self.space_reconnects_in_flight.contains(&name)});