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.

gui: hover tags recover file names the sidebar ellipsis ate

RoversXd9c0c3f55b93
diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rs
index 9fc77d9c..f0b4052b 100644
--- a/wezterm-gui/src/termwindow/mod.rs
+++ b/wezterm-gui/src/termwindow/mod.rs
@@ -1187,6 +1187,62 @@ mod tooltip_tests {
})
.is_none());
}
+
+ /// The Files panel is only ever a sidebar wide, so a long name is cut --
+ /// and cut from the end, which is the end that names the file.
+ #[test]
+ fn a_file_row_names_the_file_in_full() {
+ assert_eq!(
+ tooltip_label_for(&UIItemType::RightSidebarFileRow(PathBuf::from(
+ "/src/a-very-long-component-name.module.tsx"
+ )))
+ .as_deref(),
+ Some("a-very-long-component-name.module.tsx")
+ );
+ // A search result's row shows a `display_path`, so the ellipsis eats
+ // the file name specifically -- the tag has to be what it removed,
+ // not the leading directories the row already showed.
+ assert_eq!(
+ tooltip_label_for(&UIItemType::RightSidebarFileRow(PathBuf::from(
+ "/root/wezterm-gui/src/termwindow/ui/right_sidebar.rs"
+ )))
+ .as_deref(),
+ Some("right_sidebar.rs")
+ );
+ // No final component: nothing to name, and an empty tag must not
+ // paint as a bare floating pill.
+ assert!(tooltip_label_for(&UIItemType::RightSidebarFileRow(PathBuf::from("/"))).is_none());
+ // Remote rows are the same full-width, end-ellipsized row painted
+ // from an SFTP listing, and must carry the same tag.
+ assert_eq!(
+ tooltip_label_for(&UIItemType::RightSidebarRemoteFileRow(
+ remote_files::RemotePath::from_server_absolute("/home/x/right_sidebar.rs").unwrap()
+ ))
+ .as_deref(),
+ Some("right_sidebar.rs")
+ );
+ assert!(tooltip_label_for(&UIItemType::RightSidebarRemoteFileRow(
+ remote_files::RemotePath::from_server_absolute("/").unwrap()
+ ))
+ .is_none());
+ }
+
+ /// Alignment is a property of the item's KIND. Kept as a named rule so a
+ /// third full-width row cannot quietly inherit the button behaviour.
+ #[test]
+ fn full_width_rows_left_align_their_tag_and_buttons_do_not() {
+ assert!(tooltip_left_aligns(&UIItemType::RightSidebarFileRow(
+ PathBuf::from("/a/b.rs")
+ )));
+ assert!(tooltip_left_aligns(&UIItemType::RightSidebarRemoteFileRow(
+ remote_files::RemotePath::from_server_absolute("/a/b.rs").unwrap()
+ )));
+ assert!(tooltip_left_aligns(&UIItemType::ThreadRefGroupToggle {
+ key: "project-1".to_string(),
+ origin: "Lab Server".to_string(),
+ }));
+ assert!(!tooltip_left_aligns(&UIItemType::WorkspaceSidebarSettings));
+ }
}
#[cfg(test)]
@@ -1375,8 +1431,22 @@ pub fn tooltip_anchor_x(
x.clamp(0.0, (window_width - tip_width).max(0.0))
}
-/// The name to show for an icon-only button, or `None` for everything that
-/// already carries its own label (or whose meaning is obvious from position).
+/// Whether a tag begins at its item's left edge instead of centring on it.
+///
+/// By item KIND, never by width -- see [`tooltip_anchor_x`] for why. Full-width
+/// list rows have no centre worth pointing at; icon buttons do.
+pub fn tooltip_left_aligns(item_type: &UIItemType) -> bool {
+ matches!(
+ item_type,
+ UIItemType::ThreadRefGroupToggle { .. }
+ | UIItemType::RightSidebarFileRow(_)
+ | UIItemType::RightSidebarRemoteFileRow(_)
+ )
+}
+
+/// The tag to show for an item whose own text cannot say enough: an icon-only
+/// button (no text at all) or a row whose label is cut to fit the sidebar.
+/// `None` for everything that already reads in full.
pub fn tooltip_label_for(item_type: &UIItemType) -> Option<String> {
// A reference group's header shows the origin project's name, exactly
// like a local folder. Where that project actually lives — which Space,
@@ -1385,6 +1455,24 @@ pub fn tooltip_label_for(item_type: &UIItemType) -> Option<String> {
if let UIItemType::ThreadRefGroupToggle { origin, .. } = item_type {
return (!origin.is_empty()).then(|| origin.clone());
}
+ // A file row gets only the sidebar's width, and `ellipsize_ui_text` cuts
+ // from the END -- so what survives is the part every sibling shares and
+ // what is lost is the part that identifies the file. The tag carries the
+ // file name in both modes: in the tree it is what the row already tried
+ // to show, and in search results (where the row shows a `display_path`)
+ // it is exactly the tail the ellipsis ate.
+ if let UIItemType::RightSidebarFileRow(path) = item_type {
+ return path
+ .file_name()
+ .map(|name| name.to_string_lossy().into_owned())
+ .filter(|name| !name.is_empty());
+ }
+ // Remote file rows are the same full-width, end-ellipsized row painted
+ // from an SFTP listing; the tag recovers the same tail.
+ if let UIItemType::RightSidebarRemoteFileRow(path) = item_type {
+ let name = path.file_name();
+ return (!name.is_empty()).then(|| name.to_string());
+ }
let key = match item_type {
UIItemType::WorkspaceSidebarSettings => "tooltip-sidebar-settings",
UIItemType::WorkspaceSidebarViewOptions => "tooltip-sidebar-view-options",
@@ -1465,10 +1553,7 @@ mod pane_output_watchdog_tests {
},
true,
));
- assert!(pane_output_needs_repaint(
- current_after_paint,
- captured
- ));
+ assert!(pane_output_needs_repaint(current_after_paint, captured));
assert!(!pane_output_needs_repaint(captured, captured));
}
@@ -1791,6 +1876,11 @@ pub struct TermWindow {
/// detached tasks, and failures also await a resync) cannot mutate the
/// rejection damper with a stale decision.
client_viewport_publish_seq: HashMap<TabId, u64>,
+ /// File rows whose painted label was actually cut this frame, rebuilt by
+ /// the Files panel painters each paint. Gates the hover tag: a row that
+ /// already reads in full has nothing for a tag to add.
+ right_sidebar_truncated_file_rows: HashSet<PathBuf>,
+ right_sidebar_truncated_remote_file_rows: HashSet<remote_files::RemotePath>,
/// Latest-only full-viewport streams for native divider drags. A stream
/// owns the matching ClientPane preview epoch until its final target is
/// confirmed or explicitly rolled back.
@@ -2843,6 +2933,8 @@ impl TermWindow {
rejected_local_viewports: HashMap::new(),
rejected_client_viewports: HashMap::new(),
client_viewport_publish_seq: HashMap::new(),
+ right_sidebar_truncated_file_rows: HashSet::new(),
+ right_sidebar_truncated_remote_file_rows: HashSet::new(),
remote_divider_resize_streams: HashMap::new(),
next_frontend_geometry_epoch: 1,
frontend_viewport_report_pending: Arc::new(AtomicBool::new(false)),
@@ -6226,10 +6318,7 @@ impl TermWindow {
return;
}
for pos in tab.iter_panes() {
- if self
- .collapsed_pane_layouts
- .contains_key(&pos.pane_stack_id)
- {
+ if self.collapsed_pane_layouts.contains_key(&pos.pane_stack_id) {
continue;
}
let pane_id = pos.pane.pane_id();
@@ -6251,10 +6340,7 @@ impl TermWindow {
}
return;
}
- if let Some(client_pane) = pos
- .pane
- .downcast_ref::<wezterm_client::pane::ClientPane>()
- {
+ if let Some(client_pane) = pos.pane.downcast_ref::<wezterm_client::pane::ClientPane>() {
// Pass the viewport the renderer will actually paint —
// scrolled back, that is not the live screen, and judging
// the live rows would latch the watchdog on Stale rows a
@@ -6662,6 +6748,30 @@ impl TermWindow {
}
/// Whether the given pressed UI item is the surface currently hosting the
+ /// Whether a hover tag may exist for this item right now. The static
+ /// half lives in [`tooltip_label_for`]; this adds the conditions only
+ /// the live window knows: a row being renamed shows an editor where its
+ /// name was (the tag would name the file the user is renaming away
+ /// from), and a file row whose painted label was not actually cut this
+ /// frame already reads in full. Checked both when the tag arms
+ /// (`update_hover_tooltip`) and when it paints (`paint_hover_tooltip`),
+ /// so a rename started from a key assignment with the pointer at rest
+ /// still suppresses an already-armed tag.
+ pub(crate) fn hover_tooltip_allowed(&self, item_type: &UIItemType) -> bool {
+ if self.ui_item_hosts_inline_rename(Some(item_type)) {
+ return false;
+ }
+ match item_type {
+ UIItemType::RightSidebarFileRow(path) => {
+ self.right_sidebar_truncated_file_rows.contains(path)
+ }
+ UIItemType::RightSidebarRemoteFileRow(path) => {
+ self.right_sidebar_truncated_remote_file_rows.contains(path)
+ }
+ _ => true,
+ }
+ }
+
/// inline rename editor; presses there must not auto-commit the rename.
fn ui_item_hosts_inline_rename(&self, item: Option<&UIItemType>) -> bool {
let Some(rename) = self.inline_tab_rename.as_ref() else {
diff --git a/wezterm-gui/src/termwindow/mouseevent.rs b/wezterm-gui/src/termwindow/mouseevent.rs
index 75fa704f..81f7f65d 100644
--- a/wezterm-gui/src/termwindow/mouseevent.rs
+++ b/wezterm-gui/src/termwindow/mouseevent.rs
@@ -1474,7 +1474,7 @@ impl super::TermWindow {
}
}
- /// Track which icon-only button the pointer is resting on.
+ /// Track which tagged item the pointer is resting on.
///
/// Keyed by item *type*, not by the UIItem: the sidebar rebuilds its items
/// every frame and a button's rect can shift by a pixel, which must not
@@ -1484,8 +1484,12 @@ impl super::TermWindow {
/// appear is registered by `paint_hover_tooltip`, because `paint_impl`
/// clears `has_animation` on entry and would discard a deadline set here.
fn update_hover_tooltip(&mut self, item: Option<&UIItem>) {
- let labelled =
- item.filter(|item| crate::termwindow::tooltip_label_for(&item.item_type).is_some());
+ let labelled = item
+ .filter(|item| crate::termwindow::tooltip_label_for(&item.item_type).is_some())
+ // The dynamic half of the rule: no tag over a live rename
+ // editor, and none for a file row whose label already reads in
+ // full. `paint_hover_tooltip` re-checks the same predicate.
+ .filter(|item| self.hover_tooltip_allowed(&item.item_type));
match labelled {
None => self.hover_tooltip = None,
Some(item) => match self.hover_tooltip.as_mut() {
@@ -1776,15 +1780,16 @@ impl super::TermWindow {
self.current_mouse_capture = None;
}
- if self.mouse_wheel_right_sidebar(&event, context) {
- return;
- }
-
- if self.mouse_wheel_workspace_sidebar(&event, context) {
- return;
- }
-
- if self.mouse_wheel_tab_surfaces(&event, context) {
+ if self.mouse_wheel_right_sidebar(&event, context)
+ || self.mouse_wheel_workspace_sidebar(&event, context)
+ || self.mouse_wheel_tab_surfaces(&event, context)
+ {
+ // The wheel moved content under a stationary pointer, so an
+ // armed hover tag now names whatever row USED to be under it.
+ // These early returns never reach `update_hover_tooltip`, so the
+ // stale tag would otherwise fire over the wrong row once its
+ // delay elapses. It re-arms on the next real pointer move.
+ self.hover_tooltip = None;
return;
}
diff --git a/wezterm-gui/src/termwindow/render/paint.rs b/wezterm-gui/src/termwindow/render/paint.rs
index d3edeb95..dd428bd0 100644
--- a/wezterm-gui/src/termwindow/render/paint.rs
+++ b/wezterm-gui/src/termwindow/render/paint.rs
@@ -642,10 +642,7 @@ impl crate::TermWindow {
}
}
- pub(crate) fn paint_impl(
- &mut self,
- frame: &mut RenderFrame,
- ) -> anyhow::Result<PaintOutcome> {
+ pub(crate) fn paint_impl(&mut self, frame: &mut RenderFrame) -> anyhow::Result<PaintOutcome> {
self.num_frames += 1;
// If nothing on screen needs animating, then we can avoid
// invalidating as frequently
@@ -2721,6 +2718,12 @@ impl crate::TermWindow {
self.update_next_frame_time(Some(Instant::now() + remaining));
return Ok(());
}
+ // Re-check the dynamic conditions at paint time: a rename started
+ // from a key assignment (no mouse event) or a row whose label no
+ // longer overflows must suppress an already-armed tag.
+ if !self.hover_tooltip_allowed(&hover.item.item_type) {
+ return Ok(());
+ }
let Some(label) = crate::termwindow::tooltip_label_for(&hover.item.item_type) else {
return Ok(());
};
@@ -2771,10 +2774,7 @@ impl crate::TermWindow {
// buttons in the same row — these are laid out horizontally, so the
// only free direction is up. Flip below when there is no room above.
// Full-width list rows left-align their tag; icon buttons centre it.
- let left_align = matches!(
- hover.item.item_type,
- crate::termwindow::UIItemType::ThreadRefGroupToggle { .. }
- );
+ let left_align = crate::termwindow::tooltip_left_aligns(&hover.item.item_type);
let x = crate::termwindow::tooltip_anchor_x(bx, bw, tip_w, window_w, left_align);
let y = if by - gap - tip_h >= 0.0 {
by - gap - tip_h
diff --git a/wezterm-gui/src/termwindow/ui/right_sidebar.rs b/wezterm-gui/src/termwindow/ui/right_sidebar.rs
index 83808ffc..3eeb00e7 100644
--- a/wezterm-gui/src/termwindow/ui/right_sidebar.rs
+++ b/wezterm-gui/src/termwindow/ui/right_sidebar.rs
@@ -9178,6 +9178,10 @@ impl crate::TermWindow {
content_bottom: usize,
icon_size: usize,
) -> anyhow::Result<()> {
+ // Rebuilt as the rows paint below: only rows recorded this frame may
+ // carry the truncated-name hover tag.
+ self.right_sidebar_truncated_file_rows.clear();
+ self.right_sidebar_truncated_remote_file_rows.clear();
if let Some(target) = self
.active_remote_project_for_files()
.map_err(anyhow::Error::msg)?
@@ -10135,6 +10139,15 @@ impl crate::TermWindow {
false,
)
} else {
+ // Same rule as the local tree: only a name the ellipsis actually
+ // cut earns the hover tag.
+ if matches!(
+ self.ellipsize_ui_text(ui_font, &row.entry.name, text_width)?,
+ Cow::Owned(_)
+ ) {
+ self.right_sidebar_truncated_remote_file_rows
+ .insert(row.entry.path.clone());
+ }
self.paint_sidebar_text(
layers,
ui_font,
@@ -14038,6 +14051,16 @@ impl crate::TermWindow {
} else {
let cell_height = ui_metrics.cell_size.height as usize;
let text_y = y + (row_metrics.row_height.saturating_sub(cell_height)) / 2;
+ // The hover tag exists to recover what the ellipsis ate; a name
+ // that fits carries no tag. The shared shape cache makes this
+ // re-measure a lookup, not a second shaping pass.
+ if matches!(
+ self.ellipsize_ui_text(ui_font, &row.name, text_width)?,
+ Cow::Owned(_)
+ ) {
+ self.right_sidebar_truncated_file_rows
+ .insert(row.path.clone());
+ }
if visible(text_y, cell_height) {
self.paint_sidebar_text(
layers,