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
Refine sidebar scaling and window chrome details
RoversXb201db5c5215
diff --git a/wezterm-gui/src/native_settings.rs b/wezterm-gui/src/native_settings.rsindex c5a50703..c9968340 100644--- a/wezterm-gui/src/native_settings.rs+++ b/wezterm-gui/src/native_settings.rs@@ -198,6 +198,9 @@ pub(crate) struct NativeChromeSettings {pub(crate) settings_font_weight: Option<u16>,pub(crate) home_font_size: Option<f64>,pub(crate) sidebar_font_size: Option<f64>,+ /// Right sidebar (files / notes / snippets) text size; None follows+ /// home_font_size.+ pub(crate) right_sidebar_font_size: Option<f64>,pub(crate) workspace_sidebar_width: Option<usize>,pub(crate) right_sidebar_width: Option<usize>,pub(crate) right_sidebar_file_preview_width: Option<usize>,@@ -452,6 +455,16 @@ pub(crate) fn sidebar_font_size() -> f64 {.clamp(10.0, 28.0)}+/// Right sidebar (files / notes / snippets) text size; follows the+/// resolved Home Font Size until explicitly set.+pub(crate) fn right_sidebar_font_size(settings: &ThinkTermNativeSettings) -> f64 {+ settings+ .chrome+ .right_sidebar_font_size+ .unwrap_or_else(|| home_font_size(settings))+ .clamp(10.0, 28.0)+}+pub(crate) fn workspace_sidebar_width() -> Option<usize> {load().chrome.workspace_sidebar_width}diff --git a/wezterm-gui/src/settings_window.rs b/wezterm-gui/src/settings_window.rsindex cbe0d765..b2e2b801 100644--- a/wezterm-gui/src/settings_window.rs+++ b/wezterm-gui/src/settings_window.rs@@ -690,16 +690,30 @@ impl MemorySnapshot {enum ChromeFontArea {Settings,Home,+ RightSidebar,Sidebar,TabBar,PaneHeader,}+/// Order of the font-size stepper rows in the Typography card. The card's+/// row count derives from this list (plus the trailing font-weight row),+/// so adding an area here automatically grows the card background.+const TYPOGRAPHY_FONT_AREAS: [ChromeFontArea; 6] = [+ ChromeFontArea::Settings,+ ChromeFontArea::Home,+ ChromeFontArea::RightSidebar,+ ChromeFontArea::Sidebar,+ ChromeFontArea::TabBar,+ ChromeFontArea::PaneHeader,+];+impl ChromeFontArea {fn label(self) -> &'static str {match self {Self::Settings => "Settings UI Font Size",Self::Home => "Home Font Size",+ Self::RightSidebar => "Right Sidebar Font Size",Self::Sidebar => "Workspace Sidebar Font Size",Self::TabBar => "Tab Bar Font Size",Self::PaneHeader => "Pane Header Font Size",@@ -710,6 +724,9 @@ impl ChromeFontArea {match self {Self::Settings => "Controls the Settings window chrome and content text.",Self::Home => "Controls the main home/content view text.",+ Self::RightSidebar => {+ "Follows Home Font Size until set — files, notes and snippets panel."+ }Self::Sidebar => "Saved separately for the main workspace sidebar.",Self::TabBar => "Saved separately for the top terminal tab bar.",Self::PaneHeader => "Saved separately for split-pane header labels.",@@ -720,6 +737,7 @@ impl ChromeFontArea {match self {Self::Settings => DEFAULT_SETTINGS_FONT_SIZE,Self::Home => DEFAULT_HOME_FONT_SIZE,+ Self::RightSidebar => DEFAULT_HOME_FONT_SIZE,Self::Sidebar => DEFAULT_SIDEBAR_FONT_SIZE,Self::TabBar => DEFAULT_TAB_FONT_SIZE,Self::PaneHeader => DEFAULT_PANE_HEADER_FONT_SIZE,@@ -2128,17 +2146,29 @@ impl SettingsWindow {let value = match area {ChromeFontArea::Settings => self.native_settings.chrome.settings_font_size,ChromeFontArea::Home => self.native_settings.chrome.home_font_size,+ ChromeFontArea::RightSidebar => self.native_settings.chrome.right_sidebar_font_size,ChromeFontArea::Sidebar => self.native_settings.chrome.sidebar_font_size,ChromeFontArea::TabBar => self.native_settings.chrome.tab_font_size,ChromeFontArea::PaneHeader => self.native_settings.chrome.pane_header_font_size,};- value.unwrap_or_else(|| area.default_size())+ value.unwrap_or_else(|| match area {+ // An unset Right Sidebar size follows the resolved Home size;+ // show and step from what is actually rendered, not the+ // platform default.+ ChromeFontArea::RightSidebar => {+ crate::native_settings::home_font_size(&self.native_settings)+ }+ _ => area.default_size(),+ })}fn set_chrome_font_size_value(&mut self, area: ChromeFontArea, value: Option<f64>) {match area {ChromeFontArea::Settings => self.native_settings.chrome.settings_font_size = value,ChromeFontArea::Home => self.native_settings.chrome.home_font_size = value,+ ChromeFontArea::RightSidebar => {+ self.native_settings.chrome.right_sidebar_font_size = value+ }ChromeFontArea::Sidebar => self.native_settings.chrome.sidebar_font_size = value,ChromeFontArea::TabBar => self.native_settings.chrome.tab_font_size = value,ChromeFontArea::PaneHeader => self.native_settings.chrome.pane_header_font_size = value,@@ -3616,7 +3646,8 @@ impl SettingsWindow {let row_step = self.settings_row_step();let section_y = self.ui_px(CONTENT_SECTION_Y) - scroll;let theme_row_count = 4;- let typography_row_count = 6;+ // The font-size steppers plus the trailing font-weight stepper.+ let typography_row_count = TYPOGRAPHY_FONT_AREAS.len() + 1;let app_icon_note_space = self.metrics.cell_size.height as f32 + self.ui_px(10.0);let (theme_card_y, mut y) = self.settings_card_geometry(section_y, theme_row_count);let theme_card_height = self.settings_card_height(theme_row_count) + app_icon_note_space;@@ -3707,13 +3738,7 @@ impl SettingsWindow {typography_card_height,)?;y = typography_first_row_y;- for area in [- ChromeFontArea::Settings,- ChromeFontArea::Home,- ChromeFontArea::Sidebar,- ChromeFontArea::TabBar,- ChromeFontArea::PaneHeader,- ] {+ for area in TYPOGRAPHY_FONT_AREAS {self.paint_font_size_stepper_row(layers,row_x,diff --git a/wezterm-gui/src/termwindow/mouseevent.rs b/wezterm-gui/src/termwindow/mouseevent.rsindex 8c5238e2..66aaf288 100644--- a/wezterm-gui/src/termwindow/mouseevent.rs+++ b/wezterm-gui/src/termwindow/mouseevent.rs@@ -206,7 +206,7 @@ impl super::TermWindow {.ceil()}- fn window_tab_chrome_params(&self) -> WindowTabChromeParams {+ pub(crate) fn window_tab_chrome_params(&self) -> WindowTabChromeParams {WindowTabChromeParams {use_fancy_tab_bar: self.config.use_fancy_tab_bar,workspace_sidebar_width: self.workspace_sidebar_width(),@@ -216,6 +216,17 @@ impl super::TermWindow {integrated_title_button_style: self.config.integrated_title_button_style,cell_width: self.render_metrics.cell_size.width.max(1) as f32,dpi: self.dimensions.dpi,+ top_fancy_row_height: if self.show_tab_bar+ && self.config.use_fancy_tab_bar+ && !self.config.tab_bar_at_bottom+ {+ self.tab_bar_pixel_height()+ .ok()+ .map(|h| h.ceil() as usize)+ .filter(|h| *h > 0)+ } else {+ None+ },}}diff --git a/wezterm-gui/src/termwindow/render/draw.rs b/wezterm-gui/src/termwindow/render/draw.rsindex 3e0929f4..fa50c5ca 100644--- a/wezterm-gui/src/termwindow/render/draw.rs+++ b/wezterm-gui/src/termwindow/render/draw.rs@@ -12,7 +12,7 @@ use ::window::color::LinearRgba;use ::window::{Appearance, Dimensions, WindowDecorations, WindowState};use config::FreeTypeLoadTarget;-const LINUX_WINDOW_CORNER_RADIUS: f32 = 12.0;+const LINUX_WINDOW_CORNER_RADIUS: f32 = 16.0;const LINUX_WINDOW_BORDER_WIDTH: f32 = 1.0;#[derive(Clone, Copy, Debug, PartialEq)]@@ -436,7 +436,7 @@ mod tests {let radius =effective_window_corner_radius(decorations, WindowState::COMPOSITED, 96);if cfg!(target_os = "linux") {- assert_eq!(radius, 12.0);+ assert_eq!(radius, LINUX_WINDOW_CORNER_RADIUS);} else {assert_eq!(radius, 0.0);}diff --git a/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs b/wezterm-gui/src/termwindow/render/fancy_tab_bar.rsindex 1fd3bf1f..e879db0e 100644--- a/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs+++ b/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs@@ -385,6 +385,9 @@ impl crate::TermWindow {return Ok(());}+ // The rounded-corner clearance is folded into+ // leading_action_start_pixels so layout reservation, painting and+ // hit-testing share the same origin.let mut button_x = row_x + self.window_tab_leading_action_start_pixels().ceil() as usize;for action_idx in 0..action_slot_count {let is_sidebar_toggle =@@ -401,10 +404,16 @@ impl crate::TermWindow {} else {self.ui_px(WINDOW_TAB_LEADING_ACTION_ICON_SIZE)};+ // action_button_size already comes from the shared+ // sidebar_toggle_size_px geometry (capsule height on non-mac+ // top fancy bars, fixed size otherwise); row_height here is+ // the content row (top spacer removed by the caller).let button_size = if is_fullscreen_sidebar_toggle {action_button_size} else {- action_button_size.min(row_height.saturating_sub(4)).max(1)+ action_button_size+ .min(row_height.saturating_sub(self.ui_px(4)))+ .max(1)};let icon_size = action_icon_size.min(button_size.saturating_sub(2));@@ -415,10 +424,8 @@ impl crate::TermWindow {row_y.saturating_sub(self.ui_px(WINDOW_TAB_TOP_SPACER))+ self.ui_px(SIDEBAR_INSET)+ self.ui_px(WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_Y_OFFSET)- } else if !cfg!(target_os = "macos") {- row_y.saturating_sub(self.ui_px(WINDOW_TAB_TOP_SPACER))- + self.ui_px(SIDEBAR_INSET)} else {+ // Center like the window tab capsules (all platforms).row_y + (row_height.saturating_sub(button_size) / 2)};self.paint_window_sidebar_toggle_button(@@ -554,7 +561,6 @@ impl crate::TermWindow {let close_button = button == IntegratedTitleButton::Close;if hovered {- let chrome = UiPalette::for_appearance(crate::native_settings::effective_appearance());let fill = if close_button {let mut red = LinearRgba::with_srgba(232, 17, 35, 255);if pressed {@@ -562,9 +568,12 @@ impl crate::TermWindow {}red} else if pressed {- chrome.control_pressed_bg+ // Foreground-tinted overlay reads correctly on both themes;+ // the palette's control_hover_bg is near-white and washes+ // out on the light tab bar.+ foreground.mul_alpha(0.16)} else {- chrome.control_hover_bg+ foreground.mul_alpha(0.10)};let border = if close_button {LinearRgba::TRANSPARENTdiff --git a/wezterm-gui/src/termwindow/render/split.rs b/wezterm-gui/src/termwindow/render/split.rsindex 74553016..5626d027 100644--- a/wezterm-gui/src/termwindow/render/split.rs+++ b/wezterm-gui/src/termwindow/render/split.rs@@ -52,13 +52,28 @@ impl crate::TermWindow {item_type: UIItemType::Split(split.clone()),});} else {+ // Match the pane chrome span: nav bars extend to the sidebar+ // and window edges (pane_chrome_span), and this divider is+ // drawn over the lower pane's top strip row, so it must cover+ // the same extended width or the strip peeks out beside it.+ let mut line_left = pos_x - (cell_width / 2.0);+ let mut line_right = line_left + (1.0 + split.size as f32) * cell_width;+ if split.left == 0 {+ line_left = self.tab_bar_left_edge() as f32;+ }+ if split.left + split.size >= self.terminal_size.cols {+ line_right = (self.dimensions.pixel_width as f32+ - border.right.get() as f32+ - self.right_sidebar_width() as f32)+ .max(line_right);+ }self.filled_rectangle(layers,2,euclid::rect(- pos_x - (cell_width / 2.0),+ line_left,pos_y + (cell_height / 2.0),- (1.0 + split.size as f32) * cell_width,+ (line_right - line_left).max(1.0),self.render_metrics.underline_height as f32,),foreground,diff --git a/wezterm-gui/src/termwindow/ui/context_menu.rs b/wezterm-gui/src/termwindow/ui/context_menu.rsindex 1faf9c5e..59abee0e 100644--- a/wezterm-gui/src/termwindow/ui/context_menu.rs+++ b/wezterm-gui/src/termwindow/ui/context_menu.rs@@ -17,22 +17,22 @@ use wezterm_font::LoadedFont;// Design pixels (2x macOS backing), scaled via ui_px/ui_f32 like the rest// of the chrome. The fallback menu only shows on non-mac (and behind a// debug flag on mac).-const MENU_MIN_WIDTH: usize = 440;+const MENU_MIN_WIDTH: usize = 400;const MENU_MAX_WIDTH: usize = 1000;const MENU_WINDOW_MARGIN: usize = 24;-const MENU_PADDING_X: usize = 28;-const MENU_PADDING_Y: usize = 20;-const MENU_LABEL_GAP: usize = 24;-const MENU_ICON_SIZE: usize = 42;-const MENU_ICON_SLOT: usize = 64;-const MENU_CHECK_SLOT: usize = 56;-const MENU_ARROW_SLOT: usize = 56;-const MENU_ROW_EXTRA_HEIGHT: usize = 44;-const MENU_SEPARATOR_HEIGHT: usize = 18;+const MENU_PADDING_X: usize = 22;+const MENU_PADDING_Y: usize = 12;+const MENU_LABEL_GAP: usize = 16;+const MENU_ICON_SIZE: usize = 32;+const MENU_ICON_SLOT: usize = 48;+const MENU_CHECK_SLOT: usize = 40;+const MENU_ARROW_SLOT: usize = 44;+const MENU_ROW_EXTRA_HEIGHT: usize = 24;+const MENU_SEPARATOR_HEIGHT: usize = 14;const MENU_BORDER_WIDTH: f32 = 2.0;-const MENU_RADIUS: f32 = 44.0;-const MENU_ROW_RADIUS: f32 = 30.0;-const MENU_ROW_HOVER_INSET_X: usize = 16;+const MENU_RADIUS: f32 = 28.0;+const MENU_ROW_RADIUS: f32 = 18.0;+const MENU_ROW_HOVER_INSET_X: usize = 10;const MENU_ROW_HOVER_INSET_Y: usize = 4;pub(crate) fn reveal_in_folder_label() -> &'static str {@@ -364,7 +364,7 @@ impl crate::TermWindow {let ui_metrics = RenderMetrics::with_font_metrics(&ui_font.metrics());let row_height = (ui_metrics.cell_size.height as usize+ self.ui_px(MENU_ROW_EXTRA_HEIGHT))- .max(self.ui_px(56));+ .max(self.ui_px(44));let palette = context_menu_palette(crate::native_settings::effective_appearance());let gl_state = self.render_state.as_ref().unwrap();diff --git a/wezterm-gui/src/termwindow/ui/platform_chrome.rs b/wezterm-gui/src/termwindow/ui/platform_chrome.rsindex f43714af..dcb93bea 100644--- a/wezterm-gui/src/termwindow/ui/platform_chrome.rs+++ b/wezterm-gui/src/termwindow/ui/platform_chrome.rs@@ -1,9 +1,9 @@use crate::termwindow::ui::tokens::{MACOS_TITLEBAR_CONTENT_TOP_INSET, MACOS_TRAFFIC_LIGHT_CLEARANCE_WIDTH,- MACOS_WINDOW_TAB_RESERVED_ACTION_SLOTS, SIDEBAR_INSET,+ MACOS_WINDOW_TAB_RESERVED_ACTION_SLOTS, SIDEBAR_INSET, TAB_VERTICAL_PADDING,WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_SIZE, WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_X,WINDOW_TAB_FULLSCREEN_SIDEBAR_ICON_SIZE, WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE,- WINDOW_TAB_LEADING_ACTION_GAP, WINDOW_TAB_LEADING_ACTION_ICON_SIZE,+ WINDOW_TAB_LEADING_ACTION_GAP, WINDOW_TAB_LEADING_ACTION_ICON_SIZE, WINDOW_TAB_TOP_SPACER,};use crate::ui::{scale_ui_f32, scale_ui_usize};use window::{@@ -20,6 +20,54 @@ pub struct WindowTabChromeParams {pub integrated_title_button_style: IntegratedTitleButtonStyle,pub cell_width: f32,pub dpi: usize,+ /// Full fancy tab-bar row height when one is visible at the TOP of+ /// the window; None for hidden, retro or bottom tab bars. Drives the+ /// sidebar-toggle size so layout reservation matches painting.+ pub top_fancy_row_height: Option<usize>,+}++/// Single source of truth for the workspace-sidebar toggle size: the+/// collapsed (tab bar) painter, the expanded (sidebar) painter and the+/// tab layout reservation all consume this so they can never disagree.+/// With a visible top fancy bar the toggle matches the window tab capsule+/// height (full row minus top spacer minus vertical padding), floored at+/// the fixed toolbar size so tiny fonts never make it unusable.+pub fn sidebar_toggle_size_px(+ dpi: usize,+ window_state: WindowState,+ top_fancy_row_height: Option<usize>,+) -> usize {+ let px = |v: usize| scale_ui_usize(v, dpi);+ if window_state.contains(WindowState::FULL_SCREEN) {+ return px(WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_SIZE);+ }+ if cfg!(target_os = "macos") {+ return px(WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE);+ }+ if let Some(row_h) = top_fancy_row_height {+ if row_h > 0 {+ let spacer = px(WINDOW_TAB_TOP_SPACER).min(row_h);+ let capsule = (row_h - spacer).saturating_sub(px(TAB_VERTICAL_PADDING) * 2);+ return capsule.max(px(WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE));+ }+ }+ px(WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE)+}++/// Distance from the window content's left edge to the sidebar toggle.+/// Shared by the collapsed and expanded states and deliberately+/// independent of the current sidebar width, so opening or closing the+/// sidebar never moves the control.+pub fn sidebar_toggle_left_inset_px(dpi: usize, window_state: WindowState) -> usize {+ let px = |v: usize| scale_ui_usize(v, dpi);+ if window_state.contains(WindowState::FULL_SCREEN) {+ px(WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_X)+ } else if cfg!(target_os = "macos") {+ px(MACOS_TRAFFIC_LIGHT_CLEARANCE_WIDTH)+ } else {+ // The extra inset clears the rounded window corner.+ px(SIDEBAR_INSET) + px(12)+ }}pub fn uses_integrated_window_buttons(@@ -68,12 +116,8 @@ impl WindowTabChromeParams {pub fn leading_action_start_pixels(self) -> f32 {if self.leading_action_slot_count() == 0 {0.0- } else if self.window_state.contains(WindowState::FULL_SCREEN) {- self.px(WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_X) as f32- } else if cfg!(target_os = "macos") {- self.px(MACOS_TRAFFIC_LIGHT_CLEARANCE_WIDTH) as f32} else {- self.px(SIDEBAR_INSET) as f32+ sidebar_toggle_left_inset_px(self.dpi, self.window_state) as f32}}@@ -96,7 +140,7 @@ impl WindowTabChromeParams {}pub fn sidebar_toggle_button_size(self) -> usize {- self.px(workspace_sidebar_toolbar_button_size(self.window_state))+ sidebar_toggle_size_px(self.dpi, self.window_state, self.top_fancy_row_height)}pub fn sidebar_toggle_icon_size(self) -> usize {@@ -160,14 +204,6 @@ pub fn workspace_sidebar_toolbar_uses_fullscreen_style(window_state: WindowState}/// Sizes are design pixels (2x macOS backing); callers scale via ui_px.-pub fn workspace_sidebar_toolbar_button_size(window_state: WindowState) -> usize {- if workspace_sidebar_toolbar_uses_fullscreen_style(window_state) {- WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_SIZE- } else {- WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE- }-}-pub fn workspace_sidebar_toolbar_icon_size(window_state: WindowState) -> usize {if workspace_sidebar_toolbar_uses_fullscreen_style(window_state) {WINDOW_TAB_FULLSCREEN_SIDEBAR_ICON_SIZE@@ -193,23 +229,110 @@ mod tests {));}+ fn test_params(+ workspace_sidebar_width: usize,+ window_state: WindowState,+ top_fancy_row_height: Option<usize>,+ ) -> WindowTabChromeParams {+ WindowTabChromeParams {+ use_fancy_tab_bar: true,+ workspace_sidebar_width,+ window_state,+ window_decorations: WindowDecorations::INTEGRATED_BUTTONS | WindowDecorations::RESIZE,+ integrated_title_button_alignment: IntegratedTitleButtonAlignment::Right,+ integrated_title_button_style: IntegratedTitleButtonStyle::Windows,+ cell_width: 10.0,+ dpi: 96,+ top_fancy_row_height,+ }+ }++ #[test]+ fn sidebar_toggle_size_tracks_the_fancy_row_and_never_collapses() {+ if cfg!(target_os = "macos") {+ return;+ }+ let px = |v: usize| scale_ui_usize(v, 96);+ let fixed = px(WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE);+ // Capsule = row - spacer - 2 * vertical padding+ let capsule = |row: usize| {+ row - px(WINDOW_TAB_TOP_SPACER) - px(TAB_VERTICAL_PADDING) * 2+ };+ // Normal and large tab fonts follow the row height+ assert_eq!(+ sidebar_toggle_size_px(96, WindowState::default(), Some(38)),+ capsule(38)+ );+ assert_eq!(+ sidebar_toggle_size_px(96, WindowState::default(), Some(58)),+ capsule(58)+ );+ // Hidden, retro or bottom tab bars keep the fixed usable size+ assert_eq!(sidebar_toggle_size_px(96, WindowState::default(), None), fixed);+ // Tiny rows never shrink the control below the fixed size+ assert_eq!(+ sidebar_toggle_size_px(96, WindowState::default(), Some(8)),+ fixed+ );+ // Fullscreen style has its own size on every platform+ assert_eq!(+ sidebar_toggle_size_px(96, WindowState::FULL_SCREEN, Some(38)),+ px(WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_SIZE)+ );+ }++ #[test]+ fn toggle_reservation_matches_painted_size() {+ if cfg!(target_os = "macos") {+ return;+ }+ // A large tab font grows the painted toggle; the tab layout must+ // reserve at least that much so the first tab cannot overlap it.+ for row in [38, 58, 90] {+ let params = test_params(0, WindowState::default(), Some(row));+ let painted = params.sidebar_toggle_button_size();+ assert_eq!(painted, sidebar_toggle_size_px(96, WindowState::default(), Some(row)));+ assert!(+ params.leading_action_area_width_pixels() >= painted as f32,+ "row {row}: reserved {} < painted {painted}",+ params.leading_action_area_width_pixels()+ );+ }+ }++ #[test]+ fn toggle_inset_is_independent_of_sidebar_width() {+ if cfg!(target_os = "macos") {+ return;+ }+ // The expanded painter anchors on sidebar_toggle_left_inset_px;+ // the collapsed tab-bar path uses leading_action_start_pixels.+ // They must agree whenever the tab-bar path is active.+ let inset = sidebar_toggle_left_inset_px(96, WindowState::default());+ let collapsed = test_params(0, WindowState::default(), Some(38));+ assert_eq!(collapsed.leading_action_start_pixels(), inset as f32);+ // Fullscreen too+ let fs_inset = sidebar_toggle_left_inset_px(96, WindowState::FULL_SCREEN);+ let fs = test_params(0, WindowState::FULL_SCREEN, Some(38));+ assert_eq!(fs.leading_action_start_pixels(), fs_inset as f32);+ // And the size is identical whether the sidebar is open or closed+ let open = test_params(380, WindowState::default(), Some(38));+ assert_eq!(+ open.sidebar_toggle_button_size(),+ collapsed.sidebar_toggle_button_size()+ );+ }+#[test]fn toolbar_sizes_are_shared_design_pixels() {// Same design-pixel values on every platform; ui_px maps them to// the local scale (halving at 96dpi), so per-OS values would- // double-apply the reduction.- assert_eq!(- workspace_sidebar_toolbar_button_size(WindowState::default()),- WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE- );+ // double-apply the reduction. (Button sizing moved to the shared+ // sidebar_toggle_size_px geometry, covered by the tests above.)assert_eq!(workspace_sidebar_toolbar_icon_size(WindowState::default()),WINDOW_TAB_LEADING_ACTION_ICON_SIZE);- assert_eq!(- workspace_sidebar_toolbar_button_size(WindowState::FULL_SCREEN),- WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_SIZE- );assert_eq!(workspace_sidebar_toolbar_icon_size(WindowState::FULL_SCREEN),WINDOW_TAB_FULLSCREEN_SIDEBAR_ICON_SIZEdiff --git a/wezterm-gui/src/termwindow/ui/right_sidebar.rs b/wezterm-gui/src/termwindow/ui/right_sidebar.rsindex f1290642..92edc30b 100644--- a/wezterm-gui/src/termwindow/ui/right_sidebar.rs+++ b/wezterm-gui/src/termwindow/ui/right_sidebar.rs@@ -1554,6 +1554,8 @@ impl crate::TermWindow {let old = self.right_sidebar_file_preview_horizontal_offset;let max = self.right_sidebar_file_preview_horizontal_scroll_max();let steps = amount.unsigned_abs().max(1) as usize;+ // The horizontal offset is measured in character columns (the cell+ // width already tracks DPI), so the step stays unscaled.let delta = steps.saturating_mul(4).min(32);if amount < 0 {self.right_sidebar_file_preview_horizontal_offset = self@@ -4842,7 +4844,7 @@ impl crate::TermWindow {fn right_sidebar_file_preview_font_size(&self) -> f64 {let settings = crate::native_settings::load();- let base_font_size = crate::native_settings::home_font_size(&settings);+ let base_font_size = crate::native_settings::right_sidebar_font_size(&settings);(base_font_size + 2.0).max(FILE_FONT_MIN_SIZE)}@@ -5250,7 +5252,7 @@ impl crate::TermWindow {let muted_fg = chrome.secondary_text;let sidebar_bg = chrome.workspace_sidebar_bg;let settings = crate::native_settings::load();- let base_font_size = crate::native_settings::home_font_size(&settings);+ let base_font_size = crate::native_settings::right_sidebar_font_size(&settings);let ui_font = self.fonts.title_font_with_size(base_font_size)@@ -5477,7 +5479,7 @@ impl crate::TermWindow {});let close_icon_size = self.ui_px(RIGHT_SIDEBAR_CLOSE_ICON_SIZE)- .min(close_visual_size.saturating_sub(4))+ .min(close_visual_size.saturating_sub(self.ui_px(4))).max(1);self.paint_sidebar_icon(layers,@@ -5531,7 +5533,7 @@ impl crate::TermWindow {let active_label_target_width = self.sidebar_text_width(&ui_font, self.right_sidebar_mode.label())?.ceil() as usize- + MODE_LABEL_CLIP_SLOP;+ + self.ui_px(MODE_LABEL_CLIP_SLOP);let inactive_segment_min_width = (mode_icon_size + self.ui_px(SIDEBAR_INSET) * 4).max(self.ui_px(70)).min((content_width / modes.len()).max(1));@@ -5590,7 +5592,7 @@ impl crate::TermWindow {});if active {- let inner_inset = 5;+ let inner_inset = self.ui_px(5);self.fill_rounded_rectangle_with_border(layers,2,@@ -5611,10 +5613,10 @@ impl crate::TermWindow {layers,2,euclid::rect(- (segment_x + 5) as f32,- (mode_y + 5) as f32,- segment_width.saturating_sub(10) as f32,- mode_height.saturating_sub(10) as f32,+ (segment_x + self.ui_px(5)) as f32,+ (mode_y + self.ui_px(5)) as f32,+ segment_width.saturating_sub(self.ui_px(10)) as f32,+ mode_height.saturating_sub(self.ui_px(10)) as f32,),chrome.sidebar_button_hover_bg,WINDOW_TAB_ADD_BUTTON_RADIUS,@@ -7725,7 +7727,7 @@ impl crate::TermWindow {euclid::rect(caret_x.clamp(clip_left, clip_right),caret_y,- NOTE_CARET_WIDTH.max(1.0),+ self.ui_f32(NOTE_CARET_WIDTH).max(1.0),caret_height,),foreground,@@ -9169,9 +9171,9 @@ impl crate::TermWindow {});}- if main_width >= 28 {- let text_x = x + 12;- let text_right = x + main_width.saturating_sub(10);+ if main_width >= self.ui_px(28) {+ let text_x = x + self.ui_px(12);+ let text_right = x + main_width.saturating_sub(self.ui_px(10));let text_width = text_right.saturating_sub(text_x);self.paint_sidebar_text(layers,@@ -10253,8 +10255,8 @@ impl crate::TermWindow {icon_size: usize,) -> anyhow::Result<()> {let header_y = content_top;- let back_size = 44;- let header_top = header_y + 8;+ let back_size = self.ui_px(44);+ let header_top = header_y + self.ui_px(8);self.paint_snippet_icon_button(layers,chrome,@@ -10330,7 +10332,7 @@ impl crate::TermWindow {content_width,muted_fg,)?;- let title_y = title_label_y + field_label_height + 8;+ let title_y = title_label_y + field_label_height + self.ui_px(8);let title_input = self.right_sidebar_snippet_title.clone();self.paint_snippet_text_box(layers,@@ -10363,7 +10365,7 @@ impl crate::TermWindow {content_width,muted_fg,)?;- let body_y = body_label_y + field_label_height + 8;+ let body_y = body_label_y + field_label_height + self.ui_px(8);let body_height = self.ui_px(SNIPPET_BODY_FIELD_HEIGHT).min(content_bottom.saturating_sub(body_y));diff --git a/wezterm-gui/src/termwindow/ui/sidebar.rs b/wezterm-gui/src/termwindow/ui/sidebar.rsindex 8a62e905..095b5bf7 100644--- a/wezterm-gui/src/termwindow/ui/sidebar.rs+++ b/wezterm-gui/src/termwindow/ui/sidebar.rs@@ -11,6 +11,7 @@ use crate::termwindow::ui::tokens::{SIDEBAR_RESIZE_HANDLE_WIDTH, SIDEBAR_ROW_GAP, 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,};use crate::termwindow::{UIItem, UIItemType};use crate::ui::{scale_ui_f32, scale_ui_usize, unscale_ui_usize, UiPalette};@@ -471,6 +472,14 @@ impl crate::TermWindow {.context("sidebar thread status dot")}+ /// Visual size of the expanded-sidebar toggle button; shares+ /// sidebar_toggle_size_px with the collapsed-state painter and the tab+ /// layout reservation so the control never changes size when the+ /// sidebar opens or closes.+ fn workspace_sidebar_toggle_visual_size(&self) -> usize {+ self.window_tab_chrome_params().sidebar_toggle_button_size()+ }+fn workspace_sidebar_content_top(&self, panel_y: usize) -> usize {let tab_row_height = self.tab_bar_pixel_height().unwrap_or(0.0).ceil() as usize;platform_chrome::workspace_sidebar_content_top(@@ -507,9 +516,7 @@ impl crate::TermWindow {.max(self.ui_px(SESSION_ROW_MIN_HEIGHT));let mut y = self.workspace_sidebar_content_top(panel_y);if show_sidebar_toolbar {- y += self.ui_px(platform_chrome::workspace_sidebar_toolbar_button_size(- self.window_state,- )) + self.ui_px(SIDEBAR_INSET);+ y += self.workspace_sidebar_toggle_visual_size() + self.ui_px(SIDEBAR_INSET);}let top_action_height = row_height.min(self.ui_px(48))@@ -875,21 +882,42 @@ impl crate::TermWindow {let show_sidebar_toolbar = layout.show_sidebar_toolbar;let sidebar_toolbar_uses_fullscreen_style =platform_chrome::workspace_sidebar_toolbar_uses_fullscreen_style(self.window_state);- let sidebar_toggle_size = self.ui_px(- platform_chrome::workspace_sidebar_toolbar_button_size(self.window_state),- );- let sidebar_toggle_x = panel_x- + if sidebar_toolbar_uses_fullscreen_style {- self.ui_px(WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_X)- } else {- self.ui_px(SIDEBAR_INSET)- };- let sidebar_toggle_y = header_y- + if sidebar_toolbar_uses_fullscreen_style {- self.ui_px(WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_Y_OFFSET)- } else {- 0- };+ let sidebar_toggle_size = self.workspace_sidebar_toggle_visual_size();+ // Mirror the collapsed-state toggle exactly: same left inset from+ // the window content edge (independent of the sidebar width — the+ // tab-bar path's leading_action_start_pixels returns 0 while the+ // sidebar is open, so it must not be used here) and the same+ // centering within the tab bar's content row.+ let border = self.get_os_border();+ let sidebar_toggle_x = if sidebar_toolbar_uses_fullscreen_style {+ panel_x + self.ui_px(WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_X)+ } else {+ border.left.get() as usize+ + platform_chrome::sidebar_toggle_left_inset_px(+ self.dimensions.dpi,+ self.window_state,+ )+ };+ let top_fancy_row = if self.show_tab_bar+ && self.config.use_fancy_tab_bar+ && !self.config.tab_bar_at_bottom+ {+ self.tab_bar_pixel_height().ok().map(|h| h.ceil() as usize)+ } else {+ None+ };+ let sidebar_toggle_y = if sidebar_toolbar_uses_fullscreen_style {+ header_y + self.ui_px(WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_Y_OFFSET)+ } else if let Some(row_h) = top_fancy_row {+ // Same formula as the collapsed painter: centered within the+ // content row (full row minus the top spacer).+ let spacer = self.ui_px(WINDOW_TAB_TOP_SPACER).min(row_h);+ border.top.get() as usize+ + spacer+ + (row_h - spacer).saturating_sub(sidebar_toggle_size) / 2+ } else {+ header_y+ };let sidebar_toggle_icon_size = self.ui_px(platform_chrome::workspace_sidebar_toolbar_icon_size(self.window_state,