Skip to content

A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.

fix(sidebar): keep the right sidebar's hover panel below the window buttons

RoversX2bd2b276be6d
diff --git a/wezterm-gui/src/termwindow/render/paint.rs b/wezterm-gui/src/termwindow/render/paint.rs
index f7595692..f9bb8811 100644
--- a/wezterm-gui/src/termwindow/render/paint.rs
+++ b/wezterm-gui/src/termwindow/render/paint.rs
@@ -371,6 +371,15 @@ fn preview_quad_key(
}
}
+fn clip_right_sidebar_hover_items(items: &mut Vec<UIItem>, top: usize, bottom: usize) {
+ items.retain_mut(|item| {
+ let end = item.y.saturating_add(item.height).min(bottom);
+ item.y = item.y.max(top);
+ item.height = end.saturating_sub(item.y);
+ item.height > 0
+ });
+}
+
fn quad_clip_rect(rect: RectF, dimensions: &Dimensions) -> QuadClipRect {
QuadClipRect::from_top_left_pixels(
rect.min_x(),
@@ -3563,6 +3572,13 @@ impl crate::TermWindow {
}
}
}
+ if !cfg!(target_os = "macos") {
+ if let Some(rect) = self.right_sidebar_rect() {
+ // The shared painters include top chrome backgrounds. Neither
+ // those targets nor the moving panel may cover window buttons.
+ clip_right_sidebar_hover_items(&mut items, rect.y, rect.y + rect.height);
+ }
+ }
Ok(Some((panel_frame, 1.0 - progress, items)))
}
@@ -3584,7 +3600,11 @@ impl crate::TermWindow {
let offset_x = hidden * rect.width as f32;
let clip = crate::quad::QuadClipRect::from_top_left_pixels(
0.0,
- 0.0,
+ if cfg!(target_os = "macos") {
+ 0.0
+ } else {
+ rect.y as f32
+ },
self.dimensions.pixel_width as f32,
self.dimensions.pixel_height as f32,
&self.dimensions,
@@ -4603,6 +4623,28 @@ mod tests {
use super::*;
use crate::quad::TripleLayerQuadAllocatorTrait;
+ #[test]
+ fn right_sidebar_hover_keeps_tab_bar_buttons_clickable() {
+ // Test both the narrow blocker used during animation and the full
+ // panel, including a top background and content crossing its edge.
+ for width in [30, 300] {
+ let item = |y, height| UIItem {
+ x: 1000 - width,
+ y,
+ width,
+ height,
+ item_type: UIItemType::RightSidebarBackground,
+ };
+ let mut items = vec![item(0, 40), item(0, 800), item(35, 30), item(100, 20)];
+ clip_right_sidebar_hover_items(&mut items, 40, 800);
+ assert_eq!(items.len(), 3);
+ assert!(items.iter().all(|item| !item.hit_test(990, 20)));
+ assert!(items.iter().any(|item| item.hit_test(990, 50)));
+ assert_eq!((items[1].y, items[1].height), (40, 25));
+ assert_eq!((items[2].y, items[2].height), (100, 20));
+ }
+ }
+
fn test_preview(area: RectF) -> TerminalPreviewRequest {
TerminalPreviewRequest {
tab_id: 1,
diff --git a/wezterm-gui/src/termwindow/ui/right_sidebar.rs b/wezterm-gui/src/termwindow/ui/right_sidebar.rs
index c516fdec..984a189b 100644
--- a/wezterm-gui/src/termwindow/ui/right_sidebar.rs
+++ b/wezterm-gui/src/termwindow/ui/right_sidebar.rs
@@ -1841,7 +1841,7 @@ impl crate::TermWindow {
rect.y,
rect.height,
width,
- top_tab_bar_height,
+ rect.y.saturating_add(top_tab_bar_height),
)
}
@@ -6523,7 +6523,7 @@ impl crate::TermWindow {
// below the tab bar so both remain reachable.
if !cfg!(target_os = "macos") && self.right_sidebar_collapsed {
let tab_bar = self.tab_bar_pixel_height().unwrap_or(0.0).ceil() as usize;
- let top = tab_bar.max(rect.y);
+ let top = rect.y.saturating_add(tab_bar);
rect.height = rect.height.saturating_sub(top - rect.y);
rect.y = top;
if rect.height == 0 {
@@ -7084,6 +7084,22 @@ impl crate::TermWindow {
}
}
+ fn right_sidebar_top_bar_layout(&self, rect: RightSidebarRect) -> (usize, usize) {
+ let y = rect.y + self.ui_px(SIDEBAR_INSET) * 2;
+ // A non-macOS hover panel already sits below the window buttons and
+ // has no toggle of its own, so it needs no additional button row.
+ let height = if !cfg!(target_os = "macos") && self.right_sidebar_collapsed {
+ 0
+ } else {
+ self.ui_px(RIGHT_SIDEBAR_TOP_BAR_HEIGHT).min(
+ rect.y
+ .saturating_add(rect.height)
+ .saturating_sub(y + self.ui_px(SIDEBAR_INSET)),
+ )
+ };
+ (y, height)
+ }
+
fn right_sidebar_snippet_scroll_metrics(&self) -> Option<(usize, usize, usize)> {
let Some(rect) = self.right_sidebar_rect() else {
return None;
@@ -7095,12 +7111,7 @@ impl crate::TermWindow {
return None;
}
- let top_bar_y = rect.y + self.ui_px(SIDEBAR_INSET) * 2;
- let top_bar_height = self.ui_px(RIGHT_SIDEBAR_TOP_BAR_HEIGHT).min(
- rect.y
- .saturating_add(rect.height)
- .saturating_sub(top_bar_y + self.ui_px(SIDEBAR_INSET)),
- );
+ let (top_bar_y, top_bar_height) = self.right_sidebar_top_bar_layout(rect);
let content_top = top_bar_y
+ top_bar_height
+ self.ui_px(RIGHT_SIDEBAR_MODE_HEIGHT)
@@ -7414,17 +7425,8 @@ impl crate::TermWindow {
let content_x = rect.x + self.ui_px(SIDEBAR_INSET) * 2;
let content_width = rect.width.saturating_sub(self.ui_px(SIDEBAR_INSET) * 4);
- let top_bar_y = rect.y + self.ui_px(SIDEBAR_INSET) * 2;
- let top_bar_height = self.ui_px(RIGHT_SIDEBAR_TOP_BAR_HEIGHT).min(
- rect.y
- .saturating_add(rect.height)
- .saturating_sub(top_bar_y + self.ui_px(SIDEBAR_INSET)),
- );
- if top_bar_height == 0 {
- return Ok(());
- }
-
- if cfg!(target_os = "macos") {
+ let (top_bar_y, top_bar_height) = self.right_sidebar_top_bar_layout(rect);
+ if cfg!(target_os = "macos") && top_bar_height > 0 {
let close_button_size = self
.ui_px(RIGHT_SIDEBAR_CLOSE_BUTTON_SIZE)
.min(top_bar_height)