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
gui: rebuild the tab bar and sidebar row chrome
RoversXf3cc2fac10e2
diff --git a/wezterm-gui/src/termwindow/mouseevent.rs b/wezterm-gui/src/termwindow/mouseevent.rsindex 58a2ceba..91117855 100644--- a/wezterm-gui/src/termwindow/mouseevent.rs+++ b/wezterm-gui/src/termwindow/mouseevent.rs@@ -6,7 +6,7 @@ use crate::termwindow::space_swipe::{SidebarSpaceSwipeFinish, SidebarSpaceSwipeUuse crate::termwindow::ui::platform_chrome::WindowTabChromeParams;use crate::termwindow::ui::sidebar::SpaceConnectionState;use crate::termwindow::ui::tokens::{- PANE_NAV_BUTTON_GAP, PANE_NAV_INSET, PANE_NAV_TAB_GAP, TAB_ROW_START_PADDING,+ PANE_NAV_INSET, PANE_NAV_TAB_GAP, TAB_MIN_WIDTH, TAB_ROW_START_PADDING, TAB_TARGET_WIDTH,TAB_VERTICAL_PADDING, WINDOW_TAB_ACTION_RESERVED_WIDTH, WINDOW_TAB_GAP,WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE, WINDOW_TAB_LEADING_ACTION_GAP, WINDOW_TAB_TOP_SPACER,};@@ -208,6 +208,31 @@ fn missing_ssh_host_blocks_activation(project_is_remote && !has_ssh_host && !space_has_client_domain}+/// Divide a tab row of `viewport_width` among `tab_count` tabs.+///+/// Everything is already in device pixels, which keeps the rule testable+/// without a live window. `target` is the width a tab wants; `floor` is the+/// narrowest it stays readable at. Once the tabs no longer fit even at `floor`+/// the row overflows and its caller scrolls.+fn adaptive_tab_width_pixels(+ tab_count: usize,+ viewport_width: f32,+ gap: f32,+ target: f32,+ floor: f32,+) -> f32 {+ let floor = floor.min(target);+ if tab_count <= 1 {+ return target;+ }+ let count = tab_count as f32;+ let usable = (viewport_width - gap * (count - 1.0)).max(0.0);+ // floor(), never ceil(): at the shrink threshold the tabs plus their gaps+ // have to add up to at most the viewport, or every row would carry a pixel+ // of phantom scroll.+ (usable / count).floor().clamp(floor, target)+}+#[cfg(test)]mod window_tab_layout_tests {use super::{@@ -367,7 +392,61 @@ impl super::TermWindow {}}+ /// Width of one tab surface in a row that holds `tab_count` of them.+ ///+ /// Tabs are chrome, so the terminal font plays no part: the row's own width+ /// and how many tabs share it decide everything. See `TAB_TARGET_WIDTH`.+ pub(super) fn adaptive_tab_width(&self, tab_count: usize, viewport_width: f32, gap: f32) -> f32 {+ // Whole pixels: the painters round the width up before laying tabs out,+ // and the scroll clamps use it raw. A fractional ui scale would+ // otherwise leave them disagreeing by up to a pixel per tab.+ adaptive_tab_width_pixels(+ tab_count,+ viewport_width,+ gap,+ self.ui_f32(TAB_TARGET_WIDTH).floor(),+ self.ui_f32(TAB_MIN_WIDTH).floor(),+ )+ }++ /// The gap the window tab row leaves between neighbouring tabs.+ pub(super) fn window_tab_gap_pixels(&self) -> f32 {+ if self.config.use_fancy_tab_bar {+ self.ui_px(WINDOW_TAB_GAP) as f32+ } else {+ 0.0+ }+ }++ /// How many surfaces the window tab row paints: the mux tabs plus the+ /// synthetic content-view tabs. Counted off `tab_bar` rather than the mux+ /// window so this matches `paint_fancy_tab_bar` frame for frame — tab width+ /// now depends on the count, so a stale one would resize every tab.+ pub(super) fn window_tab_bar_item_count(&self) -> usize {+ let mux_tabs = if self.active_content_view_is_remote_thread() {+ 0+ } else {+ self.tab_bar+ .items()+ .iter()+ .filter(|item| matches!(item.item, TabBarItem::Tab { .. }))+ .count()+ };+ mux_tabs + self.content_view_count()+ }+pub(super) fn window_tab_width_pixels(&self) -> f32 {+ self.adaptive_tab_width(+ self.window_tab_bar_item_count(),+ self.window_tab_viewport_width(),+ self.window_tab_gap_pixels(),+ )+ }++ /// The collapsed pane strip still sizes its chips off the terminal cell+ /// grid; only the window tab row and the pane nav bar moved to+ /// `adaptive_tab_width`.+ pub(super) fn collapsed_pane_tab_width_pixels(&self) -> f32 {let cell_width = self.render_metrics.cell_size.width.max(1) as f32;(self.config.tab_max_width as f32 * cell_width).max(cell_width * 15.0)@@ -497,7 +576,10 @@ impl super::TermWindow {.saturating_sub(self.tab_bar_left_edge()).saturating_sub(self.right_sidebar_width()).saturating_sub(border.right.get() as usize)- .saturating_sub(left_padding.max(0.0) as usize)+ // ceil, matching `paint_fancy_tab_bar`'s viewport_left: tab width is+ // derived from this number, so a one-pixel disagreement would clip+ // the last tab in a row that otherwise fits exactly.+ .saturating_sub(left_padding.max(0.0).ceil() as usize).saturating_sub(if self.config.use_fancy_tab_bar {self.ui_px(TAB_ROW_START_PADDING) + self.window_tab_trailing_action_reserved_width()} else {@@ -507,26 +589,13 @@ impl super::TermWindow {}pub(super) fn max_window_tab_scroll_offset(&self) -> f32 {- let mux = Mux::get();- let Some(window) = mux.get_window(self.mux_window_id) else {- return 0.0;- };- let window_tab_count = if self.active_content_view_is_remote_thread() {- 0- } else {- window.len()- };- let tab_count = window_tab_count + self.content_view_count();+ let tab_count = self.window_tab_bar_item_count();if tab_count <= 1 {return 0.0;}let tab_width = self.window_tab_width_pixels();- let tab_gap = if self.config.use_fancy_tab_bar {- self.ui_px(WINDOW_TAB_GAP) as f32- } else {- 0.0- };+ let tab_gap = self.window_tab_gap_pixels();let total_width =tab_count as f32 * tab_width + tab_count.saturating_sub(1) as f32 * tab_gap;let available_width = self.window_tab_viewport_width();@@ -566,34 +635,28 @@ impl super::TermWindow {return 0.0;}- let cell_width = self.render_metrics.cell_size.width as f32;- let content_width = pos.width as f32 * cell_width;- let pane_width = if pos.left == 0 && self.workspace_sidebar_width() > 0 {- content_width- + (self.padding_left_top().0 - self.workspace_sidebar_width() as f32).max(0.0)+ // Share the painter's viewport rather than re-deriving one here: it+ // used to assume two trailing action buttons where the painter draws+ // four or five, and now that tab width follows the row, any drift would+ // strand the last tab out of scroll range.+ let tab_gap = self.ui_px(PANE_NAV_TAB_GAP) as f32;+ // A collapsed stack has its own strip geometry and its own (legacy,+ // cell-derived) tab width; clamping it against the expanded bar's+ // figures left it with a stretch of dead scroll.+ let (viewport_width, tab_width) = if self.collapsed_pane_layouts.contains_key(&stack_id) {+ (+ self.collapsed_pane_nav_tab_viewport_width(&pos),+ self.collapsed_pane_tab_width_pixels().ceil(),+ )} else {- content_width+ let viewport_width = self.pane_nav_tab_viewport_width(&pos);+ (+ viewport_width,+ self.adaptive_tab_width(tab_count, viewport_width, tab_gap),+ )};- let pane_left = pos.left;- if pane_width <= 0.0 {- return 0.0;- }-- let nav_height = self.pane_nav_bar_height();- let icon_size = nav_height- .saturating_sub(self.ui_px(PANE_NAV_INSET) * 2)- .clamp(self.ui_px(20), self.ui_px(24));- let button_size = nav_height- .saturating_sub(self.ui_px(TAB_VERTICAL_PADDING) * 2)- .max(icon_size);- let controls_width = (button_size + self.ui_px(PANE_NAV_BUTTON_GAP))- .saturating_mul(2)- .saturating_add(self.ui_px(PANE_NAV_INSET))- .saturating_add(self.pane_nav_tab_left_inset(pane_left));- let viewport_width = (pane_width as usize).saturating_sub(controls_width).max(1) as f32;- let tab_width = self.window_tab_width_pixels();- let total_width = tab_count as f32 * tab_width- + tab_count.saturating_sub(1) as f32 * self.ui_px(PANE_NAV_TAB_GAP) as f32;+ let total_width =+ tab_count as f32 * tab_width + tab_count.saturating_sub(1) as f32 * tab_gap;(total_width - viewport_width).max(0.0)}@@ -8948,3 +9011,81 @@ mod space_menu_tests {);}}++#[cfg(test)]+mod adaptive_tab_width_tests {+ use super::adaptive_tab_width_pixels;++ const TARGET: f32 = 300.0;+ const FLOOR: f32 = 160.0;+ const GAP: f32 = 18.0;++ fn width(count: usize, viewport: f32) -> f32 {+ adaptive_tab_width_pixels(count, viewport, GAP, TARGET, FLOOR)+ }++ /// A roomy row does not stretch its tabs to fill it: two tabs in a wide+ /// window stay at the target width, the way browser tab strips behave.+ #[test]+ fn a_roomy_row_parks_every_tab_at_the_target_width() {+ assert_eq!(width(1, 2000.0), TARGET);+ assert_eq!(width(2, 2000.0), TARGET);+ assert_eq!(width(5, 2000.0), TARGET);+ }++ /// Past the point where targets fit, the tabs give up width together.+ #[test]+ fn crowding_shrinks_the_tabs_evenly() {+ let w = width(8, 1600.0);+ assert!(w < TARGET, "{w} should be under the target");+ assert!(w > FLOOR, "{w} should still be over the floor");+ // 8 tabs and 7 gaps have to land inside the row.+ assert!(8.0 * w + 7.0 * GAP <= 1600.0);+ }++ /// Exactly at the fit boundary the row must not leave a stray pixel of+ /// scroll behind — that is what the floor() in the divide is for.+ #[test]+ fn a_row_that_just_fits_leaves_no_phantom_scroll() {+ for count in 2..=40usize {+ for viewport in [640.0f32, 977.0, 1280.0, 1441.0, 2560.0] {+ let w = width(count, viewport);+ let total = count as f32 * w + (count - 1) as f32 * GAP;+ if w > FLOOR {+ assert!(+ total <= viewport,+ "count={count} viewport={viewport} width={w} total={total}"+ );+ }+ }+ }+ }++ /// Below the floor the tabs stop shrinking and the row overflows instead,+ /// which is the signal for the caller to scroll.+ #[test]+ fn the_floor_holds_and_hands_the_overflow_to_the_scroller() {+ let w = width(40, 1200.0);+ assert_eq!(w, FLOOR);+ assert!(40.0 * w + 39.0 * GAP > 1200.0);+ }++ /// A window narrower than one tab (or with no room at all) still reports a+ /// usable width rather than 0 or a negative.+ #[test]+ fn a_starved_row_still_reports_the_floor() {+ assert_eq!(width(3, 0.0), FLOOR);+ assert_eq!(width(3, -50.0), FLOOR);+ assert_eq!(width(0, 800.0), TARGET);+ }++ /// The floor is advisory: a design that set it above the target must not+ /// produce a tab wider than the target.+ #[test]+ fn a_floor_above_the_target_never_wins() {+ assert_eq!(+ adaptive_tab_width_pixels(6, 400.0, GAP, 100.0, 250.0),+ 100.0+ );+ }+}diff --git a/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs b/wezterm-gui/src/termwindow/render/fancy_tab_bar.rsindex a93b6d4e..c9d4df4e 100644--- a/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs+++ b/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs@@ -1,12 +1,16 @@use crate::customglyph::BlockKey;-use crate::quad::{QuadTrait, TripleLayerQuadAllocator, TripleLayerQuadAllocatorTrait};+use crate::quad::{+ HeapQuadAllocator, QuadClipRect, QuadTrait, TripleLayerQuadAllocator,+ TripleLayerQuadAllocatorTrait,+};use crate::shapecache::{BorrowedShapeCacheKey, ShapedInfo};use crate::tabbar::{TabBarItem, TabEntry};use crate::termwindow::ui::icons::SvgIcon;use crate::termwindow::ui::platform_chrome::uses_integrated_window_buttons;use crate::termwindow::ui::tokens::{- CAPSULE_BORDER_WIDTH, ICON_BUTTON_BORDER_WIDTH, SIDEBAR_INSET, TAB_CLOSE_HOVER_INSET,- TAB_CLOSE_HOVER_RADIUS, TAB_CLOSE_RIGHT_GAP, TAB_ROW_START_PADDING, TAB_VERTICAL_PADDING,+ ICON_BUTTON_BORDER_WIDTH, SIDEBAR_INSET, TAB_CLOSE_HOVER_INSET,+ TAB_CLOSE_HOVER_RADIUS, TAB_CONTENT_INSET, TAB_ICON_SIZE, TAB_ROW_START_PADDING,+ TAB_VERTICAL_PADDING,WINDOW_TAB_ADD_BUTTON_RADIUS, WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_Y_OFFSET, WINDOW_TAB_GAP,WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE, WINDOW_TAB_LEADING_ACTION_GAP,WINDOW_TAB_LEADING_ACTION_ICON_SIZE, WINDOW_TAB_RADIUS, WINDOW_TAB_TOP_SPACER,@@ -70,7 +74,7 @@ impl crate::TermWindow {};let content_row_y = row_y + content_top_spacer;let content_row_height = row_height.saturating_sub(content_top_spacer);- let icon_size = fancy_tab_icon_size(&metrics, content_row_height as f32) as usize;+ let icon_size = self.ui_px(TAB_ICON_SIZE).min(content_row_height);let button_size = content_row_height.saturating_sub(self.ui_px(TAB_VERTICAL_PADDING) * 2).max(icon_size);@@ -131,7 +135,10 @@ impl crate::TermWindow {layers,1,euclid::rect(row_x as f32, divider_y as f32, row_width as f32, 1.0),- foreground.mul_alpha(0.14),+ // The shared separator token, same as the sidebar edges draw:+ // this used to be a one-off `text * 0.14`, which read markedly+ // brighter than every other rule in the window.+ chrome.separator,).context("fancy tab bar pane layer divider")?;}@@ -247,6 +254,21 @@ impl crate::TermWindow {}}+ // Dissolve the row into the bar wherever it runs on past the viewport,+ // so a clipped tab reads as continuing rather than as one sliced in+ // half. Goes down after the tabs and before the trailing actions, which+ // own the space beyond the boundary.+ self.paint_tab_row_fades(+ layers,+ background,+ content_row_y,+ content_row_height,+ viewport_left,+ viewport_right,+ scroll_offset > 0.5,+ scroll_offset < max_scroll - 0.5,+ )?;+// Establish a hard paint boundary before the trailing actions. Tab// surfaces and glyphs are already geometrically clipped, but this mask// also protects the action area from shader and texture overhang.@@ -398,14 +420,10 @@ impl crate::TermWindow {if self.fancy_tab_bar_shows_window_buttons() {let chrome = UiPalette::for_appearance(crate::native_settings::effective_appearance());- let font = self- .fonts- .title_font_with_size(crate::native_settings::tab_font_size())?;- let metrics = RenderMetrics::with_font_metrics(&font.metrics());let content_top_spacer = self.ui_px(WINDOW_TAB_TOP_SPACER).min(row_height);let content_row_y = row_y + content_top_spacer;let content_row_height = row_height.saturating_sub(content_top_spacer);- let icon_size = fancy_tab_icon_size(&metrics, content_row_height as f32) as usize;+ let icon_size = self.ui_px(TAB_ICON_SIZE).min(content_row_height);let button_size = content_row_height.saturating_sub(self.ui_px(TAB_VERTICAL_PADDING) * 2).max(icon_size);@@ -724,14 +742,6 @@ impl crate::TermWindow {background: LinearRgba,foreground: LinearRgba,) -> anyhow::Result<()> {- self.filled_rectangle(- layers,- 1,- euclid::rect(visible_left, row_y as f32, visible_width, row_height as f32),- background,- )- .context("window tab background")?;-let hover_x = visible_left.max(0.0) as usize;let hover_width = visible_width.max(0.0) as usize;let is_hovered = self.is_pointer_over_ui_rect(hover_x, row_y, hover_width, row_height);@@ -743,68 +753,99 @@ impl crate::TermWindow {background};let tab_surface_y = row_y + (row_height.saturating_sub(button_size) / 2);- self.fill_rounded_rectangle_with_border(++ ui_items.push(UIItem {+ x: visible_left.max(0.0) as usize,+ y: row_y,+ width: visible_width.max(0.0) as usize,+ height: row_height,+ item_type: UIItemType::TabBar(TabBarItem::Tab { tab_idx, active }),+ });++ // The whole tab -- backdrop, capsule, shadow and content -- is recorded+ // in the tab's own space, its left edge at 0, and replayed clipped to+ // the row's viewport.+ //+ // Recording it at full width is what keeps a cut tab looking like a cut+ // tab: `snapped_rounded_corner_radius` clamps the radius to half the+ // rect it is given, so drawing the capsule pre-cut turned a 30px sliver+ // into its own little lozenge instead of the end of a 320px pill. The+ // clip supplies the hard edge, so the corners need no special casing.+ //+ // Recording it in local space is what keeps the content in the right+ // place: once the row scrolls a tab's true origin goes negative, which+ // the unsigned coordinates the painters take cannot express, and laying+ // out from a clamped 0 drew the wrong slice and dropped the close+ // target on a neighbouring tab.+ let out_layers = layers;+ let mut content = HeapQuadAllocator::default();+ let mut content_layers = TripleLayerQuadAllocator::Heap(&mut content);+ let layers = &mut content_layers;++ self.filled_rectangle(layers,1,- euclid::rect(- visible_left,- tab_surface_y as f32,- visible_width,- button_size as f32,- ),+ euclid::rect(0.0, row_y as f32, tab_width as f32, row_height as f32),+ background,+ )+ .context("window tab background")?;++ self.paint_tab_capsule(+ layers,+ 1,+ tab_surface_y,+ tab_width,+ button_size,+ self.ui_f32(WINDOW_TAB_RADIUS),tab_surface_color,if active {chrome.control_border} else {LinearRgba::TRANSPARENT},- self.ui_f32(WINDOW_TAB_RADIUS),- CAPSULE_BORDER_WIDTH,+ active,).context("window tab surface")?;- ui_items.push(UIItem {- x: visible_left.max(0.0) as usize,- y: row_y,- width: visible_width.max(0.0) as usize,- height: row_height,- item_type: UIItemType::TabBar(TabBarItem::Tab { tab_idx, active }),- });-- let tab_left = tab_left.max(0.0) as usize;- let icon_x = tab_left + self.ui_px(WINDOW_TAB_INSET);+ let icon_x = self.ui_px(TAB_CONTENT_INSET);let icon_y = row_y + (row_height.saturating_sub(icon_size) / 2);- if icon_x >= viewport_left && icon_x.saturating_add(icon_size) <= viewport_right {- self.paint_fancy_tab_icon(- layers,- SvgIcon::SquareTerminal,- icon_x,- icon_y,- icon_size,- foreground,- )?;- }+ self.paint_fancy_tab_icon(+ layers,+ SvgIcon::SquareTerminal,+ icon_x,+ icon_y,+ icon_size,+ foreground,+ )?;- let close_x = tab_left- .saturating_add(tab_width)- .saturating_sub(button_size + self.ui_px(TAB_CLOSE_RIGHT_GAP));+ let close_x = self.tab_close_button_x(tab_width, button_size, icon_size);let close_y = row_y + (row_height.saturating_sub(button_size) / 2);+ // Where the button really lands, for hover and hit testing. A target+ // placed from a clamped origin used to sit over the neighbouring tab+ // and close the wrong one.+ let close_screen_x = tab_left + close_x as f32;+ let close_hit_visible = close_screen_x >= viewport_left as f32+ && close_screen_x + button_size as f32 <= viewport_right as f32;let close_slot_reserved = self.config.show_close_tab_button_in_tabs && !is_renaming;let show_close = close_slot_reserved && (active || is_hovered);- if show_close- && close_x >= viewport_left- && close_x.saturating_add(button_size) <= viewport_right- {- let close_hovered =- self.is_pointer_over_ui_rect(close_x, close_y, button_size, button_size);+ if show_close {+ // Hover feedback follows the hit target: a half-clipped button that+ // lit up without accepting the click sent it through to the tab+ // underneath, switching tabs instead of closing one.+ let close_hit_x = close_screen_x.max(0.0) as usize;+ let close_hovered = close_hit_visible+ && self.is_pointer_over_ui_rect(close_hit_x, close_y, button_size, button_size);if close_hovered {- let hover_alpha =- if self.is_pointer_pressing_ui_rect(close_x, close_y, button_size, button_size)- {- 0.20- } else {- 0.12- };+ let hover_alpha = if self.is_pointer_pressing_ui_rect(+ close_hit_x,+ close_y,+ button_size,+ button_size,+ ) {+ 0.20+ } else {+ 0.12+ };let hover_inset = self.ui_px(TAB_CLOSE_HOVER_INSET).min(button_size / 2);let hover_size = button_size.saturating_sub(hover_inset * 2);self.fill_rounded_rectangle(@@ -821,13 +862,15 @@ impl crate::TermWindow {).context("window tab close hover")?;}- ui_items.push(UIItem {- x: close_x,- y: close_y,- width: button_size,- height: button_size,- item_type: UIItemType::CloseTab(tab_idx),- });+ if close_hit_visible {+ ui_items.push(UIItem {+ x: close_hit_x,+ y: close_y,+ width: button_size,+ height: button_size,+ item_type: UIItemType::CloseTab(tab_idx),+ });+ }let close_fg = if close_hovered {foreground} else {@@ -846,23 +889,18 @@ impl crate::TermWindow {let mut text_x = icon_x + icon_size + self.ui_px(WINDOW_TAB_ICON_GAP);if let Some(status) = item.status {let status_x = text_x;- if status_x >= viewport_left && status_x.saturating_add(icon_size) <= viewport_right {- self.paint_status_icon(layers, 2, status, status_x, icon_y, icon_size, foreground)- .context("window tab status icon")?;- }+ self.paint_status_icon(layers, 2, status, status_x, icon_y, icon_size, foreground)+ .context("window tab status icon")?;text_x = status_x + icon_size + self.ui_px(WINDOW_TAB_ICON_GAP);}let text_right = if close_slot_reserved {close_x.saturating_sub(self.ui_px(WINDOW_TAB_ICON_GAP))} else {- tab_left- .saturating_add(tab_width)- .saturating_sub(self.ui_px(WINDOW_TAB_INSET))- }- .min(viewport_right);+ tab_width.saturating_sub(self.ui_px(TAB_CONTENT_INSET))+ };let text_width = text_right.saturating_sub(text_x);let text_y = row_y + (row_height.saturating_sub(metrics.cell_size.height as usize) / 2);- if text_x >= viewport_left && text_x < viewport_right {+ if text_width > 0 {let text_fg = if is_renaming {self.filled_rectangle(layers,@@ -891,6 +929,23 @@ impl crate::TermWindow {text_fg,)?;}++ drop(content_layers);+ content+ .apply_to_clipped_at(+ out_layers,+ tab_left,+ 0.0,+ QuadClipRect::from_top_left_pixels(+ viewport_left as f32,+ row_y as f32,+ viewport_right as f32,+ (row_y + row_height) as f32,+ &self.dimensions,+ ),+ 1.0,+ )+ .context("window tab content")?;Ok(())}@@ -932,65 +987,76 @@ impl crate::TermWindow {background};let tab_surface_y = row_y + (row_height.saturating_sub(button_size) / 2);- self.fill_rounded_rectangle_with_border(++ ui_items.push(UIItem {+ x: visible_left.max(0.0) as usize,+ y: row_y,+ width: visible_width.max(0.0) as usize,+ height: row_height,+ item_type: UIItemType::TabBar(TabBarItem::ContentView { id }),+ });++ // Whole tab recorded at full width in the tab's own space, replayed+ // clipped to the row. See `paint_window_tab`.+ let out_layers = layers;+ let mut content = HeapQuadAllocator::default();+ let mut content_layers = TripleLayerQuadAllocator::Heap(&mut content);+ let layers = &mut content_layers;++ self.filled_rectangle(layers,1,- euclid::rect(- visible_left,- tab_surface_y as f32,- visible_width,- button_size as f32,- ),+ euclid::rect(0.0, row_y as f32, tab_width as f32, row_height as f32),+ background,+ )+ .context("content view tab background")?;+ self.paint_tab_capsule(+ layers,+ 1,+ tab_surface_y,+ tab_width,+ button_size,+ self.ui_f32(WINDOW_TAB_RADIUS),surface,if active {chrome.control_border} else {LinearRgba::TRANSPARENT},- self.ui_f32(WINDOW_TAB_RADIUS),- CAPSULE_BORDER_WIDTH,+ active,).context("content view tab surface")?;- ui_items.push(UIItem {- x: visible_left.max(0.0) as usize,- y: row_y,- width: visible_width.max(0.0) as usize,- height: row_height,- item_type: UIItemType::TabBar(TabBarItem::ContentView { id }),- });-- let tab_left = tab_left.max(0.0) as usize;- let icon_x = tab_left + self.ui_px(WINDOW_TAB_INSET);+ let icon_x = self.ui_px(TAB_CONTENT_INSET);let icon_y = row_y + (row_height.saturating_sub(icon_size) / 2);- if icon_x >= viewport_left && icon_x.saturating_add(icon_size) <= viewport_right {- self.paint_fancy_tab_icon(- layers,- SvgIcon::Link2,- icon_x,- icon_y,- icon_size,- foreground,- )?;- }+ self.paint_fancy_tab_icon(+ layers,+ SvgIcon::Link2,+ icon_x,+ icon_y,+ icon_size,+ foreground,+ )?;- let close_x = tab_left- .saturating_add(tab_width)- .saturating_sub(button_size + self.ui_px(TAB_CLOSE_RIGHT_GAP));+ let close_x = self.tab_close_button_x(tab_width, button_size, icon_size);let close_y = row_y + (row_height.saturating_sub(button_size) / 2);- let close_slot_visible =- close_x >= viewport_left && close_x.saturating_add(button_size) <= viewport_right;- let show_close = close_slot_visible && (active || is_hovered);+ let close_screen_x = tab_left + close_x as f32;+ let close_hit_visible = close_screen_x >= viewport_left as f32+ && close_screen_x + button_size as f32 <= viewport_right as f32;+ let show_close = active || is_hovered;if show_close {- let close_hovered =- self.is_pointer_over_ui_rect(close_x, close_y, button_size, button_size);- ui_items.push(UIItem {- x: close_x,- y: close_y,- width: button_size,- height: button_size,- item_type: UIItemType::ContentViewClose(id),- });+ let close_hit_x = close_screen_x.max(0.0) as usize;+ let close_hovered = close_hit_visible+ && self.is_pointer_over_ui_rect(close_hit_x, close_y, button_size, button_size);+ if close_hit_visible {+ ui_items.push(UIItem {+ x: close_hit_x,+ y: close_y,+ width: button_size,+ height: button_size,+ item_type: UIItemType::ContentViewClose(id),+ });+ }self.paint_fancy_tab_icon(layers,SvgIcon::X,@@ -1006,22 +1072,32 @@ impl crate::TermWindow {}let text_x = icon_x + icon_size + self.ui_px(WINDOW_TAB_ICON_GAP);- let text_right = if close_slot_visible {- close_x.saturating_sub(self.ui_px(WINDOW_TAB_ICON_GAP))- } else {- tab_left- .saturating_add(tab_width)- .saturating_sub(self.ui_px(WINDOW_TAB_INSET))- }- .min(viewport_right);+ let text_right = close_x.saturating_sub(self.ui_px(WINDOW_TAB_ICON_GAP));let text_width = text_right.saturating_sub(text_x);let text_y = row_y + (row_height.saturating_sub(metrics.cell_size.height as usize) / 2);- if text_x >= viewport_left && text_x < viewport_right {+ if text_width > 0 {let line = Line::from_text(title, &CellAttributes::blank(), 0, None);self.paint_fancy_tab_text(layers, font, &line, false, text_x, text_y, text_width, foreground,)?;}++ drop(content_layers);+ content+ .apply_to_clipped_at(+ out_layers,+ tab_left,+ 0.0,+ QuadClipRect::from_top_left_pixels(+ viewport_left as f32,+ row_y as f32,+ viewport_right as f32,+ (row_y + row_height) as f32,+ &self.dimensions,+ ),+ 1.0,+ )+ .context("content view tab content")?;Ok(())}@@ -1729,13 +1805,6 @@ fn horizontal_texture_clip(})}-fn fancy_tab_icon_size(metrics: &RenderMetrics, tab_bar_height: f32) -> f32 {- let cell_height = metrics.cell_size.height.max(1) as f32;- let from_bar = (tab_bar_height - cell_height * 0.45).max(1.0);- let from_font = metrics.cell_size.height as f32 * 0.95;- from_bar.min(from_font).max(1.0).floor()-}-fn is_legacy_progress_marker(value: &str) -> bool {let mut chars = value.chars();let Some(ch) = chars.next() else {diff --git a/wezterm-gui/src/termwindow/render/pane.rs b/wezterm-gui/src/termwindow/render/pane.rsindex 3f0e41f8..ed3fb3de 100644--- a/wezterm-gui/src/termwindow/render/pane.rs+++ b/wezterm-gui/src/termwindow/render/pane.rs@@ -1,5 +1,6 @@use crate::quad::{- HeapQuadAllocator, QuadTrait, TripleLayerQuadAllocator, TripleLayerQuadAllocatorTrait,+ HeapQuadAllocator, QuadClipRect, QuadTrait, TripleLayerQuadAllocator,+ TripleLayerQuadAllocatorTrait,};use crate::selection::SelectionRange;use crate::termwindow::box_model::*;@@ -12,7 +13,8 @@ use crate::termwindow::ui::status_icon::{split_leading_legacy_progress_marker, Uuse crate::termwindow::ui::tokens::{CAPSULE_BORDER_WIDTH, ICON_BUTTON_BORDER_WIDTH, PANE_NAV_ACTION_BUTTON_RADIUS,PANE_NAV_BUTTON_GAP, PANE_NAV_ICON_GAP, PANE_NAV_INSET, PANE_NAV_TAB_GAP, PANE_NAV_TAB_RADIUS,- PANE_NAV_TAB_TOP_OFFSET, TAB_CLOSE_HOVER_INSET, TAB_CLOSE_HOVER_RADIUS, TAB_CLOSE_RIGHT_GAP,+ PANE_NAV_ACTION_ICON_SIZE, TAB_CLOSE_HOVER_INSET,+ TAB_CLOSE_HOVER_RADIUS, TAB_CONTENT_INSET, TAB_ICON_SIZE,TAB_VERTICAL_PADDING,};use crate::termwindow::{PaneNavAction, ScrollHit, UIItem, UIItemType};@@ -119,6 +121,11 @@ pub(crate) fn client_pane_lag_ms(pane: &dyn mux::pane::Pane) -> Option<u64> {}}+/// Inset from the collapsed strip's own edges to its content.+const COLLAPSED_EDGE_PADDING: usize = 8;+/// Gap the collapsed strip leaves between its tabs and its action button.+const COLLAPSED_SECTION_GAP: usize = 10;+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.@@ -129,6 +136,83 @@ impl crate::TermWindow {)}+ /// Icon, action-icon and button sizes for a nav bar of `nav_height`.+ /// The painter and the scroll clamp both size their geometry from these, so+ /// they are derived once.+ fn pane_nav_button_metrics(&self, nav_height: usize) -> (usize, usize, usize) {+ // Fixed chrome sizes, clamped only so a nav bar squeezed by a short+ // pane cannot overflow its own row. The tab icon deliberately matches+ // the window tab row's; it used to be capped at 24 here and computed+ // from the font up there, which left the two rows visibly out of step.+ let icon_size = self.ui_px(TAB_ICON_SIZE).min(nav_height);+ let action_icon_size = self.ui_px(PANE_NAV_ACTION_ICON_SIZE).min(nav_height);+ // Floored by both icons, as the window tab row is: a pane short enough+ // to squeeze the row would otherwise leave the pill shorter than the+ // icon inside it, which then top-aligns and gets its base clipped away.+ let button_size = nav_height+ .saturating_sub(self.ui_px(TAB_VERTICAL_PADDING) * 2)+ .max(action_icon_size)+ .max(icon_size);+ (icon_size, action_icon_size, button_size)+ }++ /// Width the trailing action buttons claim from the nav bar's right edge:+ /// new tab, split down, split right and zoom, plus collapse wherever the+ /// split shape allows it.+ fn pane_nav_action_reserved_width(&self, pos: &PositionedPane, nav_height: usize) -> usize {+ let (_, _, button_size) = self.pane_nav_button_metrics(nav_height);+ let action_count = 4 + usize::from(self.can_collapse_pane_stack(pos));+ action_count+ .saturating_mul(button_size + self.ui_px(PANE_NAV_BUTTON_GAP))+ .saturating_add(self.ui_px(PANE_NAV_INSET))+ }++ /// Horizontal room the *collapsed* strip leaves for its tabs.+ ///+ /// The expanded bar's `pane_nav_tab_viewport_width` does not describe this+ /// one: the collapsed strip insets by its own padding and reserves a single+ /// Expand button where the expanded bar reserves four or five. Clamping the+ /// wheel against the expanded figure left roughly a button-row of dead+ /// scroll the strip never moved through.+ pub(crate) fn collapsed_pane_nav_tab_viewport_width(&self, pos: &PositionedPane) -> f32 {+ let Some(layout) = self.collapsed_pane_layouts.get(&pos.pane_stack_id).copied() else {+ return 0.0;+ };+ if layout.split_direction == SplitDirection::Horizontal {+ // A vertical strip stacks its chips; there is nothing to scroll.+ return 0.0;+ }+ let Ok(pane_rect) = self.pane_frame_rect(pos) else {+ return 0.0;+ };+ 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 = self.pane_nav_bar_height().min(strip_height);+ let (_, _, button_size) = self.pane_nav_button_metrics(chrome_height);+ let tab_start = strip_left + COLLAPSED_EDGE_PADDING;+ let max_tab_right = strip_right+ .saturating_sub(COLLAPSED_EDGE_PADDING + button_size + COLLAPSED_SECTION_GAP);+ max_tab_right.saturating_sub(tab_start) as f32+ }++ /// Horizontal room the nav bar leaves for its tab strip. Tab width is+ /// derived from this, so the painter and the wheel-scroll clamp have to read+ /// it from the same place or the last tab drifts out of reach.+ pub(crate) fn pane_nav_tab_viewport_width(&self, pos: &PositionedPane) -> f32 {+ let nav_height = self.pane_nav_bar_height_for_pane(pos);+ if nav_height == 0 {+ return 0.0;+ }+ let Ok((pane_x, pane_width)) = self.pane_chrome_span(pos) else {+ return 0.0;+ };+ let tab_start = pane_x.max(0.0) as usize + self.pane_nav_tab_left_inset(pos.left);+ let max_tab_right = ((pane_x + pane_width).max(0.0) as usize)+ .saturating_sub(self.pane_nav_action_reserved_width(pos, nav_height));+ max_tab_right.saturating_sub(tab_start) as f32+ }+pub(crate) fn terminal_viewport_right(&self) -> f32 {let border = self.get_os_border();self.dimensions@@ -225,9 +309,7 @@ impl crate::TermWindow {},});- const COLLAPSED_EDGE_PADDING: usize = 8;const COLLAPSED_BUTTON_GAP: usize = 6;- const COLLAPSED_SECTION_GAP: usize = 10;let tabs = Mux::get().pane_stack_tabs(pos.pane.pane_id());let active_tab = tabs.iter().find(|tab| tab.is_active);@@ -308,15 +390,8 @@ impl crate::TermWindow {// bar overlays the content (it steals no viewport rows), for local// panes the viewport was already shrunk to make room.let chrome_height = self.pane_nav_bar_height().min(strip_height);- let icon_size = chrome_height- .saturating_sub(self.ui_px(PANE_NAV_INSET) * 2)- .clamp(self.ui_px(20), self.ui_px(24));- let action_icon_size = icon_size- .saturating_add(self.ui_px(2))- .clamp(icon_size, self.ui_px(26));- let button_size = chrome_height- .saturating_sub(self.ui_px(TAB_VERTICAL_PADDING) * 2)- .max(action_icon_size);+ let (icon_size, action_icon_size, button_size) =+ self.pane_nav_button_metrics(chrome_height);let button_y =pane_rect.origin.y.max(0.0) as usize + (chrome_height.saturating_sub(button_size) / 2);let mut button_x = strip_right.saturating_sub(COLLAPSED_EDGE_PADDING);@@ -342,7 +417,7 @@ impl crate::TermWindow {}let tab_start = strip_left + COLLAPSED_EDGE_PADDING;- let tab_width = self.window_tab_width_pixels().ceil() as usize;+ let tab_width = self.collapsed_pane_tab_width_pixels().ceil() as usize;let tab_step = tab_width + self.ui_px(PANE_NAV_TAB_GAP);let total_tab_width = tabs.len().saturating_mul(tab_width).saturating_add(tabs.len()@@ -406,17 +481,6 @@ impl crate::TermWindow {} else {LinearRgba::TRANSPARENT};- self.fill_rounded_rectangle_with_border(- layers,- 1,- euclid::rect(visible_left, tab_y as f32, visible_width, tab_height as f32),- tab_surface_color,- tab_border_color,- self.ui_f32(PANE_NAV_TAB_RADIUS),- CAPSULE_BORDER_WIDTH,- )- .context("collapsed pane nav tab surface")?;-self.ui_items.push(UIItem {x: visible_left.max(0.0) as usize,y: tab_y,@@ -429,8 +493,29 @@ impl crate::TermWindow {},});- let draw_tab_x = tab_left.max(0.0) as usize;- let title_icon_x = draw_tab_x + self.ui_px(PANE_NAV_INSET);+ // Reborrow: the surrounding loop cannot move the caller's `&mut`.+ let out_layers = &mut *layers;+ // Content rides in a heap and is replayed clipped to the strip's+ // viewport, recorded in the tab's own space -- left edge at 0 --+ // and shifted onto the strip on replay. See `paint_window_tab`.+ let mut content = HeapQuadAllocator::default();+ let mut content_layers = TripleLayerQuadAllocator::Heap(&mut content);+ let layers = &mut content_layers;++ self.paint_tab_capsule(+ layers,+ 1,+ tab_y,+ tab_width,+ tab_height,+ self.ui_f32(PANE_NAV_TAB_RADIUS),+ tab_surface_color,+ tab_border_color,+ selected_tab,+ )+ .context("pane nav tab surface")?;++ let title_icon_x = self.ui_px(TAB_CONTENT_INSET);let title_icon_y = tab_y + ((tab_height.saturating_sub(icon_size)) / 2);let raw_title = self.pane_nav_tab_title(tab.pane_id, &tab.title);let (title, status) =@@ -442,48 +527,52 @@ impl crate::TermWindow {} else {(raw_title.as_str(), None)};- if title_icon_x >= tab_start && title_icon_x.saturating_add(icon_size) <= max_tab_right- {- if let Some(status) = status {- self.paint_status_icon(- layers,- 2,- status,- title_icon_x,- title_icon_y,- icon_size,- this_tab_fg,- )?;- } else {- self.paint_pane_nav_icon(- layers,- SvgIcon::SquareTerminal,- title_icon_x,- title_icon_y,- icon_size,- this_tab_fg,- )?;- }+ if let Some(status) = status {+ self.paint_status_icon(+ layers,+ 2,+ status,+ title_icon_x,+ title_icon_y,+ icon_size,+ this_tab_fg,+ )?;+ } else {+ self.paint_pane_nav_icon(+ layers,+ SvgIcon::SquareTerminal,+ title_icon_x,+ title_icon_y,+ icon_size,+ this_tab_fg,+ )?;}- let raw_close_x = draw_tab_x- .saturating_add(tab_width)- .saturating_sub(button_size + self.ui_px(TAB_CLOSE_RIGHT_GAP));let close_slot_reserved = !is_renaming_tab;- let close_view_left = draw_tab_x.max(tab_start);- let close_view_right = draw_tab_x.saturating_add(tab_width).min(max_tab_right);- let close_x = raw_close_x- .min(close_view_right.saturating_sub(button_size))- .max(close_view_left);- let show_close = close_slot_reserved- && (selected_tab || is_hovered)- && close_view_right.saturating_sub(close_view_left) >= button_size;+ // The button slides to stay inside the tab's visible sliver, so a+ // half-scrolled tab keeps a usable close target instead of letting+ // it scroll off with the rest. The clamp is in the tab's own space+ // and derived from its *true* origin: it used to be computed from+ // an origin clamped to 0, which is what put the button on a+ // neighbouring tab.+ let view_left = (tab_start as f32 - tab_left).max(0.0);+ let view_right = (max_tab_right as f32 - tab_left).min(tab_width as f32);+ let close_x = (self.tab_close_button_x(tab_width, button_size, icon_size) as f32)+ .min(view_right - button_size as f32)+ .max(view_left)+ .max(0.0) as usize;+ let close_screen_x = tab_left + close_x as f32;+ let close_hit_visible = view_right - view_left >= button_size as f32;+ let close_hit_x = close_screen_x.max(0.0) as usize;+ let show_close = close_slot_reserved && (selected_tab || is_hovered);if show_close {- let close_hovered =- self.is_pointer_over_ui_rect(close_x, tab_y, button_size, button_size);+ // Hover feedback follows the hit target, or a half-clipped+ // button lights up and then passes the click through.+ let close_hovered = close_hit_visible+ && self.is_pointer_over_ui_rect(close_hit_x, tab_y, button_size, button_size);if close_hovered {let hover_alpha = if self.is_pointer_pressing_ui_rect(- close_x,+ close_hit_x,tab_y,button_size,button_size,@@ -508,17 +597,19 @@ impl crate::TermWindow {).context("collapsed pane nav close hover")?;}- self.ui_items.push(UIItem {- x: close_x,- y: tab_y,- width: button_size,- height: button_size,- item_type: UIItemType::PaneNav {- pane_id: pos.pane.pane_id(),- pane_index: pos.index,- action: PaneNavAction::Close(tab.pane_id),- },- });+ if close_hit_visible {+ self.ui_items.push(UIItem {+ x: close_hit_x,+ y: tab_y,+ width: button_size,+ height: button_size,+ item_type: UIItemType::PaneNav {+ pane_id: pos.pane.pane_id(),+ pane_index: pos.index,+ action: PaneNavAction::Close(tab.pane_id),+ },+ });+ }self.paint_pane_nav_icon(layers,SvgIcon::X,@@ -536,20 +627,17 @@ impl crate::TermWindow {let ui_metrics = RenderMetrics::with_font_metrics(&ui_font.metrics());let text_x = title_icon_x + icon_size + self.ui_px(PANE_NAV_ICON_GAP);let text_right = if close_slot_reserved {- if show_close {- close_x- } else {- raw_close_x- }+ // The tab's own close slot, not the slid-out position. Letting+ // the title chase the slide collapsed `text_right` below+ // `text_x` on a narrow sliver and dropped the title whole.+ self.tab_close_button_x(tab_width, button_size, icon_size)} else {- draw_tab_x + tab_width - self.ui_px(PANE_NAV_INSET)+ tab_width.saturating_sub(self.ui_px(TAB_CONTENT_INSET))};- let text_width = text_right- .min(max_tab_right)- .saturating_sub(text_x + self.ui_px(PANE_NAV_ICON_GAP));+ let text_width = text_right.saturating_sub(text_x + self.ui_px(PANE_NAV_ICON_GAP));let text_y =tab_y + ((tab_height.saturating_sub(ui_metrics.cell_size.height as usize)) / 2);- if text_x >= tab_start && text_x < max_tab_right && text_width > 0 {+ if text_width > 0 {let text_fg = if is_renaming_tab {self.fill_rounded_rectangle(layers,@@ -572,8 +660,39 @@ impl crate::TermWindow {layers, &ui_font, ui_metrics, title, text_x, text_y, text_width, text_fg,)?;}++ drop(content_layers);+ content+ .apply_to_clipped_at(+ out_layers,+ tab_left,+ 0.0,+ QuadClipRect::from_top_left_pixels(+ tab_start as f32,+ tab_y as f32,+ max_tab_right as f32,+ (tab_y + tab_height) as f32,+ &self.dimensions,+ ),+ 1.0,+ )+ .context("collapsed pane nav tab content")?;}+ // Dissolve the strip into the bar wherever it runs on past its+ // viewport, so a clipped tab reads as continuing rather than as one+ // sliced in half.+ self.paint_tab_row_fades(+ layers,+ chrome.sidebar_bg,+ tab_y,+ tab_height,+ tab_start,+ max_tab_right,+ scroll_offset > 0.5,+ scroll_offset < max_scroll - 0.5,+ )?;+Ok(strip_height)}@@ -646,18 +765,11 @@ impl crate::TermWindow {},});- let icon_size = nav_height- .saturating_sub(self.ui_px(PANE_NAV_INSET) * 2)- .clamp(self.ui_px(20), self.ui_px(24));- let action_icon_size = icon_size- .saturating_add(self.ui_px(2))- .clamp(icon_size, self.ui_px(26));- let button_size = nav_height- .saturating_sub(self.ui_px(TAB_VERTICAL_PADDING) * 2)- .max(action_icon_size);- let button_y = pane_y as usize- + (nav_height.saturating_sub(button_size) / 2 + self.ui_px(PANE_NAV_TAB_TOP_OFFSET))- .min(nav_height.saturating_sub(button_size));+ let (icon_size, action_icon_size, button_size) = self.pane_nav_button_metrics(nav_height);+ // Centred, like the collapsed strip and the window tab row above. It+ // used to carry a 4px downward nudge, which left 12px of air over the+ // capsule and 4 under it — the row read as sagging.+ let button_y = pane_y as usize + nav_height.saturating_sub(button_size) / 2;let mut button_x = (pane_x + pane_width) as usize;let mut actions = vec![(SvgIcon::Plus, PaneNavAction::NewTab),@@ -698,15 +810,17 @@ impl crate::TermWindow {let tabs = Mux::get().pane_stack_tabs(pos.pane.pane_id());let tab_start = pane_x as usize + self.pane_nav_tab_left_inset(pos.left);- let tab_width = self.window_tab_width_pixels().ceil() as usize;- let tab_step = tab_width + self.ui_px(PANE_NAV_TAB_GAP);- let total_tab_width = tabs.len().saturating_mul(tab_width).saturating_add(- tabs.len()- .saturating_sub(1)- .saturating_mul(self.ui_px(PANE_NAV_TAB_GAP)),- );- let max_tab_right = button_x.saturating_sub(self.ui_px(PANE_NAV_INSET));- let viewport_width = max_tab_right.saturating_sub(tab_start);+ let tab_gap = self.ui_px(PANE_NAV_TAB_GAP);+ let viewport_width = self.pane_nav_tab_viewport_width(pos) as usize;+ let max_tab_right = tab_start.saturating_add(viewport_width);+ let tab_width = self+ .adaptive_tab_width(tabs.len(), viewport_width as f32, tab_gap as f32)+ .ceil() as usize;+ let tab_step = tab_width + tab_gap;+ let total_tab_width = tabs+ .len()+ .saturating_mul(tab_width)+ .saturating_add(tabs.len().saturating_sub(1).saturating_mul(tab_gap));let max_scroll = total_tab_width.saturating_sub(viewport_width) as f32;let scroll_offset = self.pane_nav_tab_scroll_offsets@@ -761,16 +875,6 @@ impl crate::TermWindow {} else {LinearRgba::TRANSPARENT};- self.fill_rounded_rectangle_with_border(- layers,- 1,- euclid::rect(visible_left, tab_y as f32, visible_width, tab_height as f32),- tab_surface_color,- tab_border_color,- self.ui_f32(PANE_NAV_TAB_RADIUS),- CAPSULE_BORDER_WIDTH,- )- .context("pane nav tab surface")?;self.ui_items.push(UIItem {x: visible_left.max(0.0) as usize,y: tab_y,@@ -783,8 +887,29 @@ impl crate::TermWindow {},});- let draw_tab_x = tab_left.max(0.0) as usize;- let title_icon_x = draw_tab_x + self.ui_px(PANE_NAV_INSET);+ // Reborrow: the surrounding loop cannot move the caller's `&mut`.+ let out_layers = &mut *layers;+ // Content rides in a heap and is replayed clipped to the strip's+ // viewport, recorded in the tab's own space -- left edge at 0 --+ // and shifted onto the strip on replay. See `paint_window_tab`.+ let mut content = HeapQuadAllocator::default();+ let mut content_layers = TripleLayerQuadAllocator::Heap(&mut content);+ let layers = &mut content_layers;++ self.paint_tab_capsule(+ layers,+ 1,+ tab_y,+ tab_width,+ tab_height,+ self.ui_f32(PANE_NAV_TAB_RADIUS),+ tab_surface_color,+ tab_border_color,+ selected_tab,+ )+ .context("pane nav tab surface")?;++ let title_icon_x = self.ui_px(TAB_CONTENT_INSET);let title_icon_y = tab_y + ((tab_height.saturating_sub(icon_size)) / 2);let raw_title = self.pane_nav_tab_title(tab.pane_id, &tab.title);let (title, status) =@@ -796,48 +921,52 @@ impl crate::TermWindow {} else {(raw_title.as_str(), None)};- if title_icon_x >= tab_start && title_icon_x.saturating_add(icon_size) <= max_tab_right- {- if let Some(status) = status {- self.paint_status_icon(- layers,- 2,- status,- title_icon_x,- title_icon_y,- icon_size,- this_tab_fg,- )?;- } else {- self.paint_pane_nav_icon(- layers,- SvgIcon::SquareTerminal,- title_icon_x,- title_icon_y,- icon_size,- this_tab_fg,- )?;- }+ if let Some(status) = status {+ self.paint_status_icon(+ layers,+ 2,+ status,+ title_icon_x,+ title_icon_y,+ icon_size,+ this_tab_fg,+ )?;+ } else {+ self.paint_pane_nav_icon(+ layers,+ SvgIcon::SquareTerminal,+ title_icon_x,+ title_icon_y,+ icon_size,+ this_tab_fg,+ )?;}- let raw_close_x = draw_tab_x- .saturating_add(tab_width)- .saturating_sub(button_size + self.ui_px(TAB_CLOSE_RIGHT_GAP));let close_slot_reserved = !is_renaming_tab;- let close_view_left = draw_tab_x.max(tab_start);- let close_view_right = draw_tab_x.saturating_add(tab_width).min(max_tab_right);- let close_x = raw_close_x- .min(close_view_right.saturating_sub(button_size))- .max(close_view_left);- let show_close = close_slot_reserved- && (selected_tab || is_hovered)- && close_view_right.saturating_sub(close_view_left) >= button_size;+ // The button slides to stay inside the tab's visible sliver, so a+ // half-scrolled tab keeps a usable close target instead of letting+ // it scroll off with the rest. The clamp is in the tab's own space+ // and derived from its *true* origin: it used to be computed from+ // an origin clamped to 0, which is what put the button on a+ // neighbouring tab.+ let view_left = (tab_start as f32 - tab_left).max(0.0);+ let view_right = (max_tab_right as f32 - tab_left).min(tab_width as f32);+ let close_x = (self.tab_close_button_x(tab_width, button_size, icon_size) as f32)+ .min(view_right - button_size as f32)+ .max(view_left)+ .max(0.0) as usize;+ let close_screen_x = tab_left + close_x as f32;+ let close_hit_visible = view_right - view_left >= button_size as f32;+ let close_hit_x = close_screen_x.max(0.0) as usize;+ let show_close = close_slot_reserved && (selected_tab || is_hovered);if show_close {- let close_hovered =- self.is_pointer_over_ui_rect(close_x, tab_y, button_size, button_size);+ // Hover feedback follows the hit target, or a half-clipped+ // button lights up and then passes the click through.+ let close_hovered = close_hit_visible+ && self.is_pointer_over_ui_rect(close_hit_x, tab_y, button_size, button_size);if close_hovered {let hover_alpha = if self.is_pointer_pressing_ui_rect(- close_x,+ close_hit_x,tab_y,button_size,button_size,@@ -862,17 +991,19 @@ impl crate::TermWindow {).context("pane nav close hover")?;}- self.ui_items.push(UIItem {- x: close_x,- y: tab_y,- width: button_size,- height: button_size,- item_type: UIItemType::PaneNav {- pane_id: pos.pane.pane_id(),- pane_index: pos.index,- action: PaneNavAction::Close(tab.pane_id),- },- });+ if close_hit_visible {+ self.ui_items.push(UIItem {+ x: close_hit_x,+ y: tab_y,+ width: button_size,+ height: button_size,+ item_type: UIItemType::PaneNav {+ pane_id: pos.pane.pane_id(),+ pane_index: pos.index,+ action: PaneNavAction::Close(tab.pane_id),+ },+ });+ }self.paint_pane_nav_icon(layers,SvgIcon::X,@@ -890,20 +1021,17 @@ impl crate::TermWindow {let ui_metrics = RenderMetrics::with_font_metrics(&ui_font.metrics());let text_x = title_icon_x + icon_size + self.ui_px(PANE_NAV_ICON_GAP);let text_right = if close_slot_reserved {- if show_close {- close_x- } else {- raw_close_x- }+ // The tab's own close slot, not the slid-out position. Letting+ // the title chase the slide collapsed `text_right` below+ // `text_x` on a narrow sliver and dropped the title whole.+ self.tab_close_button_x(tab_width, button_size, icon_size)} else {- draw_tab_x + tab_width - self.ui_px(PANE_NAV_INSET)+ tab_width.saturating_sub(self.ui_px(TAB_CONTENT_INSET))};- let text_width = text_right- .min(max_tab_right)- .saturating_sub(text_x + self.ui_px(PANE_NAV_ICON_GAP));+ let text_width = text_right.saturating_sub(text_x + self.ui_px(PANE_NAV_ICON_GAP));let text_y =tab_y + ((tab_height.saturating_sub(ui_metrics.cell_size.height as usize)) / 2);- if text_x >= tab_start && text_x < max_tab_right && text_width > 0 {+ if text_width > 0 {let text_fg = if is_renaming_tab {self.fill_rounded_rectangle(layers,@@ -926,8 +1054,39 @@ impl crate::TermWindow {layers, &ui_font, ui_metrics, title, text_x, text_y, text_width, text_fg,)?;}++ drop(content_layers);+ content+ .apply_to_clipped_at(+ out_layers,+ tab_left,+ 0.0,+ QuadClipRect::from_top_left_pixels(+ tab_start as f32,+ tab_y as f32,+ max_tab_right as f32,+ (tab_y + tab_height) as f32,+ &self.dimensions,+ ),+ 1.0,+ )+ .context("pane nav tab content")?;}+ // Dissolve the strip into the bar wherever it runs on past its+ // viewport, so a clipped tab reads as continuing rather than as one+ // sliced in half.+ self.paint_tab_row_fades(+ layers,+ background,+ pane_y.max(0.0) as usize,+ nav_height,+ tab_start,+ max_tab_right,+ scroll_offset > 0.5,+ scroll_offset < max_scroll - 0.5,+ )?;+Ok(nav_height)}diff --git a/wezterm-gui/src/termwindow/render/tab_bar.rs b/wezterm-gui/src/termwindow/render/tab_bar.rsindex 1f618b93..2f1fac0a 100644--- a/wezterm-gui/src/termwindow/render/tab_bar.rs+++ b/wezterm-gui/src/termwindow/render/tab_bar.rs@@ -10,10 +10,8 @@ use wezterm_term::color::ColorAttribute;use window::color::LinearRgba;fn fancy_tab_bar_pixel_height(cell_height: usize, dpi: usize) -> usize {- let cell_height = cell_height.max(1);- // Keep a comfortable capsule while trimming a small amount of the- // vertical whitespace around the tab text.- cell_height * 2 + scale_ui_usize(WINDOW_TAB_TOP_SPACER, dpi)+ crate::termwindow::ui::tokens::tab_row_height_for_cell(cell_height)+ + scale_ui_usize(WINDOW_TAB_TOP_SPACER, dpi)}#[cfg(test)]@@ -31,10 +29,10 @@ mod tests {#[test]fn fancy_height_keeps_compact_comfortable_proportion() {let dpi = if cfg!(target_os = "macos") { 144 } else { 192 };- assert_eq!(fancy_tab_bar_pixel_height(20, dpi), 44);+ assert_eq!(fancy_tab_bar_pixel_height(20, dpi), 49);assert_eq!(fancy_tab_bar_pixel_height(30, dpi) - fancy_tab_bar_pixel_height(20, dpi),- 20+ 22);}}diff --git a/wezterm-gui/src/termwindow/ui/mod.rs b/wezterm-gui/src/termwindow/ui/mod.rsindex 6a9bc03a..0c5500f2 100644--- a/wezterm-gui/src/termwindow/ui/mod.rs+++ b/wezterm-gui/src/termwindow/ui/mod.rs@@ -21,10 +21,197 @@ pub fn pane_nav_bar_height_for_metrics(render_metrics: RenderMetrics) -> usize {// Match the primary tab content height so both tab levels keep the same// vertical rhythm on every monitor DPI.let cell_height = render_metrics.cell_size.height.max(1) as usize;- cell_height * 2+ crate::termwindow::ui::tokens::tab_row_height_for_cell(cell_height)}impl crate::TermWindow {+ /// Record a tab's capsule at the tab's own origin -- left edge at x = 0 --+ /// so the caller can replay it clipped to the row.+ ///+ /// Recording it at full width is what keeps a cut tab looking like a cut+ /// tab. `snapped_rounded_corner_radius` clamps the radius to half the rect+ /// it is handed, so a capsule drawn pre-cut turned a 30px remnant of a+ /// 320px pill into its own little lozenge. At full width the radius is the+ /// one every other tab gets, and the clip supplies the hard edge.+ #[allow(clippy::too_many_arguments)]+ pub(crate) fn paint_tab_capsule(+ &self,+ layers: &mut crate::quad::TripleLayerQuadAllocator,+ layer_num: usize,+ y: usize,+ width: usize,+ height: usize,+ radius: f32,+ fill: ::window::color::LinearRgba,+ border: ::window::color::LinearRgba,+ active: bool,+ ) -> anyhow::Result<()> {+ let rect = euclid::rect(0.0, y as f32, width as f32, height as f32);+ if active {+ self.paint_active_surface_shadow(layers, layer_num, rect, radius)?;+ }+ self.fill_rounded_rectangle_with_border(+ layers,+ layer_num,+ rect,+ fill,+ border,+ radius,+ crate::termwindow::ui::tokens::CAPSULE_BORDER_WIDTH,+ )+ }++ /// A short drop shadow under a selected surface — an active tab, a selected+ /// sidebar row — so it reads as sitting on its bar rather than merely being+ /// a different colour.+ ///+ /// Two tight strips, far shorter than `draw_elevated_surface`'s card+ /// shadow: the tab pill clears the pane nav bar's bottom edge by only ~4px,+ /// and anything softer would spill a dark line onto the terminal below.+ /// Offset downward, so the lift comes from the asymmetry rather than from+ /// depth the dark palette has no room for.+ ///+ /// Draw before the surface, on the surface's own layer. The halo is+ /// inflated past the surface, so a caller whose surface can be cut by a+ /// viewport has to record both into the same clipped buffer -- otherwise+ /// the halo escapes past the boundary the surface stops at.+ pub(crate) fn paint_active_surface_shadow(+ &self,+ layers: &mut crate::quad::TripleLayerQuadAllocator,+ layer_num: usize,+ rect: ::window::RectF,+ radius: f32,+ ) -> anyhow::Result<()> {+ // The bar underneath decides what a given alpha is worth. Black at 0.28+ // moves a dark bar (rgb 25) by 7 levels but a light one (rgb 238) by+ // 66 — nine times as far — so one ramp cannot serve both: tuned for+ // dark it bruises the light bar, tuned for light it vanishes on dark.+ let (outer, inner) = match crate::native_settings::effective_appearance() {+ ::window::Appearance::Light | ::window::Appearance::LightHighContrast => (0.04, 0.05),+ ::window::Appearance::Dark | ::window::Appearance::DarkHighContrast => (0.12, 0.18),+ };+ for (spread, offset_y, alpha) in [+ (self.ui_f32(2.0), self.ui_f32(1.0), outer),+ (self.ui_f32(1.0), self.ui_f32(1.0), inner),+ ] {+ self.fill_rounded_rectangle(+ layers,+ layer_num,+ euclid::rect(+ rect.min_x() - spread,+ rect.min_y() - spread + offset_y,+ rect.width() + spread * 2.0,+ rect.height() + spread * 2.0,+ ),+ ::window::color::LinearRgba::with_components(0.0, 0.0, 0.0, alpha),+ radius + spread,+ )?;+ }+ Ok(())+ }++ /// Dissolve a tab row into the bar at an edge the viewport cut.+ ///+ /// A tab sliced mid-body reads as a paint bug however honestly its corner+ /// is squared off; ramping the bar's own colour over the last few pixels+ /// turns the same cut into the row visibly continuing past the boundary.+ /// Modelled on `ssh_hosts_view::paint_list_fades`, which does this for a+ /// scrolling list's top and bottom.+ ///+ /// Painted on layer 2, above the tab surfaces and their icons, so it has to+ /// go down after the tabs and before whatever owns the space beyond the+ /// boundary.+ #[allow(clippy::too_many_arguments)]+ pub(crate) fn paint_tab_row_fades(+ &self,+ layers: &mut crate::quad::TripleLayerQuadAllocator,+ background: ::window::color::LinearRgba,+ row_y: usize,+ row_height: usize,+ viewport_left: usize,+ viewport_right: usize,+ fade_at_left: bool,+ fade_at_right: bool,+ ) -> anyhow::Result<()> {+ use crate::ui::anim::Easing;+ use anyhow::Context;++ if row_height == 0 || viewport_right <= viewport_left {+ return Ok(());+ }+ let width = self+ .ui_px(crate::termwindow::ui::tokens::TAB_ROW_FADE_WIDTH)+ .min(viewport_right - viewport_left);+ if width == 0 {+ return Ok(());+ }++ if fade_at_left {+ for step in 0..width {+ let progress = step as f32 / width as f32;+ let alpha = 1.0 - Easing::Smooth.apply(progress);+ self.filled_rectangle(+ layers,+ 2,+ euclid::rect(+ (viewport_left + step) as f32,+ row_y as f32,+ 1.0,+ row_height as f32,+ ),+ background.mul_alpha(alpha),+ )+ .context("tab row leading fade")?;+ }+ }++ if fade_at_right {+ let start = viewport_right - width;+ for step in 0..width {+ let progress = (step + 1) as f32 / width as f32;+ let alpha = Easing::Smooth.apply(progress);+ self.filled_rectangle(+ layers,+ 2,+ euclid::rect(+ (start + step) as f32,+ row_y as f32,+ 1.0,+ row_height as f32,+ ),+ background.mul_alpha(alpha),+ )+ .context("tab row trailing fade")?;+ }+ }++ Ok(())+ }++ /// Left edge of a tab's close-button box, placed so the glyph inside it+ /// lands `TAB_CONTENT_INSET` from the tab's right edge — the same inset the+ /// leading icon keeps on the left. Derived rather than a fixed gap so the+ /// two stay symmetric whatever the icon and button sizes work out to.+ pub(crate) fn tab_close_button_x(+ &self,+ tab_right: usize,+ button_size: usize,+ icon_size: usize,+ ) -> usize {+ let glyph_pad = button_size.saturating_sub(icon_size) / 2;+ // Optical, not geometric. Lucide's `x` inks only the middle half of its+ // 24-unit box (6..18) where `square-terminal` inks three quarters+ // (3..21), so boxing the two at the same inset leaves the X looking+ // further from the tab's right edge than the icon looks from its left.+ // Nudge the button out by that difference — an eighth of the icon — and+ // the two glyphs' ink lands the same distance from their own edges.+ let optical = icon_size / 8;+ let inset = self+ .ui_px(crate::termwindow::ui::tokens::TAB_CONTENT_INSET)+ .saturating_sub(optical);+ tab_right.saturating_sub(inset + icon_size + glyph_pad)+ }+pub(crate) fn pane_nav_bar_height(&self) -> usize {let metrics = self.fontsdiff --git a/wezterm-gui/src/termwindow/ui/sidebar.rs b/wezterm-gui/src/termwindow/ui/sidebar.rsindex 3870502b..c8c64723 100644--- a/wezterm-gui/src/termwindow/ui/sidebar.rs+++ b/wezterm-gui/src/termwindow/ui/sidebar.rs@@ -8,7 +8,8 @@ use crate::termwindow::ui::platform_chrome;use crate::termwindow::ui::status_icon::UiStatusKind;use crate::termwindow::ui::tokens::{CAPSULE_BORDER_WIDTH, SIDEBAR_ICON_GAP, SIDEBAR_INSET, SIDEBAR_MAX_WIDTH, SIDEBAR_MIN_WIDTH,- SIDEBAR_RESIZE_HANDLE_WIDTH, SIDEBAR_ROW_GAP, SIDEBAR_ROW_RADIUS, SIDEBAR_WIDTH_CELLS,+ SIDEBAR_RESIZE_HANDLE_WIDTH, SIDEBAR_ROW_GAP, SIDEBAR_ROW_HIGHLIGHT_RADIUS,+ SIDEBAR_ROW_RADIUS, SIDEBAR_WIDTH_CELLS,WINDOW_TAB_FULLSCREEN_NEW_SESSION_EXTRA_HEIGHT, WINDOW_TAB_FULLSCREEN_NEW_SESSION_Y_OFFSET,WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_X, WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_Y_OFFSET,WINDOW_TAB_TOP_SPACER,@@ -1710,18 +1711,26 @@ impl crate::TermWindow {let is_selected =self.is_workspace_sidebar_thread_selected(session, suppress_own_active);if is_selected {+ let row_rect = euclid::rect(+ pinned_x as f32,+ y as f32,+ pinned_width as f32,+ session_row_height as f32,+ );+ self.paint_active_surface_shadow(+ layers,+ 0,+ row_rect,+ self.ui_f32(SIDEBAR_ROW_HIGHLIGHT_RADIUS),+ )+ .context("sidebar selected pinned thread shadow")?;self.fill_rounded_rectangle_with_border(layers,0,- euclid::rect(- pinned_x as f32,- y as f32,- pinned_width as f32,- session_row_height as f32,- ),+ row_rect,selected_bg,selected_border,- self.ui_f32(SIDEBAR_ROW_RADIUS) + 2.0,+ self.ui_f32(SIDEBAR_ROW_HIGHLIGHT_RADIUS),CAPSULE_BORDER_WIDTH,).context("sidebar selected pinned thread")?;@@ -1736,7 +1745,7 @@ impl crate::TermWindow {session_row_height as f32,),chrome.sidebar_row_hover_bg,- self.ui_f32(SIDEBAR_ROW_RADIUS) + 2.0,+ self.ui_f32(SIDEBAR_ROW_HIGHLIGHT_RADIUS),).context("sidebar hovered pinned thread")?;}@@ -2131,18 +2140,26 @@ impl crate::TermWindow {let is_selected =self.is_workspace_sidebar_thread_selected(session, suppress_own_active);if row_is_visible && is_selected {+ let row_rect = euclid::rect(+ session_x as f32,+ y as f32,+ session_width as f32,+ session_row_height as f32,+ );+ self.paint_active_surface_shadow(+ layers,+ 0,+ row_rect,+ self.ui_f32(SIDEBAR_ROW_HIGHLIGHT_RADIUS),+ )+ .context("sidebar selected thread shadow")?;self.fill_rounded_rectangle_with_border(layers,0,- euclid::rect(- session_x as f32,- y as f32,- session_width as f32,- session_row_height as f32,- ),+ row_rect,selected_bg,selected_border,- self.ui_f32(SIDEBAR_ROW_RADIUS) + 2.0,+ self.ui_f32(SIDEBAR_ROW_HIGHLIGHT_RADIUS),CAPSULE_BORDER_WIDTH,).context("sidebar selected thread")?;@@ -2195,7 +2212,7 @@ impl crate::TermWindow {session_row_height as f32,),chrome.sidebar_row_hover_bg,- self.ui_f32(SIDEBAR_ROW_RADIUS) + 2.0,+ self.ui_f32(SIDEBAR_ROW_HIGHLIGHT_RADIUS),).context("sidebar hovered thread")?;}@@ -2502,18 +2519,26 @@ impl crate::TermWindow {let is_selected = self.is_workspace_sidebar_thread_selected(session, false);let dimmed = reference.dangling || !reference.origin_domain_attached;if is_selected {+ let row_rect = euclid::rect(+ session_x as f32,+ y as f32,+ session_width as f32,+ session_row_height as f32,+ );+ self.paint_active_surface_shadow(+ layers,+ 0,+ row_rect,+ self.ui_f32(SIDEBAR_ROW_HIGHLIGHT_RADIUS),+ )+ .context("sidebar selected thread ref shadow")?;self.fill_rounded_rectangle_with_border(layers,0,- euclid::rect(- session_x as f32,- y as f32,- session_width as f32,- session_row_height as f32,- ),+ row_rect,selected_bg,selected_border,- self.ui_f32(SIDEBAR_ROW_RADIUS) + 2.0,+ self.ui_f32(SIDEBAR_ROW_HIGHLIGHT_RADIUS),CAPSULE_BORDER_WIDTH,).context("sidebar selected thread ref")?;@@ -2528,7 +2553,7 @@ impl crate::TermWindow {session_row_height as f32,),chrome.sidebar_row_hover_bg,- self.ui_f32(SIDEBAR_ROW_RADIUS) + 2.0,+ self.ui_f32(SIDEBAR_ROW_HIGHLIGHT_RADIUS),).context("sidebar hovered thread ref")?;}@@ -3278,6 +3303,32 @@ impl crate::TermWindow {radius: f32,round_top: bool,round_bottom: bool,+ ) -> anyhow::Result<()> {+ self.fill_rounded_rectangle_corners(+ layers,+ layer_num,+ rect,+ color,+ radius,+ RoundedCorners::vertical(round_top, round_bottom),+ )+ }++ /// Fill a rectangle rounding only the corners `corners` names.+ ///+ /// A surface clipped by a viewport passes the flags for the edges that are+ /// really its own: the cut edge then comes out square, so a half-scrolled+ /// tab reads as running under the boundary instead of as a genuinely+ /// narrower tab.+ #[allow(clippy::too_many_arguments)]+ pub(crate) fn fill_rounded_rectangle_corners(+ &self,+ layers: &mut TripleLayerQuadAllocator,+ layer_num: usize,+ rect: RectF,+ color: LinearRgba,+ radius: f32,+ corners: RoundedCorners,) -> anyhow::Result<()> {let radius = snapped_rounded_corner_radius(rect, radius);// Sub-pixel radii round down to a 0px corner sprite (which panics when@@ -3288,75 +3339,51 @@ impl crate::TermWindow {}let corner_size = euclid::size2(radius, radius);- if round_top {- self.poly_quad(- layers,- layer_num,- euclid::point2(rect.min_x(), rect.min_y()),+ for (rounded, sprite, x, y) in [+ (+ corners.top_left,TOP_LEFT_ROUNDED_CORNER,- 0,- corner_size,- color,- )?- .set_grayscale();- self.poly_quad(- layers,- layer_num,- euclid::point2(rect.max_x() - radius, rect.min_y()),+ rect.min_x(),+ rect.min_y(),+ ),+ (+ corners.top_right,TOP_RIGHT_ROUNDED_CORNER,- 0,- corner_size,- color,- )?- .set_grayscale();- } else {- self.filled_rectangle(- layers,- layer_num,- euclid::rect(rect.min_x(), rect.min_y(), radius, radius),- color,- )?;- self.filled_rectangle(- layers,- layer_num,- euclid::rect(rect.max_x() - radius, rect.min_y(), radius, radius),- color,- )?;- }- if round_bottom {- self.poly_quad(- layers,- layer_num,- euclid::point2(rect.min_x(), rect.max_y() - radius),+ rect.max_x() - radius,+ rect.min_y(),+ ),+ (+ corners.bottom_left,BOTTOM_LEFT_ROUNDED_CORNER,- 0,- corner_size,- color,- )?- .set_grayscale();- self.poly_quad(- layers,- layer_num,- euclid::point2(rect.max_x() - radius, rect.max_y() - radius),+ rect.min_x(),+ rect.max_y() - radius,+ ),+ (+ corners.bottom_right,BOTTOM_RIGHT_ROUNDED_CORNER,- 0,- corner_size,- color,- )?- .set_grayscale();- } else {- self.filled_rectangle(- layers,- layer_num,- euclid::rect(rect.min_x(), rect.max_y() - radius, radius, radius),- color,- )?;- self.filled_rectangle(- layers,- layer_num,- euclid::rect(rect.max_x() - radius, rect.max_y() - radius, radius, radius),- color,- )?;+ rect.max_x() - radius,+ rect.max_y() - radius,+ ),+ ] {+ if rounded {+ self.poly_quad(+ layers,+ layer_num,+ euclid::point2(x, y),+ sprite,+ 0,+ corner_size,+ color,+ )?+ .set_grayscale();+ } else {+ self.filled_rectangle(+ layers,+ layer_num,+ euclid::rect(x, y, radius, radius),+ color,+ )?;+ }}self.filled_rectangle(@@ -3646,6 +3673,33 @@ fn ellipsize_cut_byte(glyphs: &[(f32, usize)], text_len: usize, budget: f32) ->/// Corner sprites are cached at integral physical-pixel sizes. Keep the quad/// geometry on that same grid so fractional radii cannot expose the joins/// between the four corners and the center rectangles on 1x displays.+/// Which corners of a rounded rectangle actually get rounded.+///+/// A scrollable surface keeps the corners of its real edges and leaves a+/// viewport-created cut edge square. (A surface cut *horizontally* does not+/// need this: it is recorded at full width and clipped on replay, which both+/// gives the cut a hard edge and keeps the radius the one the full shape would+/// have had — see `paint_tab_capsule`.)+#[derive(Clone, Copy, PartialEq, Eq, Debug)]+pub(crate) struct RoundedCorners {+ pub top_left: bool,+ pub top_right: bool,+ pub bottom_left: bool,+ pub bottom_right: bool,+}++impl RoundedCorners {+ pub(crate) fn vertical(round_top: bool, round_bottom: bool) -> Self {+ Self {+ top_left: round_top,+ top_right: round_top,+ bottom_left: round_bottom,+ bottom_right: round_bottom,+ }+ }++}+fn snapped_rounded_corner_radius(rect: RectF, radius: f32) -> f32 {radius.min(rect.width() / 2.0)diff --git a/wezterm-gui/src/termwindow/ui/tokens.rs b/wezterm-gui/src/termwindow/ui/tokens.rsindex 2934b717..72302461 100644--- a/wezterm-gui/src/termwindow/ui/tokens.rs+++ b/wezterm-gui/src/termwindow/ui/tokens.rs@@ -5,6 +5,11 @@ pub const SIDEBAR_INSET: usize = 10;pub const SIDEBAR_ICON_GAP: usize = 10;pub const SIDEBAR_ROW_GAP: usize = 10;pub const SIDEBAR_ROW_RADIUS: f32 = 10.0;+/// Corner of the highlight behind a selected or hovered sidebar row. Scaled as+/// a whole, unlike the `ui_f32(SIDEBAR_ROW_RADIUS) + 2.0` it replaces, where+/// the added 2 stayed in raw pixels and so grew relative to the design on any+/// display below the 2x grid the chrome is drawn for.+pub const SIDEBAR_ROW_HIGHLIGHT_RADIUS: f32 = 20.0;pub const SIDEBAR_RESIZE_HANDLE_WIDTH: usize = 8;/// Left-edge strip that arms a hover reveal of the collapsed sidebar.///@@ -33,6 +38,19 @@ pub const MACOS_TITLEBAR_CONTENT_TOP_INSET: usize = 52;pub const MACOS_TRAFFIC_LIGHT_CLEARANCE_WIDTH: usize = 164;pub const MACOS_WINDOW_TAB_RESERVED_ACTION_SLOTS: usize = 1;+/// A tab row's height, from its title font's line height.+///+/// Both tab levels go through this, so the window tab bar and the pane nav bar+/// keep one vertical rhythm at every font size and monitor DPI. The ratio, not+/// a pixel constant: the row exists to hold a line of text, so it has to track+/// that text rather than a fixed number.+pub fn tab_row_height_for_cell(cell_height: usize) -> usize {+ // 2.25x. At the 2x this replaces, the capsule inside came out only+ // `TAB_VERTICAL_PADDING` clear of the row on each side, which read tight+ // once the capsule went fully rounded.+ cell_height.max(1) * 9 / 4+}+pub const TAB_ROW_START_PADDING: usize = 16;pub const WINDOW_TAB_TOP_SPACER: usize = 4;pub const WINDOW_TAB_ACTION_RESERVED_WIDTH: usize = 60;@@ -44,21 +62,56 @@ pub const WINDOW_TAB_FULLSCREEN_NEW_SESSION_Y_OFFSET: usize = 6;pub const WINDOW_TAB_FULLSCREEN_NEW_SESSION_EXTRA_HEIGHT: usize = 6;pub const WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE: usize = 34;pub const WINDOW_TAB_LEADING_ACTION_GAP: usize = 8;-pub const WINDOW_TAB_LEADING_ACTION_ICON_SIZE: usize = 26;+/// Matches `TAB_ICON_SIZE`: the leading action sits in the same row as the+/// tabs and the trailing actions, which both already draw at that size.+pub const WINDOW_TAB_LEADING_ACTION_ICON_SIZE: usize = 32;pub const WINDOW_TAB_GAP: usize = 18;-pub const WINDOW_TAB_RADIUS: f32 = 12.0;+/// How far a tab row dissolves into the bar at an edge the viewport cut.+/// Matches `ssh_hosts_view`'s list fades, which solve the same problem+/// vertically.+pub const TAB_ROW_FADE_WIDTH: usize = 32;+/// Pill: `snapped_rounded_corner_radius` clamps this to half the surface's+/// short side, so the tab keeps semicircular ends at every row height.+pub const WINDOW_TAB_RADIUS: f32 = 999.0;+/// A tab surface is chrome, so it sizes itself to the row it lives in rather+/// than to the terminal grid. A roomy row parks every tab at the target width;+/// crowding shrinks them all evenly down to the floor, and only past the floor+/// does the row scroll.+pub const TAB_TARGET_WIDTH: f32 = 320.0;+/// How far tabs give up width before the row scrolls instead.+///+/// Equal to the target, so they give up nothing: a tab is always+/// `TAB_TARGET_WIDTH` wide and the row starts scrolling the moment the tabs+/// stop fitting. Every value in between trades a scrollbar for a few narrower+/// tabs — 240 buys roughly two extra tabs before the row scrolls — but a tab+/// that cannot show its title has stopped doing its job, and scrolling to a+/// legible tab beats reading a row of stubs.+pub const TAB_MIN_WIDTH: f32 = TAB_TARGET_WIDTH;pub const WINDOW_TAB_ADD_BUTTON_RADIUS: f32 = 999.0;-pub const TAB_CLOSE_HOVER_INSET: usize = 5;+/// Inset from a tab pill's edge to its content — icon on the left, title's+/// right limit, and (via the close button's own box) the close glyph. Sized+/// against the pill's corner radius, which is half its height: content much+/// nearer than this reads as jammed into the rounded cap. It also lands the+/// leading icon and the trailing close glyph the same distance from their+/// respective ends.+pub const TAB_CONTENT_INSET: usize = 18;+/// Icon inside a tab pill, in the window tab row and the pane nav row alike.+/// Fixed chrome geometry, so the two rows cannot drift apart.+pub const TAB_ICON_SIZE: usize = 32;+/// Leaves a hover ring that clears the pill's top and bottom by the same+/// `TAB_VERTICAL_PADDING` the pill itself sits in.+pub const TAB_CLOSE_HOVER_INSET: usize = 8;pub const TAB_CLOSE_HOVER_RADIUS: f32 = 999.0;-pub const TAB_CLOSE_RIGHT_GAP: usize = 6;pub const TAB_VERTICAL_PADDING: usize = 8;pub const PANE_NAV_INSET: usize = 10;pub const PANE_NAV_ICON_GAP: usize = 8;pub const PANE_NAV_BUTTON_GAP: usize = 4;pub const PANE_NAV_TAB_GAP: usize = 18;-pub const PANE_NAV_TAB_TOP_OFFSET: usize = 4;-pub const PANE_NAV_TAB_RADIUS: f32 = 12.0;+pub const PANE_NAV_TAB_RADIUS: f32 = 999.0;+/// Icon in the nav bar's trailing action buttons. Kept apart from+/// `TAB_ICON_SIZE`: these are buttons, not tabs, and want their own weight.+pub const PANE_NAV_ACTION_ICON_SIZE: usize = 26;pub const PANE_NAV_ACTION_BUTTON_RADIUS: f32 = 999.0;pub const PANE_DROP_PREVIEW_RADIUS: f32 = 10.0;