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.

Rework ref folders: project grouping, hover provenance, precise active row

RoversXf03fbe6cd374
diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rs
index 3fd9a7e8..5cd0cfde 100644
--- a/wezterm-gui/src/termwindow/mod.rs
+++ b/wezterm-gui/src/termwindow/mod.rs
@@ -520,13 +520,20 @@ pub enum UIItemType {
/// connected this session).
SpaceReconnect,
ProjectToggleThreads(String),
- /// Collapse/expand a folder-style thread-reference group; the payload is
- /// the group key (`"<space_id>::<machine_label>"`), tracked in runtime
- /// state rather than the store.
- ThreadRefGroupToggle(String),
+ /// Collapse/expand a folder-style thread-reference group. `key` is the
+ /// collapse-state key (`"<space_id>::"` + the group key — the origin
+ /// project id, or a machine fallback for dangling groups), tracked in
+ /// runtime state rather than the store. `origin` is the group's
+ /// provenance — origin Space for a local group, machine (and Space) for
+ /// a remote one, empty for a dangling group whose header already names
+ /// the machine; the row has no room for it, so it is the hover tag.
+ ThreadRefGroupToggle {
+ key: String,
+ origin: String,
+ },
/// The "+" on a reference group: create a thread in the group's origin
/// project (exactly like the project "+") and auto-add a ref to it in
- /// the current Space. Payload is the group's origin Space id.
+ /// the current Space. Payload is the group key (origin project id).
ThreadRefGroupNewThread(String),
Project(String),
WorkspaceThread(String),
@@ -1113,6 +1120,46 @@ mod tooltip_tests {
assert!(tooltip_label_for(&item_type).is_none(), "{:?}", item_type);
}
}
+
+ #[test]
+ fn a_tag_centres_on_a_button_but_starts_at_a_rows_left_edge() {
+ // Icon button: centred on it, regardless of relative widths.
+ assert_eq!(tooltip_anchor_x(100.0, 24.0, 80.0, 1000.0, false), 72.0);
+ // The nearly-row-wide Settings body still centres — alignment is
+ // by item kind, so it cannot flip while the sidebar is resized.
+ assert_eq!(tooltip_anchor_x(8.0, 300.0, 80.0, 1000.0, false), 118.0);
+ // A list row's tag begins where the row begins — even when the tag
+ // is wider than the row (narrow sidebar, long origin), where
+ // centring would shove it left of the row.
+ assert_eq!(tooltip_anchor_x(8.0, 300.0, 80.0, 1000.0, true), 8.0);
+ assert_eq!(tooltip_anchor_x(8.0, 246.0, 300.0, 1000.0, true), 8.0);
+ // Neither mode may push the tag off-window.
+ assert_eq!(tooltip_anchor_x(0.0, 24.0, 80.0, 1000.0, false), 0.0);
+ assert_eq!(tooltip_anchor_x(960.0, 24.0, 80.0, 1000.0, false), 920.0);
+ assert_eq!(tooltip_anchor_x(960.0, 40.0, 80.0, 1000.0, true), 920.0);
+ }
+
+ /// A reference folder looks like any other folder, so where its threads
+ /// actually live is only discoverable through the hover tag: the origin
+ /// Space for a local group, machine · Space for a remote one.
+ #[test]
+ fn a_reference_group_names_its_origin() {
+ assert_eq!(
+ tooltip_label_for(&UIItemType::ThreadRefGroupToggle {
+ key: "project-1".to_string(),
+ origin: "Lab Server · Studies".to_string(),
+ })
+ .as_deref(),
+ Some("Lab Server · Studies")
+ );
+ // A dangling group's header already names the machine; the paint
+ // side passes an empty tag and no tooltip may appear.
+ assert!(tooltip_label_for(&UIItemType::ThreadRefGroupToggle {
+ key: "project-1".to_string(),
+ origin: String::new(),
+ })
+ .is_none());
+ }
}
#[cfg(test)]
@@ -1277,9 +1324,40 @@ pub struct HoverTooltip {
pub since: Instant,
}
+/// Where a hover tag's left edge goes, given the rect it names.
+///
+/// Alignment is decided by what KIND of item is tagged, never inferred from
+/// widths: a width heuristic silently re-anchors whichever control happens
+/// to cross the tag's width — the Settings row is nearly sidebar-wide while
+/// its label shows, then collapses to an icon pill, and its tag must not
+/// flip alignment mid-resize. Buttons centre (the tag reads as belonging to
+/// the icon); full-width list rows left-align to the row's start (they have
+/// no centre worth pointing at). Kept clear of the window edges either way.
+pub fn tooltip_anchor_x(
+ item_x: f32,
+ item_width: f32,
+ tip_width: f32,
+ window_width: f32,
+ left_align: bool,
+) -> f32 {
+ let x = if left_align {
+ item_x
+ } else {
+ item_x + (item_width - tip_width) / 2.0
+ };
+ 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).
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,
+ // which machine — has nowhere to go on a sidebar-width row, so the
+ // hover tag is where it appears.
+ if let UIItemType::ThreadRefGroupToggle { origin, .. } = item_type {
+ return (!origin.is_empty()).then(|| origin.clone());
+ }
let key = match item_type {
UIItemType::WorkspaceSidebarSettings => "tooltip-sidebar-settings",
UIItemType::WorkspaceSidebarViewOptions => "tooltip-sidebar-view-options",
@@ -1836,7 +1914,9 @@ pub struct TermWindow {
/// Feeds the hover-reveal as a hot zone.
titlebar_sidebar_button_hovered: bool,
/// Collapsed folder-style reference groups, keyed by
- /// `"<space_id>::<machine_label>"`. Runtime-only: collapse state resets
+ /// `"<space_id>::<group_key>"`, where the group key is the origin
+ /// project id (or a machine fallback for dangling groups). Runtime-only:
+ /// collapse state resets
/// with the window, like a disclosure and unlike project collapse.
thread_ref_groups_collapsed: std::collections::HashSet<String>,
/// A native (AppKit) context menu is open. The fallback menu tracks
diff --git a/wezterm-gui/src/termwindow/mouseevent.rs b/wezterm-gui/src/termwindow/mouseevent.rs
index d0a7a4c8..12489009 100644
--- a/wezterm-gui/src/termwindow/mouseevent.rs
+++ b/wezterm-gui/src/termwindow/mouseevent.rs
@@ -1389,7 +1389,7 @@ impl super::TermWindow {
| UIItemType::SpaceMenu
| UIItemType::SpaceReconnect
| UIItemType::ProjectToggleThreads(_)
- | UIItemType::ThreadRefGroupToggle(_)
+ | UIItemType::ThreadRefGroupToggle { .. }
| UIItemType::ThreadRefGroupNewThread(_)
| UIItemType::Project(_)
| UIItemType::WorkspaceThread(_)
@@ -1501,7 +1501,7 @@ impl super::TermWindow {
| UIItemType::SpaceMenu
| UIItemType::SpaceReconnect
| UIItemType::ProjectToggleThreads(_)
- | UIItemType::ThreadRefGroupToggle(_)
+ | UIItemType::ThreadRefGroupToggle { .. }
| UIItemType::ThreadRefGroupNewThread(_)
| UIItemType::Project(_)
| UIItemType::WorkspaceThread(_)
@@ -3414,7 +3414,7 @@ impl super::TermWindow {
UIItemType::ProjectToggleThreads(project_id) => {
self.mouse_event_project_toggle_threads(project_id, event, context);
}
- UIItemType::ThreadRefGroupToggle(group_key) => {
+ UIItemType::ThreadRefGroupToggle { key: group_key, .. } => {
if let WMEK::Press(MousePress::Left) = event.kind {
if !self.thread_ref_groups_collapsed.remove(&group_key) {
self.thread_ref_groups_collapsed.insert(group_key);
@@ -3423,9 +3423,9 @@ impl super::TermWindow {
}
context.set_cursor(Some(MouseCursor::Arrow));
}
- UIItemType::ThreadRefGroupNewThread(origin_space_id) => {
+ UIItemType::ThreadRefGroupNewThread(group_key) => {
if let WMEK::Press(MousePress::Left) = event.kind {
- self.create_thread_in_ref_group(&origin_space_id, context);
+ self.create_thread_in_ref_group(&group_key, context);
}
context.set_cursor(Some(MouseCursor::Arrow));
}
@@ -3918,7 +3918,7 @@ impl super::TermWindow {
UIItemType::ProjectToggleThreads(project_id) => {
self.mouse_event_project_toggle_threads(project_id, event, context);
}
- UIItemType::ThreadRefGroupToggle(group_key) => {
+ UIItemType::ThreadRefGroupToggle { key: group_key, .. } => {
if let WMEK::Press(MousePress::Left) = event.kind {
if !self.thread_ref_groups_collapsed.remove(&group_key) {
self.thread_ref_groups_collapsed.insert(group_key);
@@ -3927,9 +3927,9 @@ impl super::TermWindow {
}
context.set_cursor(Some(MouseCursor::Arrow));
}
- UIItemType::ThreadRefGroupNewThread(origin_space_id) => {
+ UIItemType::ThreadRefGroupNewThread(group_key) => {
if let WMEK::Press(MousePress::Left) = event.kind {
- self.create_thread_in_ref_group(&origin_space_id, context);
+ self.create_thread_in_ref_group(&group_key, context);
}
context.set_cursor(Some(MouseCursor::Arrow));
}
@@ -5612,15 +5612,10 @@ impl super::TermWindow {
/// The reference group "+": create a thread in the group's origin
/// project — exactly the project-"+" flow — and auto-add a reference to
/// it in the current Space so it appears (and activates) right here.
- pub(crate) fn create_thread_in_ref_group(
- &mut self,
- origin_space_id: &str,
- context: &dyn WindowOps,
- ) {
- let Some(project_id) = crate::workspace_threads::ref_group_origin_project(
- &self.active_space_id,
- origin_space_id,
- ) else {
+ pub(crate) fn create_thread_in_ref_group(&mut self, group_key: &str, context: &dyn WindowOps) {
+ let Some(project_id) =
+ crate::workspace_threads::ref_group_origin_project(&self.active_space_id, group_key)
+ else {
context.invalidate();
return;
};
diff --git a/wezterm-gui/src/termwindow/render/paint.rs b/wezterm-gui/src/termwindow/render/paint.rs
index 07df5b8b..da536cb7 100644
--- a/wezterm-gui/src/termwindow/render/paint.rs
+++ b/wezterm-gui/src/termwindow/render/paint.rs
@@ -2749,11 +2749,15 @@ impl crate::TermWindow {
let window_w = self.dimensions.pixel_width as f32;
let window_h = self.dimensions.pixel_height as f32;
- // Above the button, centred on it. Beside it would sit on top of the
- // neighbouring 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.
- let x = (bx + (bw - tip_w) / 2.0).clamp(0.0, (window_w - tip_w).max(0.0));
+ // Above the button. Beside it would sit on top of the neighbouring
+ // 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 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
} else {
diff --git a/wezterm-gui/src/termwindow/ui/sidebar.rs b/wezterm-gui/src/termwindow/ui/sidebar.rs
index dfcf7f0b..e74c9b6e 100644
--- a/wezterm-gui/src/termwindow/ui/sidebar.rs
+++ b/wezterm-gui/src/termwindow/ui/sidebar.rs
@@ -330,10 +330,18 @@ impl crate::TermWindow {
)
}
+ /// `section_gap`/`group_gap` arrive PRE-SCALED (`ui_px` of
+ /// `WORKSPACE_SECTION_LABEL_GAP`/`WORKSPACE_GROUP_EXTRA_GAP`): this is an
+ /// associated fn with no `&self` to scale with, and the paint loop adds
+ /// the scaled values — adding the raw constants here over-counts every
+ /// gap on any display whose ui scale is not exactly 1 (e.g. Linux 96dpi
+ /// at 0.5), inflating max_scroll past the painted content.
fn workspace_sidebar_list_height(
view: &workspace_threads::WorkspaceThreadsView,
row_height: usize,
row_gap: usize,
+ section_gap: usize,
+ group_gap: usize,
) -> usize {
let mut height = 0usize;
if !view.pinned_threads.is_empty() {
@@ -346,7 +354,7 @@ impl crate::TermWindow {
}
if !view.projects.is_empty() {
if !view.pinned_threads.is_empty() {
- height = height.saturating_add(WORKSPACE_SECTION_LABEL_GAP);
+ height = height.saturating_add(section_gap);
}
height = height.saturating_add(row_height + row_gap);
}
@@ -361,15 +369,15 @@ impl crate::TermWindow {
view.projects
.len()
.saturating_sub(1)
- .saturating_mul(WORKSPACE_GROUP_EXTRA_GAP),
+ .saturating_mul(group_gap),
);
if !view.ref_groups.is_empty() {
if !view.pinned_threads.is_empty() || !view.projects.is_empty() {
- height = height.saturating_add(WORKSPACE_GROUP_EXTRA_GAP);
+ height = height.saturating_add(group_gap);
}
for (group_idx, group) in view.ref_groups.iter().enumerate() {
if group_idx > 0 {
- height = height.saturating_add(WORKSPACE_GROUP_EXTRA_GAP);
+ height = height.saturating_add(group_gap);
}
height = height.saturating_add(row_height + row_gap);
if !group.collapsed {
@@ -385,9 +393,12 @@ impl crate::TermWindow {
view: &workspace_threads::WorkspaceThreadsView,
row_height: usize,
row_gap: usize,
+ section_gap: usize,
+ group_gap: usize,
viewport_height: usize,
) -> usize {
- let height = Self::workspace_sidebar_list_height(view, row_height, row_gap);
+ let height =
+ Self::workspace_sidebar_list_height(view, row_height, row_gap, section_gap, group_gap);
if height > viewport_height {
height.saturating_add(SIDEBAR_LIST_BOTTOM_PADDING)
} else {
@@ -590,14 +601,22 @@ impl crate::TermWindow {
}
}
+ /// `suppress_active` carries "a thread reference's workspace is on
+ /// screen": the Space's own active-thread pointer is then stale for
+ /// selection (ref activation never repoints it), so the Space's OWN rows
+ /// must not paint as active next to the ref row that actually is. Ref
+ /// rows always pass false. The suppression lives here, on the paint
+ /// side, because `is_active` in the view data feeds other consumers —
+ /// notably the status-filter exemption — that must keep seeing it.
fn is_workspace_sidebar_thread_selected(
&self,
session: &workspace_threads::WorkspaceThreadView,
+ suppress_active: bool,
) -> bool {
if let Some(thread_id) = self.workspace_sidebar_pending_thread_selection.as_deref() {
thread_id == session.id.as_str()
} else {
- session.is_active
+ session.is_active && !suppress_active
}
}
@@ -606,8 +625,9 @@ impl crate::TermWindow {
session: &workspace_threads::WorkspaceThreadView,
chrome: &UiPalette,
foreground: LinearRgba,
+ suppress_active: bool,
) -> LinearRgba {
- if session.is_active {
+ if session.is_active && !suppress_active {
LinearRgba::with_components(0.20, 0.78, 0.36, 1.0)
} else if session.is_unread {
chrome.selected_bg
@@ -626,13 +646,14 @@ impl crate::TermWindow {
status: UiStatusKind,
chrome: &UiPalette,
foreground: LinearRgba,
+ suppress_active: bool,
) -> LinearRgba {
if status == UiStatusKind::Done {
SESSION_STATUS_DONE_COLOR
- } else if session.is_active {
+ } else if session.is_active && !suppress_active {
foreground
} else {
- self.sidebar_thread_dot_color(session, chrome, foreground)
+ self.sidebar_thread_dot_color(session, chrome, foreground, suppress_active)
}
}
@@ -653,6 +674,7 @@ impl crate::TermWindow {
row_height: usize,
chrome: &UiPalette,
foreground: LinearRgba,
+ suppress_active: bool,
) -> anyhow::Result<()> {
let icon_y = y + ((row_height.saturating_sub(self.ui_px(SESSION_STATUS_ICON_SIZE))) / 2);
if let Some(status) = self.sidebar_thread_status_kind(session) {
@@ -668,7 +690,13 @@ impl crate::TermWindow {
centered_inner_start(x, self.ui_px(SESSION_STATUS_ICON_SIZE), status_size),
centered_inner_start(y, row_height, status_size),
status_size,
- self.sidebar_thread_status_color(session, status, chrome, foreground),
+ self.sidebar_thread_status_color(
+ session,
+ status,
+ chrome,
+ foreground,
+ suppress_active,
+ ),
);
}
@@ -687,7 +715,7 @@ impl crate::TermWindow {
self.ui_px(SESSION_STATUS_DOT_SIZE) as f32,
self.ui_px(SESSION_STATUS_DOT_SIZE) as f32,
),
- self.sidebar_thread_dot_color(session, chrome, foreground),
+ self.sidebar_thread_dot_color(session, chrome, foreground, suppress_active),
self.ui_px(SESSION_STATUS_DOT_SIZE) as f32 / 2.0,
)
.context("sidebar thread status dot")
@@ -843,6 +871,8 @@ impl crate::TermWindow {
&view,
layout.row_height,
row_gap,
+ self.ui_px(WORKSPACE_SECTION_LABEL_GAP),
+ self.ui_px(WORKSPACE_GROUP_EXTRA_GAP),
viewport_height,
);
total_height.saturating_sub(viewport_height) as f32
@@ -901,6 +931,8 @@ impl crate::TermWindow {
&view,
layout.row_height,
row_gap,
+ self.ui_px(WORKSPACE_SECTION_LABEL_GAP),
+ self.ui_px(WORKSPACE_GROUP_EXTRA_GAP),
viewport_height,
);
let max_scroll = total_height.saturating_sub(viewport_height) as f32;
@@ -1130,6 +1162,9 @@ impl crate::TermWindow {
&active_workspace,
&workspaces,
));
+ // A ref row is showing its workspace: the Space's own rows must not
+ // paint a second active highlight from their stale pointer.
+ let suppress_own_active = view.ref_workspace_on_screen();
let header_icon_size = icon_size.min(self.ui_px(32));
let button_size = (header_icon_size + self.ui_px(8)).clamp(self.ui_px(32), self.ui_px(40));
@@ -1571,6 +1606,8 @@ impl crate::TermWindow {
&view,
session_row_height,
row_gap,
+ self.ui_px(WORKSPACE_SECTION_LABEL_GAP),
+ self.ui_px(WORKSPACE_GROUP_EXTRA_GAP),
viewport_height,
);
total_height.saturating_sub(viewport_height) as f32
@@ -1663,7 +1700,8 @@ impl crate::TermWindow {
session_row_height,
);
let is_renaming_session = self.is_renaming_sidebar_thread(&session.id);
- let is_selected = self.is_workspace_sidebar_thread_selected(session);
+ let is_selected =
+ self.is_workspace_sidebar_thread_selected(session, suppress_own_active);
if is_selected {
self.fill_rounded_rectangle_with_border(
layers,
@@ -1721,6 +1759,7 @@ impl crate::TermWindow {
session_row_height,
&chrome,
foreground,
+ suppress_own_active,
)?;
let title = self.sidebar_thread_title(&session.id, &session.name);
self.paint_sidebar_text(
@@ -2027,7 +2066,8 @@ impl crate::TermWindow {
row_bottom.min(content_bottom_f).ceil().max(hit_y as f32) as usize;
let hit_height = hit_bottom.saturating_sub(hit_y).max(1);
- let is_selected = self.is_workspace_sidebar_thread_selected(session);
+ let is_selected =
+ self.is_workspace_sidebar_thread_selected(session, suppress_own_active);
if row_is_visible && is_selected {
self.fill_rounded_rectangle_with_border(
layers,
@@ -2104,6 +2144,7 @@ impl crate::TermWindow {
session_row_height,
&chrome,
foreground,
+ suppress_own_active,
)?;
let session_title = self.sidebar_thread_title(&session.id, &session.name);
self.paint_sidebar_text(
@@ -2194,6 +2235,12 @@ impl crate::TermWindow {
let row_bottom = row_top + session_row_height as f32;
let row_is_visible = row_bottom > list_top_f && row_top < content_bottom_f;
let y = row_top.floor().max(0.0) as usize;
+ // Hit rect clamped to the list viewport, like every other
+ // full-width row: a header scrolled under the toolbar keeps
+ // painting (masked) but must not swallow toolbar clicks.
+ let hit_y = row_top.max(list_top_f).floor().max(0.0) as usize;
+ let hit_bottom = row_bottom.min(content_bottom_f).ceil().max(hit_y as f32) as usize;
+ let hit_height = hit_bottom.saturating_sub(hit_y).max(1);
let disclosure_size = icon_size.min(22);
let disclosure_x = item_x + self.ui_px(SIDEBAR_INSET);
@@ -2209,12 +2256,33 @@ impl crate::TermWindow {
.saturating_sub(group_action_size + self.ui_px(SIDEBAR_INSET));
if row_is_visible {
let group_key = format!("{group_space_id}::{}", group.key);
+ // The hover tag carries the provenance the project-name
+ // header cannot: project names repeat across Spaces, so
+ // a local group names its origin Space, and a remote one
+ // leads with the machine. A dangling group's header IS
+ // the machine label already — nothing left to add.
+ let dangling = group
+ .threads
+ .first()
+ .is_some_and(|reference| reference.dangling);
+ let origin_tag = if dangling {
+ String::new()
+ } else if group.machine_is_local {
+ group.origin_space_name.clone()
+ } else if group.origin_space_name.is_empty() {
+ group.machine_label.clone()
+ } else {
+ format!("{} · {}", group.machine_label, group.origin_space_name)
+ };
self.ui_items.push(UIItem {
x: item_x,
- y,
+ y: hit_y,
width: item_width,
- height: session_row_height,
- item_type: UIItemType::ThreadRefGroupToggle(group_key),
+ height: hit_height,
+ item_type: UIItemType::ThreadRefGroupToggle {
+ key: group_key,
+ origin: origin_tag,
+ },
});
self.paint_sidebar_icon(
layers,
@@ -2240,10 +2308,11 @@ impl crate::TermWindow {
muted_fg.mul_alpha(0.6)
},
)?;
- // Header: origin-Space name, with the machine as a
- // right-aligned badge. The name is the primary info, so
- // when both cannot fit the badge is dropped first and
- // the name keeps the full width (ellipsized as needed).
+ // Header: the origin project's name, full width, exactly
+ // like a local folder. The machine it lives on is the
+ // row's hover tag — a permanent badge would eat the
+ // name's width on every row to answer a question the
+ // user asks once.
let header_fg = if group.attached {
muted_fg
} else {
@@ -2251,56 +2320,6 @@ impl crate::TermWindow {
};
let text_avail =
group_action_x.saturating_sub(group_text_x + self.ui_px(SIDEBAR_INSET));
- let badge_pad = self.ui_px(6);
- let badge_gap = self.ui_px(8);
- // Badge typography: clearly smaller than the header name
- // so it reads as metadata, matching the height of the
- // "+" button beside it.
- let badge_font = self
- .fonts
- .title_font_with_size(
- crate::native_settings::sidebar_font_size() * 0.82,
- )
- .ok();
- // Local needs no badge: the badge answers "which
- // machine", and this machine is the answer by default.
- let show_badge = group.machine_label != group.label
- && !group.machine_label.is_empty()
- && group.machine_label != "Local";
- let badge = match (&badge_font, show_badge) {
- (Some(badge_font), true) => {
- let badge_metrics =
- RenderMetrics::with_font_metrics(&badge_font.metrics());
- (|| {
- let text_w = self
- .cached_ui_text_advance(
- badge_font,
- &badge_metrics,
- &group.machine_label,
- )
- .ok()?
- .ceil() as usize;
- let name_w = self
- .cached_ui_text_advance(
- &ui_font,
- &ui_metrics,
- &group.label,
- )
- .ok()?
- .ceil() as usize;
- let badge_w = text_w + badge_pad * 2;
- (name_w + badge_gap + badge_w <= text_avail)
- .then_some((badge_w, badge_metrics))
- })()
- }
- _ => None,
- };
- let name_avail = match &badge {
- Some((badge_w, _)) => {
- text_avail.saturating_sub(badge_w + badge_gap)
- }
- None => text_avail,
- };
self.paint_sidebar_text(
layers,
&ui_font,
@@ -2308,44 +2327,9 @@ impl crate::TermWindow {
&group.label,
group_text_x,
text_y,
- name_avail,
+ text_avail,
header_fg,
)?;
- if let (Some((badge_w, badge_metrics)), Some(badge_font)) =
- (badge, &badge_font)
- {
- // Same height as the "+" button so the trailing
- // cluster reads as one aligned row of controls.
- let badge_h = group_action_size;
- let badge_x = group_action_x
- .saturating_sub(self.ui_px(SIDEBAR_INSET) / 2 + badge_w);
- let badge_y =
- y + ((session_row_height.saturating_sub(badge_h)) / 2);
- self.fill_rounded_rectangle(
- layers,
- 1,
- euclid::rect(
- badge_x as f32,
- badge_y as f32,
- badge_w as f32,
- badge_h as f32,
- ),
- chrome.sidebar_button_bg,
- self.ui_f32(SIDEBAR_ROW_RADIUS),
- )
- .context("sidebar ref group machine badge")?;
- let badge_cell_h = badge_metrics.cell_size.height as usize;
- self.paint_sidebar_text(
- layers,
- badge_font,
- badge_metrics,
- &group.machine_label,
- badge_x + badge_pad,
- badge_y + ((badge_h.saturating_sub(badge_cell_h)) / 2),
- badge_w.saturating_sub(badge_pad),
- header_fg,
- )?;
- }
// The group "+": create a thread in the origin project
// and auto-reference it here — same affordance as the
@@ -2396,10 +2380,8 @@ impl crate::TermWindow {
self.paint_sidebar_icon(
layers,
SvgIcon::Plus,
- group_action_x
- + ((group_action_size.saturating_sub(action_icon_size)) / 2),
- group_action_y
- + ((group_action_size.saturating_sub(action_icon_size)) / 2),
+ group_action_x + ((group_action_size.saturating_sub(action_icon_size)) / 2),
+ group_action_y + ((group_action_size.saturating_sub(action_icon_size)) / 2),
action_icon_size,
if group_action_hovered {
foreground
@@ -2456,7 +2438,7 @@ impl crate::TermWindow {
session_width,
session_row_height,
);
- let is_selected = self.is_workspace_sidebar_thread_selected(session);
+ let is_selected = self.is_workspace_sidebar_thread_selected(session, false);
let dimmed = reference.dangling || !reference.origin_domain_attached;
if is_selected {
self.fill_rounded_rectangle_with_border(
@@ -2490,8 +2472,7 @@ impl crate::TermWindow {
.context("sidebar hovered thread ref")?;
}
- let text_y =
- y + ((session_row_height.saturating_sub(ui_cell_height)) / 2);
+ let text_y = y + ((session_row_height.saturating_sub(ui_cell_height)) / 2);
let action_size = session_row_height.saturating_sub(8).clamp(
self.ui_px(SESSION_ACTION_MIN_SIZE),
self.ui_px(SESSION_ACTION_MAX_SIZE),
@@ -2499,8 +2480,7 @@ impl crate::TermWindow {
let delete_x = session_x
.saturating_add(session_width)
.saturating_sub(self.ui_px(SIDEBAR_INSET) + action_size);
- let action_y =
- y + ((session_row_height.saturating_sub(action_size)) / 2);
+ let action_y = y + ((session_row_height.saturating_sub(action_size)) / 2);
let text_right = if is_hovered {
delete_x
} else {
@@ -2517,6 +2497,7 @@ impl crate::TermWindow {
session_row_height,
&chrome,
foreground,
+ false,
)?;
}
let text_fg = if dimmed {
@@ -2533,8 +2514,7 @@ impl crate::TermWindow {
&session.name,
session_text_x,
text_y,
- text_right
- .saturating_sub(session_text_x + self.ui_px(SIDEBAR_INSET)),
+ text_right.saturating_sub(session_text_x + self.ui_px(SIDEBAR_INSET)),
text_fg,
)?;
@@ -2560,10 +2540,8 @@ impl crate::TermWindow {
self.paint_sidebar_icon(
layers,
SvgIcon::X,
- delete_x
- + ((action_size.saturating_sub(action_icon_size)) / 2),
- action_y
- + ((action_size.saturating_sub(action_icon_size)) / 2),
+ delete_x + ((action_size.saturating_sub(action_icon_size)) / 2),
+ action_y + ((action_size.saturating_sub(action_icon_size)) / 2),
action_icon_size,
if hovered {
foreground
@@ -2932,9 +2910,7 @@ impl crate::TermWindow {
let settings_label_fits = self
.cached_ui_text_advance(&ui_font, &ui_metrics, &settings_label)
.map(|advance| {
- settings_label_x_inset
- + (advance.ceil() as usize)
- + self.ui_px(SIDEBAR_INSET)
+ settings_label_x_inset + (advance.ceil() as usize) + self.ui_px(SIDEBAR_INSET)
<= settings_body_width
})
.unwrap_or(false);
diff --git a/wezterm-gui/src/workspace_threads.rs b/wezterm-gui/src/workspace_threads.rs
index c44eb180..51867633 100644
--- a/wezterm-gui/src/workspace_threads.rs
+++ b/wezterm-gui/src/workspace_threads.rs
@@ -201,25 +201,51 @@ pub struct TerminalSpawnSpec {
pub struct WorkspaceThreadsView {
pub pinned_threads: Vec<WorkspaceThreadView>,
pub projects: Vec<ProjectView>,
- /// Thread references this Space holds, grouped by origin machine so the
+ /// Thread references this Space holds, grouped by origin project so the
/// sidebar can render them as folder-style groups just like projects.
pub ref_groups: Vec<ThreadRefGroupView>,
}
+impl WorkspaceThreadsView {
+ /// True when the workspace on screen is one of this Space's thread
+ /// references. Activating a ref never repoints the Space's own
+ /// active-thread pointer, so while this holds, the own rows' `is_active`
+ /// is stale for SELECTION purposes — the paint side suppresses their
+ /// highlight (and only their highlight: the flag stays true in the data,
+ /// keeping the status-filter exemption and every other consumer intact).
+ pub fn ref_workspace_on_screen(&self) -> bool {
+ self.ref_groups.iter().any(|group| {
+ group
+ .threads
+ .iter()
+ .any(|reference| reference.thread.is_active)
+ })
+ }
+}
+
/// One folder-style group of thread references sharing an origin Space.
#[derive(Debug, Clone)]
pub struct ThreadRefGroupView {
- /// Stable group key: the origin Space id, or a machine-derived fallback
- /// for dangling refs whose origin rows are gone from the cache.
+ /// Stable group key: the origin project id, or a machine-derived
+ /// fallback for dangling refs whose origin rows are gone from the cache.
pub key: String,
- /// Header label: the origin Space's name (a machine hosts several
- /// Spaces, so the machine alone would be ambiguous). Dangling groups
- /// fall back to the cached machine label.
+ /// Header label: the origin project's name, so a ref folder reads
+ /// exactly like a local project folder. Dangling groups fall back to
+ /// the cached machine label.
pub label: String,
- /// The origin machine, shown as a small right-aligned badge on the
- /// header (hidden when it would not fit, or when it just repeats the
- /// label).
+ /// The origin machine. The header has no room for it, so it appears as
+ /// the row's hover tag.
pub machine_label: String,
+ /// Whether the origin machine is this device. Tracked structurally
+ /// rather than by comparing `machine_label` to "Local", because domain
+ /// names are user-controlled.
+ pub machine_is_local: bool,
+ /// The Space the origin project belongs to. Part of the hover tag: the
+ /// header shows only the project name, and project names repeat across
+ /// Spaces (every Space starts with a "Home"), so without this a
+ /// local-to-local ref folder would carry no identifying information at
+ /// all. Empty for a dangling group.
+ pub origin_space_name: String,
/// Whether the origin domain is currently attached; a detached group's
/// rows paint dimmed.
pub attached: bool,
@@ -258,16 +284,24 @@ pub struct WorkspaceThreadView {
/// vanished simply produces no view.
#[derive(Debug, Clone)]
// The origin fields are asserted by the store tests and reserved for row
-// painting polish (offline dimming, origin tooltips); the bin target does
-// not read them yet.
+// Some fields are read only by tests or kept for menu/navigation follow-ups
+// (e.g. `origin_space_id` for a go-to-origin action).
#[allow(dead_code)]
pub struct ThreadRefView {
pub thread: WorkspaceThreadView,
pub origin_space_id: SpaceId,
pub origin_space_name: String,
+ /// The project the thread lives in on its origin machine; the sidebar
+ /// groups refs under this name so ref folders read like local ones.
+ /// Empty for a dangling ref.
+ pub origin_project_id: ProjectId,
+ pub origin_project_name: String,
/// Short machine tag for the row: the origin Space's mux domain name
/// (which is the user's host label when one exists) or "Local".
pub machine_label: String,
+ /// Whether the origin machine is this device, tracked structurally so no
+ /// user-controlled domain name can pass for "Local".
+ pub machine_is_local: bool,
/// False when the origin Space's mux domain is currently detached; the
/// sidebar dims such rows.
pub origin_domain_attached: bool,
@@ -1123,18 +1157,22 @@ pub fn purge_thread_refs_for_machines(machines: &[String]) -> bool {
changed
}
-/// The origin project a reference group's "+" should create a thread in:
-/// the project of the first resolvable ref in `host_space_id`'s list whose
-/// origin Space is `origin_space_id`.
-pub fn ref_group_origin_project(host_space_id: &str, origin_space_id: &str) -> Option<ProjectId> {
+/// The origin project a reference group's "+" should create a thread in.
+/// Group keys are origin project ids, so this only confirms the key names
+/// the project of some resolvable ref in `host_space_id`'s list (a machine
+/// fallback key for dangling groups never matches).
+pub fn ref_group_origin_project(host_space_id: &str, group_key: &str) -> Option<ProjectId> {
let store = THREAD_STORE.lock();
- let space = store.spaces.iter().find(|space| space.id == host_space_id)?;
+ let space = store
+ .spaces
+ .iter()
+ .find(|space| space.id == host_space_id)?;
space.thread_refs.iter().find_map(|thread_id| {
let project = store
.projects
.iter()
.find(|project| project.threads.iter().any(|t| &t.id == thread_id))?;
- (project.space_id == origin_space_id).then(|| project.id.clone())
+ (project.id == group_key).then(|| project.id.clone())
})
}
@@ -1320,13 +1358,9 @@ fn delete_space_for_window_local(
.or_else(|| {
// A refs-only Space cannot rehome a window: it has no thread
// of its own for the window to adopt.
- store
- .spaces
- .iter()
- .find(|space| {
- !occupied_by_other.contains(&space.id)
- && !store.is_refs_only_space(&space.id)
- })
+ store.spaces.iter().find(|space| {
+ !occupied_by_other.contains(&space.id) && !store.is_refs_only_space(&space.id)
+ })
})
.map(|space| space.id.clone())
.unwrap_or_else(|| {
@@ -1487,13 +1521,9 @@ pub async fn delete_space_for_window(
.or_else(|| {
// A refs-only Space cannot rehome a window: it has no thread
// of its own for the window to adopt.
- store
- .spaces
- .iter()
- .find(|space| {
- !occupied_by_other.contains(&space.id)
- && !store.is_refs_only_space(&space.id)
- })
+ store.spaces.iter().find(|space| {
+ !occupied_by_other.contains(&space.id) && !store.is_refs_only_space(&space.id)
+ })
})
.map(|space| space.id.clone())
.unwrap_or_else(|| {
@@ -1596,7 +1626,10 @@ pub fn space_id_for_workspace(workspace: &str) -> Option<SpaceId> {
/// silently keep targeting the previous machine.
pub fn origin_space_for_ref_workspace(host_space_id: &str, workspace: &str) -> Option<SpaceId> {
let store = THREAD_STORE.lock();
- let space = store.spaces.iter().find(|space| space.id == host_space_id)?;
+ let space = store
+ .spaces
+ .iter()
+ .find(|space| space.id == host_space_id)?;
store.projects.iter().find_map(|project| {
project
.threads
@@ -1705,16 +1738,17 @@ pub fn view_for_current_project(
view
}
-/// Fold resolved refs into folder-style groups keyed by origin Space, in
-/// first-appearance order of the Space's ref list. Dangling refs (origin
-/// rows gone) group under their cached machine label instead.
+/// Fold resolved refs into folder-style groups keyed by origin project, in
+/// first-appearance order of the Space's ref list — so ref folders carry
+/// the same names as local project folders, with the machine as a badge.
+/// Dangling refs (origin rows gone) group under their cached machine label.
fn group_thread_refs_by_origin(refs: Vec<ThreadRefView>) -> Vec<ThreadRefGroupView> {
let mut groups: Vec<ThreadRefGroupView> = Vec::new();
for reference in refs {
- let key = if reference.origin_space_id.is_empty() {
+ let key = if reference.origin_project_id.is_empty() {
format!("machine::{}", reference.machine_label)
} else {
- reference.origin_space_id.clone()
+ reference.origin_project_id.clone()
};
match groups.iter_mut().find(|group| group.key == key) {
Some(group) => {
@@ -1723,12 +1757,14 @@ fn group_thread_refs_by_origin(refs: Vec<ThreadRefView>) -> Vec<ThreadRefGroupVi
}
None => groups.push(ThreadRefGroupView {
key,
- label: if reference.origin_space_name.is_empty() {
+ label: if reference.origin_project_name.is_empty() {
reference.machine_label.clone()
} else {
- reference.origin_space_name.clone()
+ reference.origin_project_name.clone()
},
machine_label: reference.machine_label.clone(),
+ machine_is_local: reference.machine_is_local,
+ origin_space_name: reference.origin_space_name.clone(),
attached: reference.origin_domain_attached,
collapsed: false,
threads: vec![reference],
@@ -3799,7 +3835,11 @@ impl WorkspaceThreadStore {
/// is no meta to render a row from (legacy pre-meta refs).
fn groom_thread_refs(&mut self) -> bool {
let mut resolved: HashMap<String, ThreadRefMeta> = HashMap::new();
- if self.spaces.iter().any(|space| !space.thread_refs.is_empty()) {
+ if self
+ .spaces
+ .iter()
+ .any(|space| !space.thread_refs.is_empty())
+ {
for project in &self.projects {
let origin_domain = self
.spaces
@@ -4159,7 +4199,10 @@ impl WorkspaceThreadStore {
},
origin_space_id: String::new(),
origin_space_name: String::new(),
+ origin_project_id: String::new(),
+ origin_project_name: String::new(),
machine_label: meta.machine_label(),
+ machine_is_local: meta.origin_domain.is_none(),
origin_domain_attached: false,
workspace_name: String::new(),
dangling: true,
@@ -4180,10 +4223,8 @@ impl WorkspaceThreadStore {
is_unread: session.is_unread,
work_status: session.work_status(),
};
- let machine_label = origin
- .client_domain
- .clone()
- .unwrap_or_else(|| "Local".to_string());
+ let (machine_label, machine_is_local) =
+ origin_machine_for_project(project, &self.spaces);
let origin_domain_attached = origin
.client_domain
.as_deref()
@@ -4193,7 +4234,10 @@ impl WorkspaceThreadStore {
thread,
origin_space_id: origin.id.clone(),
origin_space_name: origin.name.clone(),
+ origin_project_id: project.id.clone(),
+ origin_project_name: project.name.clone(),
machine_label,
+ machine_is_local,
origin_domain_attached,
workspace_name,
dangling: false,
@@ -6691,6 +6735,36 @@ fn is_remote_project(project: &Project, spaces: &[Space]) -> bool {
.any(|space| space.id == project.space_id && space.client_domain.is_some())
}
+/// Which machine a project's threads execute on, for display: the mux
+/// domain for a domain-owned Space, the SSH host for a direct-SSH project
+/// (which lives in a LOCAL Space, so the Space's `client_domain` alone
+/// misses it — same three-way test as `is_remote_project`), or this device.
+fn origin_machine_for_project(project: &Project, spaces: &[Space]) -> (String, bool) {
+ if let Some(domain) = spaces
+ .iter()
+ .find(|space| space.id == project.space_id)
+ .and_then(|space| space.client_domain.clone())
+ {
+ return (domain, false);
+ }
+ if is_remote_project(project, spaces) {
+ let host_id = remote_host_id_for_project_id(&project.id);
+ let label = crate::ssh_hosts::host_spec(host_id)
+ .map(|spec| spec.label)
+ .or_else(|| {
+ // `ssh://user@host/...` — the authority names the machine.
+ let path = project.path.to_string_lossy().into_owned();
+ let rest = path.strip_prefix("ssh://")?;
+ let authority = rest.split('/').next()?;
+ let host = authority.rsplit('@').next()?;
+ (!host.is_empty()).then(|| host.to_string())
+ })
+ .unwrap_or_else(|| project.name.clone());
+ return (label, false);
+ }
+ ("Local".to_string(), true)
+}
+
fn thread_has_restorable_workspace(thread: &WorkspaceThread) -> bool {
// Mux-domain threads have no local layout to restore: their content lives
// on the remote mux server and only materializes through `thinkterm connect`.
@@ -7313,7 +7387,10 @@ mod tests {
let mut occupied = std::collections::HashSet::new();
occupied.insert(DEFAULT_SPACE_ID.to_string());
let claimed = store.claim_available_space_id(&occupied);
- assert_ne!(claimed, coll_id, "startup window must not claim a refs-only Space");
+ assert_ne!(
+ claimed, coll_id,
+ "startup window must not claim a refs-only Space"
+ );
// Once emptied of refs it is an ordinary empty Space and claimable.
assert!(store.remove_thread_ref(&coll_id, &t1));
let claimed = store.claim_available_space_id(&occupied);
@@ -7324,7 +7401,10 @@ mod tests {
fn collection_refs_add_remove_reorder_dedup() {
let (mut store, coll, t1, t2) = store_with_collection();
assert!(store.add_thread_ref(&coll, &t1));
- assert!(!store.add_thread_ref(&coll, &t1), "duplicate ref must be refused");
+ assert!(
+ !store.add_thread_ref(&coll, &t1),
+ "duplicate ref must be refused"
+ );
assert!(store.add_thread_ref(&coll, &t2));
assert!(!store.add_thread_ref(&coll, "thread-nonexistent"));
@@ -7402,7 +7482,12 @@ mod tests {
.unwrap()
.is_collection = true;
// Reference a remote thread from the ingested tree.
- let remote_thread_id = store.projects.iter().find(|p| p.id == "rp1").unwrap().threads[0]
+ let remote_thread_id = store
+ .projects
+ .iter()
+ .find(|p| p.id == "rp1")
+ .unwrap()
+ .threads[0]
.id
.clone();
assert!(store.add_thread_ref(&coll_id, &remote_thread_id));
@@ -7437,7 +7522,10 @@ mod tests {
// remote delete) used to fall through to ensure_current_project.
store.sync_current_project(&coll, "some-unbound-workspace");
assert!(
- store.projects.iter().all(|project| project.space_id != coll),
+ store
+ .projects
+ .iter()
+ .all(|project| project.space_id != coll),
"a refs-only Space must never acquire a project"
);
}
@@ -7452,7 +7540,10 @@ mod tests {
assert!(!space.is_collection, "the flag is retired on normalize");
assert_eq!(space.thread_refs, vec![t1.clone()]);
assert_eq!(
- space.thread_ref_meta.get(&t1).map(|m| m.origin_domain.clone()),
+ space
+ .thread_ref_meta
+ .get(&t1)
+ .map(|m| m.origin_domain.clone()),
Some(None),
"normalize refreshes the cached meta for resolvable refs"
);
@@ -7476,10 +7567,20 @@ mod tests {
let mut store = remote_test_store("syd");
assert!(store.ingest_remote_tree("syd", &sample_tree()));
let host = store.create_space_record("Studies".to_string());
- let remote_thread = store.projects.iter().find(|p| p.id == "rp1").unwrap().threads[0]
+ let remote_thread = store
+ .projects
+ .iter()
+ .find(|p| p.id == "rp1")
+ .unwrap()
+ .threads[0]
.id
.clone();
- let remote_name = store.projects.iter().find(|p| p.id == "rp1").unwrap().threads[0]
+ let remote_name = store
+ .projects
+ .iter()
+ .find(|p| p.id == "rp1")
+ .unwrap()
+ .threads[0]
.name
.clone();
assert!(store.add_thread_ref(&host, &remote_thread));
@@ -7525,7 +7626,12 @@ mod tests {
let mut store = remote_test_store("syd");
assert!(store.ingest_remote_tree("syd", &sample_tree()));
let host = store.create_space_record("Studies".to_string());
- let remote_thread = store.projects.iter().find(|p| p.id == "rp1").unwrap().threads[0]
+ let remote_thread = store
+ .projects
+ .iter()
+ .find(|p| p.id == "rp1")
+ .unwrap()
+ .threads[0]
.id
.clone();
// One ref to the doomed machine, one local ref that must survive.
@@ -7547,7 +7653,10 @@ mod tests {
let space = store.spaces.iter().find(|s| s.id == host).unwrap();
assert_eq!(space.thread_refs, vec![local_id.clone()]);
assert!(!space.thread_ref_meta.contains_key(&remote_thread));
- assert_eq!(space.active_thread_ref, None, "purged ref cannot stay active");
+ assert_eq!(
+ space.active_thread_ref, None,
+ "purged ref cannot stay active"
+ );
assert!(
!store.purge_refs_for_machines(&["syd".to_string()]),
"second purge is a no-op"
@@ -7576,7 +7685,10 @@ mod tests {
.find(|s| s.id == host)
.unwrap()
.active_thread_ref = Some(t1.clone());
- assert_eq!(store.thread_ref_to_restore(&host).as_deref(), Some(t1.as_str()));
+ assert_eq!(
+ store.thread_ref_to_restore(&host).as_deref(),
+ Some(t1.as_str())
+ );
}
#[test]
@@ -7585,7 +7697,10 @@ mod tests {
assert!(store.add_thread_ref(&coll, &t1));
assert!(store.add_thread_ref(&coll, &t2));
// Nothing opened yet: fall back to the first reference.
- assert_eq!(store.thread_ref_to_restore(&coll).as_deref(), Some(t1.as_str()));
+ assert_eq!(
+ store.thread_ref_to_restore(&coll).as_deref(),
+ Some(t1.as_str())
+ );
store
.spaces
@@ -7593,13 +7708,19 @@ mod tests {
.find(|s| s.id == coll)
.unwrap()
.active_thread_ref = Some(t2.clone());
- assert_eq!(store.thread_ref_to_restore(&coll).as_deref(), Some(t2.as_str()));
+ assert_eq!(
+ store.thread_ref_to_restore(&coll).as_deref(),
+ Some(t2.as_str())
+ );
// Removing the remembered reference clears it and falls back.
assert!(store.remove_thread_ref(&coll, &t2));
let space = store.spaces.iter().find(|s| s.id == coll).unwrap();
assert_eq!(space.active_thread_ref, None);
- assert_eq!(store.thread_ref_to_restore(&coll).as_deref(), Some(t1.as_str()));
+ assert_eq!(
+ store.thread_ref_to_restore(&coll).as_deref(),
+ Some(t1.as_str())
+ );
}
#[test]
@@ -9282,6 +9403,89 @@ mod tests {
assert!(view.projects[1].threads[0].is_active);
}
+ /// Activating a ref never repoints the space's own active-thread pointer,
+ /// so while the ref's workspace is on screen the own pointer is stale for
+ /// selection purposes. The paint side asks the built view whether that is
+ /// the case; the answer must key off the DISPLAYED workspace, not off
+ /// "some other Space owns it" — a swipe preview renders a neighbouring
+ /// Space against this window's workspace and must not blank the
+ /// neighbour's own highlight.
+ #[test]
+ fn ref_workspace_on_screen_tracks_the_displayed_workspace() {
+ let mut store = remote_test_store("syd");
+ assert!(store.ingest_remote_tree("syd", &sample_tree()));
+ let local_space = store.spaces[0].id.clone();
+ assert!(store.add_thread_ref(&local_space, "rt1"));
+
+ let ref_workspace = store.view_for_thread_refs(&local_space, &[], None)[0]
+ .workspace_name
+ .clone();
+
+ // The ref's workspace is on screen: the view reports it, so the
+ // paint side suppresses the own rows' highlight.
+ let mut view = WorkspaceThreadsView {
+ pinned_threads: Vec::new(),
+ projects: Vec::new(),
+ ref_groups: group_thread_refs_by_origin(store.view_for_thread_refs(
+ &local_space,
+ &[],
+ Some(&ref_workspace),
+ )),
+ };
+ assert!(view.ref_workspace_on_screen());
+
+ // Any other workspace on screen — including another Space's, as
+ // during a swipe preview — and the suppression must not engage.
+ view.ref_groups = group_thread_refs_by_origin(store.view_for_thread_refs(
+ &local_space,
+ &[],
+ Some("some-other-space's-workspace"),
+ ));
+ assert!(!view.ref_workspace_on_screen());
+ }
+
+ /// Suppression lives in the paint-side selection, NOT in the view data:
+ /// the status filter exempts the active thread from hiding, and that
+ /// exemption must survive a ref being on screen or the Space's own
+ /// active row vanishes from the list (shifting scroll height and
+ /// hit-test rows) whenever its status is hidden.
+ #[test]
+ fn status_filter_still_exempts_the_own_active_row_while_a_ref_is_open() {
+ let make = |name: &str, is_active| WorkspaceThreadView {
+ id: name.to_string(),
+ name: name.to_string(),
+ is_active,
+ is_materialized: false,
+ is_pinned: false,
+ is_unread: false,
+ work_status: WorkspaceThreadWorkStatus::Idle,
+ };
+ let mut view = WorkspaceThreadsView {
+ pinned_threads: Vec::new(),
+ projects: vec![ProjectView {
+ id: "p1".to_string(),
+ name: "Home".to_string(),
+ is_active: true,
+ threads_collapsed: false,
+ threads: vec![make("own-active", true), make("own-idle", false)],
+ is_remote: false,
+ distro: None,
+ }],
+ ref_groups: Vec::new(),
+ };
+ filter_threads_view_by_status(&mut view, &[WorkspaceThreadWorkStatus::Idle]);
+ let names: Vec<&str> = view.projects[0]
+ .threads
+ .iter()
+ .map(|thread| thread.name.as_str())
+ .collect();
+ assert_eq!(
+ names,
+ vec!["own-active"],
+ "the active row is exempt from status hiding; is_active must stay in the data"
+ );
+ }
+
#[test]
fn project_menu_metadata_actions_update_store() {
let space_id = default_space_id();