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.

trying to fix height of the terminal issue whileusingthe mux

RoversX14cbd6b2b167
diff --git a/wezterm-gui/src/main.rs b/wezterm-gui/src/main.rs
index fc8ff726..d9ec0525 100644
--- a/wezterm-gui/src/main.rs
+++ b/wezterm-gui/src/main.rs
@@ -404,7 +404,13 @@ async fn connect_domain_into_space(
// in-process window already occupies it, focus that window instead.
let space_owner_id = workspace_threads::next_space_owner_id();
if !workspace_threads::switch_window_space(space_owner_id, &plan.space_id) {
- for window_id in mux.iter_windows_in_workspace(&plan.workspace_name) {
+ for window_id in mux.iter_windows() {
+ let owned = mux
+ .get_window(window_id)
+ .map_or(false, |w| w.origin_domain() == Some(domain.domain_id()));
+ if !owned {
+ continue;
+ }
if let Some(gui_window) =
crate::frontend::front_end().gui_window_for_mux_window(window_id)
{
@@ -429,14 +435,6 @@ async fn connect_domain_into_space(
id
};
- // Transiently bind the thread to the window's current workspace so the
- // sidebar's workspace->project sync resolves to the mux project instead
- // of manufacturing a spurious local Home project.
- let initial_workspace = mux
- .get_window(window_id)
- .map(|w| w.get_workspace().to_string());
- workspace_threads::bind_mux_domain_thread_workspace(&plan.thread_id, initial_workspace);
-
TermWindow::new_window_with_claimed_space(window_id, space_owner_id, plan.space_id.clone())
.await?;
@@ -444,10 +442,7 @@ async fn connect_domain_into_space(
config.update_ulimit()?;
// The ConnectionUI (auth prompts) appears as a tab inside this window.
- if let Err(err) = domain.attach(Some(window_id)).await {
- workspace_threads::bind_mux_domain_thread_workspace(&plan.thread_id, None);
- return Err(err);
- }
+ domain.attach(Some(window_id)).await?;
// Mirror spawn_tab_in_domain_if_mux_is_empty's empty-server handling.
let no_workspace_filter = None;
@@ -474,22 +469,11 @@ async fn connect_domain_into_space(
}
trigger_and_log_gui_attached(MuxDomain(domain.domain_id())).await;
- // Rename the window into the Space's canonical workspace. Order matters:
- // bind the thread first so the WindowWorkspaceChanged-driven sync finds
- // the binding and activates the mux project in the sidebar.
- if mux.get_window(window_id).is_some() {
- workspace_threads::bind_mux_domain_thread_workspace(
- &plan.thread_id,
- Some(plan.workspace_name.clone()),
- );
- if let Some(mut window) = mux.get_window_mut(window_id) {
- window.set_workspace(&plan.workspace_name);
- }
- } else {
- // The window died before we could populate it (e.g. empty server and
- // the connui closed first); domain windows may still exist elsewhere.
- workspace_threads::bind_mux_domain_thread_workspace(&plan.thread_id, None);
- }
+ // Deliberately NO workspace rename here. The Space binding is carried by
+ // the claimed space on the TermWindow; renaming the mux window's
+ // workspace would be reconciled to the REMOTE mux server by the client
+ // domain (SetWindowWorkspace), polluting the server's workspace names and
+ // breaking the primary-window fold on every future attach.
Ok(())
}
diff --git a/wezterm-gui/src/termwindow/mouseevent.rs b/wezterm-gui/src/termwindow/mouseevent.rs
index 6a18f8a0..c3714b12 100644
--- a/wezterm-gui/src/termwindow/mouseevent.rs
+++ b/wezterm-gui/src/termwindow/mouseevent.rs
@@ -255,7 +255,10 @@ impl super::TermWindow {
return 0.0;
}
- let nav_height = pane_nav_bar_height_for_metrics(self.render_metrics);
+ let nav_height = self.pane_nav_bar_height_for_pane(&pos.pane, self.render_metrics);
+ if nav_height == 0 {
+ return 0.0;
+ }
let icon_size = nav_height.saturating_sub(PANE_NAV_INSET * 2).clamp(20, 24);
let button_size = nav_height
.saturating_sub(TAB_VERTICAL_PADDING * 2)
@@ -430,13 +433,17 @@ impl super::TermWindow {
0.0
};
let (padding_left, _) = self.padding_left_top();
- let nav_height = pane_nav_bar_height_for_metrics(self.render_metrics) as f32;
let cell_width = self.render_metrics.cell_size.width as f32;
let cell_height = self.render_metrics.cell_size.height as f32;
let x = event.coords.x as f32;
let y = event.coords.y as f32;
for pos in tab.iter_panes_ignoring_zoom() {
+ let nav_height =
+ self.pane_nav_bar_height_for_pane(&pos.pane, self.render_metrics) as f32;
+ if nav_height <= 0.0 {
+ continue;
+ }
let content_pane_x =
padding_left + border.left.get() as f32 + pos.left as f32 * cell_width;
let pane_x = if pos.left == 0 && self.workspace_sidebar_width() > 0 {
@@ -785,7 +792,8 @@ impl super::TermWindow {
+ (pos.left as isize * global_cell_size.width);
let pane_top =
padding_top as isize + first_line_offset + (pos.top as isize * global_cell_size.height);
- let pane_nav_height = pane_nav_bar_height_for_metrics(self.render_metrics) as isize;
+ let pane_nav_height =
+ self.pane_nav_bar_height_for_pane(&pos.pane, self.render_metrics) as isize;
let local_x = event.coords.x.sub(pane_left);
let local_y = event.coords.y.sub(pane_top + pane_nav_height);
diff --git a/wezterm-gui/src/termwindow/render/pane.rs b/wezterm-gui/src/termwindow/render/pane.rs
index 68935f09..bcd90755 100644
--- a/wezterm-gui/src/termwindow/render/pane.rs
+++ b/wezterm-gui/src/termwindow/render/pane.rs
@@ -39,10 +39,11 @@ use window::MouseEventKind as WMEK;
impl crate::TermWindow {
fn pane_nav_bar_height(&self, pos: &PositionedPane) -> usize {
- pane_nav_bar_height_for_metrics(self.render_metrics).min(
- pos.pixel_height
- .saturating_sub(self.render_metrics.cell_size.height.max(1) as usize),
- )
+ self.pane_nav_bar_height_for_pane(&pos.pane, self.render_metrics)
+ .min(
+ pos.pixel_height
+ .saturating_sub(self.render_metrics.cell_size.height.max(1) as usize),
+ )
}
fn pane_content_origin(&self, pos: &PositionedPane) -> anyhow::Result<(f32, f32)> {
@@ -80,7 +81,8 @@ impl crate::TermWindow {
};
let mut height = (pos.height as f32 * self.render_metrics.cell_size.height as f32).max(1.0);
if self.collapsed_pane_layouts.contains_key(&pos.pane_stack_id) && pos.top > 0 {
- height = height.max(pane_nav_bar_height_for_metrics(self.render_metrics) as f32);
+ height =
+ height.max(self.pane_nav_bar_height_for_pane(&pos.pane, self.render_metrics) as f32);
}
Ok(euclid::rect(
@@ -196,7 +198,13 @@ impl crate::TermWindow {
let strip_left = pane_rect.origin.x.max(0.0) as usize;
let strip_right = pane_rect.max_x().max(0.0) as usize;
let strip_height = pane_rect.size.height.max(1.0) as usize;
- let chrome_height = pane_nav_bar_height_for_metrics(self.render_metrics).min(strip_height);
+ let chrome_height = self
+ .pane_nav_bar_height_for_pane(&pos.pane, self.render_metrics)
+ .min(strip_height);
+ if chrome_height == 0 {
+ // Remote mux panes have no nav bar; don't paint one.
+ return Ok(0);
+ }
let icon_size = chrome_height
.saturating_sub(PANE_NAV_INSET * 2)
.clamp(20, 24);
diff --git a/wezterm-gui/src/termwindow/resize.rs b/wezterm-gui/src/termwindow/resize.rs
index 8288061e..bce8ac89 100644
--- a/wezterm-gui/src/termwindow/resize.rs
+++ b/wezterm-gui/src/termwindow/resize.rs
@@ -263,6 +263,30 @@ impl super::TermWindow {
}
}
+ /// Per-pane navigation bar height. Panes that belong to a mux client
+ /// domain (remote wezterm mux) get NO nav bar: the mux protocol sizes a
+ /// leaf tab from its pane, so stealing nav-bar rows from a ClientPane
+ /// echoes back from the server as a smaller tab and produces a feedback
+ /// loop that shrinks the window a few rows per round-trip.
+ pub(crate) fn pane_nav_bar_height_for_pane(
+ &self,
+ pane: &std::sync::Arc<dyn mux::pane::Pane>,
+ render_metrics: RenderMetrics,
+ ) -> usize {
+ let is_client_pane = Mux::get()
+ .get_domain(pane.domain_id())
+ .map_or(false, |domain| {
+ domain
+ .downcast_ref::<wezterm_client::domain::ClientDomain>()
+ .is_some()
+ });
+ if is_client_pane {
+ 0
+ } else {
+ pane_nav_bar_height_for_metrics(render_metrics)
+ }
+ }
+
pub(crate) fn terminal_size_for_positioned_pane(
&self,
pos: &PositionedPane,
@@ -270,7 +294,8 @@ impl super::TermWindow {
) -> TerminalSize {
let cell_width = render_metrics.cell_size.width.max(1) as usize;
let cell_height = render_metrics.cell_size.height.max(1) as usize;
- let pane_nav_height = pane_nav_bar_height_for_metrics(render_metrics)
+ let pane_nav_height = self
+ .pane_nav_bar_height_for_pane(&pos.pane, render_metrics)
.min(pos.pixel_height.saturating_sub(cell_height));
let pixel_width = pos.pixel_width.max(cell_width);
let pixel_height = pos
diff --git a/wezterm-gui/src/workspace_threads.rs b/wezterm-gui/src/workspace_threads.rs
index e812f990..14334ecb 100644
--- a/wezterm-gui/src/workspace_threads.rs
+++ b/wezterm-gui/src/workspace_threads.rs
@@ -1679,6 +1679,21 @@ impl WorkspaceThreadStore {
} else {
(project_id, false)
}
+ } else if self.is_client_domain_space(space_id) {
+ // A mux-domain Space's connect window lives in the default
+ // mux workspace, which is not bound to any thread. Resolve to
+ // the Space's mux project instead of manufacturing a local
+ // Home project.
+ let Some(project_id) = self
+ .projects
+ .iter()
+ .find(|p| p.space_id == space_id && is_mux_domain_project_id(&p.id))
+ .map(|p| p.id.clone())
+ else {
+ return changed;
+ };
+ let set = self.set_active_project_for_space(space_id, project_id.clone());
+ (project_id, set)
} else {
self.ensure_current_project(space_id, active_workspace)
};
@@ -3333,9 +3348,6 @@ pub struct MuxDomainSpacePlan {
pub space_id: SpaceId,
pub project_id: ProjectId,
pub thread_id: WorkspaceThreadId,
- /// Deterministic canonical workspace name for the thread; the connect
- /// window is renamed into this workspace once attach has completed.
- pub workspace_name: String,
}
/// Find-or-create the dedicated Space for a mux client domain, along with its
@@ -3391,42 +3403,15 @@ pub fn ensure_mux_domain_space(domain_name: &str) -> MuxDomainSpacePlan {
space.active_project_id = Some(project_id.clone());
}
- let workspace_name = workspace_name_for_thread(&project_id, &thread_id);
persist_locked(&store);
MuxDomainSpacePlan {
space_id,
project_id,
thread_id,
- workspace_name,
}
}
-/// Point a mux-domain thread at the mux workspace it is currently
-/// materialized in (or clear it with `None` when the connect fails).
-/// Only applies to mux-domain threads; returns whether a change was made.
-pub fn bind_mux_domain_thread_workspace(thread_id: &str, workspace: Option<String>) -> bool {
- let mut store = THREAD_STORE.lock();
- let mut changed = false;
- for project in store.projects.iter_mut() {
- if !is_mux_domain_project_id(&project.id) {
- continue;
- }
- if let Some(thread) = project.threads.iter_mut().find(|t| t.id == thread_id) {
- if thread.materialized_workspace_name != workspace {
- thread.materialized_workspace_name = workspace;
- thread.last_active_at = now_ts();
- changed = true;
- }
- break;
- }
- }
- if changed {
- persist_locked(&store);
- }
- changed
-}
-
pub fn remote_host_id_for_project_id(project_id: &str) -> &str {
project_id
.split_once(REMOTE_PROJECT_SPACE_SEPARATOR)