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.

Add workspace thread notifications and status filters

RoversX41d06a43a9ba
diff --git a/wezterm-gui/src/native_settings.rs b/wezterm-gui/src/native_settings.rs
index c6314231..12b0b315 100644
--- a/wezterm-gui/src/native_settings.rs
+++ b/wezterm-gui/src/native_settings.rs
@@ -201,6 +201,9 @@ pub(crate) struct NativeChromeSettings {
pub(crate) right_sidebar_custom_open_with_apps: Vec<NativeOpenWithApp>,
pub(crate) tab_font_size: Option<f64>,
pub(crate) pane_header_font_size: Option<f64>,
+ /// Workspace-thread statuses hidden by the sidebar view-options filter,
+ /// as stable keys ("idle", "running", "needs-attention", "finished").
+ pub(crate) workspace_sidebar_hidden_statuses: Vec<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
@@ -476,6 +479,16 @@ pub(crate) fn right_sidebar_open_with_app() -> Option<NativeOpenWithApp> {
load().chrome.right_sidebar_open_with_app
}
+pub(crate) fn workspace_sidebar_hidden_statuses() -> Vec<String> {
+ load().chrome.workspace_sidebar_hidden_statuses
+}
+
+pub(crate) fn save_workspace_sidebar_hidden_statuses(hidden: Vec<String>) -> anyhow::Result<()> {
+ let mut settings = load();
+ settings.chrome.workspace_sidebar_hidden_statuses = hidden;
+ save(&settings)
+}
+
pub(crate) fn force_fallback_context_menu() -> bool {
std::env::var_os("THINKTERM_FORCE_FALLBACK_CONTEXT_MENU").is_some()
|| load().developer.force_fallback_context_menu
diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rs
index 5b1585b2..74607734 100644
--- a/wezterm-gui/src/termwindow/mod.rs
+++ b/wezterm-gui/src/termwindow/mod.rs
@@ -287,6 +287,14 @@ pub(crate) enum NoteEditorCommand {
#[derive(Clone, Debug)]
pub(crate) enum ContextMenuApplicationAction {
Note(NoteEditorCommand),
+ /// Notification bell entry: jump to a thread, switching Space first when
+ /// it lives elsewhere, and acknowledge its unseen work.
+ ActivateWorkspaceThread {
+ space_id: String,
+ thread_id: String,
+ },
+ /// Sidebar view-options: show/hide threads with this work status.
+ ToggleWorkspaceStatusFilter(crate::workspace_threads::WorkspaceThreadWorkStatus),
}
#[derive(Clone, Debug, PartialEq, Eq)]
diff --git a/wezterm-gui/src/termwindow/mouseevent.rs b/wezterm-gui/src/termwindow/mouseevent.rs
index 95523835..b0764d42 100644
--- a/wezterm-gui/src/termwindow/mouseevent.rs
+++ b/wezterm-gui/src/termwindow/mouseevent.rs
@@ -2169,7 +2169,7 @@ impl super::TermWindow {
self.mouse_event_workspace_sidebar_view_options(item, event, context);
}
UIItemType::WorkspaceSidebarNotifications => {
- context.set_cursor(Some(MouseCursor::Hand));
+ self.mouse_event_workspace_sidebar_notifications(item.clone(), event, context);
}
UIItemType::ContextMenuBackdrop => {
context.set_cursor(Some(MouseCursor::Arrow));
@@ -2555,7 +2555,7 @@ impl super::TermWindow {
self.mouse_event_workspace_sidebar_view_options(item, event, context);
}
UIItemType::WorkspaceSidebarNotifications => {
- context.set_cursor(Some(MouseCursor::Hand));
+ self.mouse_event_workspace_sidebar_notifications(item.clone(), event, context);
}
UIItemType::RightSidebarToggle => {
self.mouse_event_right_sidebar_toggle(event, context);
@@ -3147,11 +3147,8 @@ impl super::TermWindow {
item.x.saturating_add(item.width) as isize,
item.y.saturating_add(item.height / 2) as isize,
);
- self.show_term_context_menu(
- context,
- coords,
- self.workspace_sidebar_view_options_menu_items(),
- );
+ let items = self.workspace_sidebar_view_options_menu_items();
+ self.show_term_context_menu(context, coords, items);
}
}
@@ -3600,8 +3597,48 @@ impl super::TermWindow {
items
}
- fn workspace_sidebar_view_options_menu_items(&self) -> Vec<ContextMenuItem> {
+ fn workspace_sidebar_view_options_menu_items(&mut self) -> Vec<ContextMenuItem> {
use config::keyassignment::KeyAssignment;
+ use crate::workspace_threads::WorkspaceThreadWorkStatus;
+
+ self.begin_context_menu_application_actions();
+ let hidden = crate::native_settings::workspace_sidebar_hidden_statuses();
+ let mut status_items = Vec::new();
+ for (label, icon, status) in [
+ (
+ "Running",
+ ContextMenuIcon::Refresh,
+ WorkspaceThreadWorkStatus::Running,
+ ),
+ (
+ "Needs Attention",
+ ContextMenuIcon::Warning,
+ WorkspaceThreadWorkStatus::NeedsAttention,
+ ),
+ (
+ "Done",
+ ContextMenuIcon::Check,
+ WorkspaceThreadWorkStatus::FinishedUnseen,
+ ),
+ (
+ "Idle",
+ ContextMenuIcon::Info,
+ WorkspaceThreadWorkStatus::Idle,
+ ),
+ ] {
+ let visible = !hidden.iter().any(|key| key == status.settings_key());
+ status_items.push(
+ self.context_menu_application_item_with_icon(
+ label,
+ icon,
+ crate::termwindow::ContextMenuApplicationAction::ToggleWorkspaceStatusFilter(
+ status,
+ ),
+ true,
+ )
+ .checked(visible),
+ );
+ }
vec![
ContextMenuItem::item_with_icon("Group by", ContextMenuIcon::Stack, KeyAssignment::Nop)
@@ -3616,57 +3653,94 @@ impl super::TermWindow {
ContextMenuItem::Separator,
ContextMenuItem::item_with_icon("Show", ContextMenuIcon::Info, KeyAssignment::Nop)
.disabled(),
- ContextMenuItem::submenu_with_icon(
- "Status",
- ContextMenuIcon::Check,
- vec![
- ContextMenuItem::item_with_icon(
- "Running",
- ContextMenuIcon::Refresh,
- KeyAssignment::Nop,
- )
- .checked(true)
- .disabled(),
- ContextMenuItem::item_with_icon(
- "Needs Attention",
- ContextMenuIcon::Warning,
- KeyAssignment::Nop,
- )
- .checked(true)
- .disabled(),
- ContextMenuItem::item_with_icon(
- "Done",
- ContextMenuIcon::Check,
- KeyAssignment::Nop,
- )
- .checked(true)
- .disabled(),
- ],
- ),
- ContextMenuItem::item_with_icon(
- "Unread",
+ ContextMenuItem::submenu_with_icon("Status", ContextMenuIcon::Check, status_items),
+ ]
+ }
+
+ /// Toggle a status's visibility in the workspace sidebar, refusing the
+ /// toggle that would hide every status and leave the list empty.
+ pub(crate) fn toggle_workspace_sidebar_status_filter(
+ &mut self,
+ status: crate::workspace_threads::WorkspaceThreadWorkStatus,
+ ) {
+ let mut hidden = crate::native_settings::workspace_sidebar_hidden_statuses();
+ let key = status.settings_key();
+ if let Some(index) = hidden.iter().position(|entry| entry == key) {
+ hidden.remove(index);
+ } else {
+ hidden.push(key.to_string());
+ let parsed = hidden
+ .iter()
+ .filter_map(|entry| {
+ crate::workspace_threads::WorkspaceThreadWorkStatus::from_settings_key(entry)
+ })
+ .collect::<Vec<_>>();
+ if crate::workspace_threads::hidden_statuses_cover_all(&parsed) {
+ return;
+ }
+ }
+ if let Err(err) = crate::native_settings::save_workspace_sidebar_hidden_statuses(hidden) {
+ log::warn!("failed to save sidebar status filter: {err:#}");
+ }
+ self.invalidate_window();
+ }
+
+ /// The notification bell: pending finished/attention threads across every
+ /// Space; activating an entry jumps to that thread.
+ pub fn mouse_event_workspace_sidebar_notifications(
+ &mut self,
+ item: UIItem,
+ event: MouseEvent,
+ context: &dyn WindowOps,
+ ) {
+ use config::keyassignment::KeyAssignment;
+
+ context.set_cursor(Some(MouseCursor::Hand));
+ if event.kind != WMEK::Press(MousePress::Left) {
+ return;
+ }
+ let coords = window::Point::new(
+ item.x.saturating_add(item.width) as isize,
+ item.y.saturating_add(item.height / 2) as isize,
+ );
+ let notifications = crate::workspace_threads::pending_work_notifications();
+ self.begin_context_menu_application_actions();
+ let items = if notifications.is_empty() {
+ vec![ContextMenuItem::item_with_icon(
+ "No notifications",
ContextMenuIcon::Notification,
KeyAssignment::Nop,
)
- .checked(true)
- .disabled(),
- ContextMenuItem::item_with_icon("Pinned", ContextMenuIcon::Pin, KeyAssignment::Nop)
- .checked(true)
- .disabled(),
- ContextMenuItem::Separator,
- ContextMenuItem::item_with_icon(
- "Collapse All",
- ContextMenuIcon::Collapse,
- KeyAssignment::Nop,
- )
- .disabled(),
- ContextMenuItem::item_with_icon(
- "Mark All Read",
- ContextMenuIcon::Check,
- KeyAssignment::Nop,
- )
- .disabled(),
- ]
+ .disabled()]
+ } else {
+ notifications
+ .into_iter()
+ .map(|notification| {
+ let icon = match notification.status {
+ crate::workspace_threads::WorkspaceThreadWorkStatus::NeedsAttention => {
+ ContextMenuIcon::Warning
+ }
+ _ => ContextMenuIcon::Check,
+ };
+ let label = format!(
+ "{} — {} · {}",
+ notification.thread_name,
+ notification.project_name,
+ notification.space_name
+ );
+ self.context_menu_application_item_with_icon(
+ label,
+ icon,
+ crate::termwindow::ContextMenuApplicationAction::ActivateWorkspaceThread {
+ space_id: notification.space_id,
+ thread_id: notification.thread_id,
+ },
+ true,
+ )
+ })
+ .collect()
+ };
+ self.show_term_context_menu(context, coords, items);
}
fn open_remote_workspace_thread_without_connecting(
diff --git a/wezterm-gui/src/termwindow/ui/context_menu.rs b/wezterm-gui/src/termwindow/ui/context_menu.rs
index 08b99969..4701c256 100644
--- a/wezterm-gui/src/termwindow/ui/context_menu.rs
+++ b/wezterm-gui/src/termwindow/ui/context_menu.rs
@@ -193,6 +193,31 @@ impl crate::TermWindow {
crate::termwindow::ContextMenuApplicationAction::Note(command) => {
self.perform_right_sidebar_note_command(command);
}
+ crate::termwindow::ContextMenuApplicationAction::ActivateWorkspaceThread {
+ space_id,
+ thread_id,
+ } => {
+ let Some(window) = self.window.clone() else {
+ return;
+ };
+ // One activation of exactly the notified thread; letting
+ // switch_space start the Space's recorded thread first can
+ // land on the wrong thread when activation is asynchronous.
+ let navigated =
+ self.switch_space_to_thread(space_id, Some(thread_id.clone()), &window);
+ // A Space owned by another window cannot be navigated from
+ // here; keep the notification so the click is not lost.
+ if navigated
+ && crate::workspace_threads::acknowledge_thread_work_for_thread(&thread_id)
+ {
+ self.invalidate_window();
+ }
+ }
+ crate::termwindow::ContextMenuApplicationAction::ToggleWorkspaceStatusFilter(
+ status,
+ ) => {
+ self.toggle_workspace_sidebar_status_filter(status);
+ }
}
}
diff --git a/wezterm-gui/src/termwindow/ui/sidebar.rs b/wezterm-gui/src/termwindow/ui/sidebar.rs
index f2765770..0b0d54e2 100644
--- a/wezterm-gui/src/termwindow/ui/sidebar.rs
+++ b/wezterm-gui/src/termwindow/ui/sidebar.rs
@@ -277,6 +277,25 @@ impl crate::TermWindow {
}
}
+ /// Apply the persisted view-options status filter. Must run everywhere a
+ /// `WorkspaceThreadsView` feeds the sidebar (paint, scroll height, hit
+ /// testing) or row math diverges from the painted rows.
+ fn apply_workspace_thread_status_filter(
+ &self,
+ mut view: workspace_threads::WorkspaceThreadsView,
+ ) -> workspace_threads::WorkspaceThreadsView {
+ let hidden = crate::native_settings::workspace_sidebar_hidden_statuses()
+ .iter()
+ .filter_map(|key| {
+ workspace_threads::WorkspaceThreadWorkStatus::from_settings_key(key)
+ })
+ .collect::<Vec<_>>();
+ if !hidden.is_empty() {
+ workspace_threads::filter_threads_view_by_status(&mut view, &hidden);
+ }
+ view
+ }
+
fn sidebar_thread_status_kind(
&self,
session: &workspace_threads::WorkspaceThreadView,
@@ -573,10 +592,12 @@ impl crate::TermWindow {
.current_mux_workspace()
.unwrap_or_else(|| mux.active_workspace());
let workspaces = mux.iter_workspaces();
- let view = workspace_threads::view_for_current_project(
- &self.active_space_id,
- &active_workspace,
- &workspaces,
+ let view = self.apply_workspace_thread_status_filter(
+ workspace_threads::view_for_current_project(
+ &self.active_space_id,
+ &active_workspace,
+ &workspaces,
+ ),
);
let row_gap = self.ui_px(SIDEBAR_ROW_GAP);
let total_height = Self::workspace_sidebar_scroll_height(
@@ -620,10 +641,12 @@ impl crate::TermWindow {
.current_mux_workspace()
.unwrap_or_else(|| mux.active_workspace());
let workspaces = mux.iter_workspaces();
- let view = workspace_threads::view_for_current_project(
- &self.active_space_id,
- &active_workspace,
- &workspaces,
+ let view = self.apply_workspace_thread_status_filter(
+ workspace_threads::view_for_current_project(
+ &self.active_space_id,
+ &active_workspace,
+ &workspaces,
+ ),
);
let row_gap = self.ui_px(SIDEBAR_ROW_GAP);
let total_height = Self::workspace_sidebar_scroll_height(
@@ -838,10 +861,12 @@ impl crate::TermWindow {
.current_mux_workspace()
.unwrap_or_else(|| mux.active_workspace());
let workspaces = mux.iter_workspaces();
- let view = workspace_threads::view_for_current_project(
- &self.active_space_id,
- &active_workspace,
- &workspaces,
+ let view = self.apply_workspace_thread_status_filter(
+ workspace_threads::view_for_current_project(
+ &self.active_space_id,
+ &active_workspace,
+ &workspaces,
+ ),
);
let header_icon_size = icon_size.min(self.ui_px(32));
@@ -1225,6 +1250,24 @@ impl crate::TermWindow {
muted_fg
},
)?;
+ if workspace_threads::pending_work_notification_count() > 0 {
+ // Unread badge; reuses the attention hue the Space indicators use.
+ let badge_size = self.ui_px(8).max(4);
+ self.fill_rounded_rectangle(
+ layers,
+ 2,
+ euclid::rect(
+ (notification_action_x + notification_action_size)
+ .saturating_sub(badge_size + self.ui_px(6)) as f32,
+ (notification_action_y + self.ui_px(6)) as f32,
+ badge_size as f32,
+ badge_size as f32,
+ ),
+ SPACE_DISCONNECTED_COLOR,
+ badge_size as f32 / 2.0,
+ )
+ .context("sidebar notification badge")?;
+ }
let list_top = layout.list_top;
let row_gap = self.ui_px(SIDEBAR_ROW_GAP);
let max_scroll = {
diff --git a/wezterm-gui/src/workspace_threads.rs b/wezterm-gui/src/workspace_threads.rs
index e296d057..611f239a 100644
--- a/wezterm-gui/src/workspace_threads.rs
+++ b/wezterm-gui/src/workspace_threads.rs
@@ -178,6 +178,44 @@ pub enum WorkspaceThreadWorkStatus {
FinishedUnseen,
}
+impl WorkspaceThreadWorkStatus {
+ pub const ALL: [Self; 4] = [
+ Self::Idle,
+ Self::Running,
+ Self::NeedsAttention,
+ Self::FinishedUnseen,
+ ];
+
+ /// Stable identifier used to persist sidebar status filters.
+ pub fn settings_key(self) -> &'static str {
+ match self {
+ Self::Idle => "idle",
+ Self::Running => "running",
+ Self::NeedsAttention => "needs-attention",
+ Self::FinishedUnseen => "finished",
+ }
+ }
+
+ pub fn from_settings_key(key: &str) -> Option<Self> {
+ Self::ALL
+ .iter()
+ .copied()
+ .find(|status| status.settings_key() == key)
+ }
+}
+
+/// A thread whose work finished without being seen or needs attention,
+/// across every Space; feeds the sidebar notification bell.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct ThreadWorkNotification {
+ pub space_id: SpaceId,
+ pub space_name: String,
+ pub project_name: String,
+ pub thread_id: WorkspaceThreadId,
+ pub thread_name: String,
+ pub status: WorkspaceThreadWorkStatus,
+}
+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
struct WorkspaceThreadWorkChange {
changed: bool,
@@ -1100,6 +1138,55 @@ pub fn acknowledge_thread_work_for_workspace(workspace: &str) -> bool {
change.changed
}
+/// Clear the unseen/attention flags of one thread by id (used when a
+/// notification entry is activated from the bell menu).
+pub fn acknowledge_thread_work_for_thread(thread_id: &str) -> bool {
+ let mut store = THREAD_STORE.lock();
+ let change = store.acknowledge_thread_work_for_thread(thread_id);
+ if change.should_persist {
+ persist_locked(&store);
+ }
+ change.changed
+}
+
+/// Threads across every Space whose work needs attention or finished without
+/// being seen. NeedsAttention entries sort first.
+pub fn pending_work_notifications() -> Vec<ThreadWorkNotification> {
+ let mut store = THREAD_STORE.lock();
+ if store.normalize_after_load() {
+ persist_locked(&store);
+ }
+ store.pending_work_notifications()
+}
+
+pub fn pending_work_notification_count() -> usize {
+ let store = THREAD_STORE.lock();
+ store.pending_work_notification_count()
+}
+
+/// Drop threads whose status is hidden by the sidebar view options. The
+/// active thread is always kept so the row the user is looking at cannot
+/// vanish from under them.
+pub fn filter_threads_view_by_status(
+ view: &mut WorkspaceThreadsView,
+ hidden: &[WorkspaceThreadWorkStatus],
+) {
+ let keep =
+ |thread: &WorkspaceThreadView| thread.is_active || !hidden.contains(&thread.work_status);
+ view.pinned_threads.retain(keep);
+ for project in &mut view.projects {
+ project.threads.retain(keep);
+ }
+}
+
+/// Guard for the view-options menu: refuse a toggle that would hide every
+/// status and leave the sidebar inexplicably empty.
+pub fn hidden_statuses_cover_all(hidden: &[WorkspaceThreadWorkStatus]) -> bool {
+ WorkspaceThreadWorkStatus::ALL
+ .iter()
+ .all(|status| hidden.contains(status))
+}
+
pub fn acknowledge_thread_work_for_workspace_deferred(workspace: &str) -> bool {
let mut store = THREAD_STORE.lock();
let change = store.acknowledge_thread_work_for_workspace(workspace);
@@ -2677,6 +2764,75 @@ impl WorkspaceThreadStore {
}
}
+ fn acknowledge_thread_work_for_thread(&mut self, thread_id: &str) -> WorkspaceThreadWorkChange {
+ for project in &mut self.projects {
+ for session in &mut project.threads {
+ if session.id == thread_id {
+ let should_persist = session.work_finished_unseen;
+ let changed = session.work_needs_attention || session.work_finished_unseen;
+ session.work_needs_attention = false;
+ session.work_finished_unseen = false;
+ return WorkspaceThreadWorkChange {
+ changed,
+ should_persist,
+ };
+ }
+ }
+ }
+ WorkspaceThreadWorkChange {
+ changed: false,
+ should_persist: false,
+ }
+ }
+
+ fn pending_work_notifications(&self) -> Vec<ThreadWorkNotification> {
+ let mut notifications = Vec::new();
+ for project in &self.projects {
+ let space_name = self
+ .spaces
+ .iter()
+ .find(|space| space.id == project.space_id)
+ .map(|space| space.name.clone())
+ .unwrap_or_default();
+ for session in &project.threads {
+ let status = session.work_status();
+ if matches!(
+ status,
+ WorkspaceThreadWorkStatus::NeedsAttention
+ | WorkspaceThreadWorkStatus::FinishedUnseen
+ ) {
+ notifications.push(ThreadWorkNotification {
+ space_id: project.space_id.clone(),
+ space_name: space_name.clone(),
+ project_name: project.name.clone(),
+ thread_id: session.id.clone(),
+ thread_name: session.name.clone(),
+ status,
+ });
+ }
+ }
+ }
+ notifications.sort_by_key(|notification| match notification.status {
+ WorkspaceThreadWorkStatus::NeedsAttention => 0,
+ _ => 1,
+ });
+ notifications
+ }
+
+ fn pending_work_notification_count(&self) -> usize {
+ self.projects
+ .iter()
+ .flat_map(|project| project.threads.iter())
+ .filter(|session| {
+ matches!(
+ session.work_status(),
+ WorkspaceThreadWorkStatus::NeedsAttention
+ | WorkspaceThreadWorkStatus::FinishedUnseen
+ )
+ })
+ .count()
+ }
+
fn thread_workspace_names(&self) -> Vec<String> {
let mut names = Vec::new();
for project in &self.projects {
@@ -4713,6 +4869,108 @@ mod tests {
);
}
+ #[test]
+ fn pending_notifications_list_attention_first_and_skip_idle_running() {
+ let mut store = test_store();
+ let mut finished = WorkspaceThread::new(
+ "project-1".to_string(),
+ "done".to_string(),
+ Some("workspace-1".to_string()),
+ );
+ finished.work_finished_unseen = true;
+ let mut attention = WorkspaceThread::new(
+ "project-1".to_string(),
+ "stuck".to_string(),
+ Some("workspace-2".to_string()),
+ );
+ attention.work_needs_attention = true;
+ let mut running = WorkspaceThread::new(
+ "project-1".to_string(),
+ "busy".to_string(),
+ Some("workspace-3".to_string()),
+ );
+ running.work_is_running = true;
+ let idle = WorkspaceThread::new(
+ "project-1".to_string(),
+ "quiet".to_string(),
+ Some("workspace-4".to_string()),
+ );
+ store.projects.push(test_project(
+ "project-1",
+ "thinkterm",
+ PathBuf::from("/tmp/thinkterm"),
+ vec![finished, attention, running, idle],
+ ));
+
+ let notifications = store.pending_work_notifications();
+ assert_eq!(notifications.len(), 2);
+ assert_eq!(notifications[0].thread_name, "stuck");
+ assert_eq!(
+ notifications[0].status,
+ WorkspaceThreadWorkStatus::NeedsAttention
+ );
+ assert_eq!(notifications[1].thread_name, "done");
+ assert_eq!(notifications[0].project_name, "thinkterm");
+ assert_eq!(notifications[0].space_id, default_space_id());
+ assert!(!notifications[0].space_name.is_empty());
+ assert_eq!(store.pending_work_notification_count(), 2);
+
+ let thread_id = notifications[1].thread_id.clone();
+ let change = store.acknowledge_thread_work_for_thread(&thread_id);
+ assert!(change.changed);
+ assert!(change.should_persist);
+ assert_eq!(store.pending_work_notification_count(), 1);
+ // Running state is runtime truth and must survive acknowledgement.
+ assert!(store.projects[0].threads[2].work_is_running);
+ }
+
+ #[test]
+ fn status_filter_hides_threads_but_never_the_active_one() {
+ let hidden = [WorkspaceThreadWorkStatus::Idle];
+ let make = |name: &str, status, is_active| WorkspaceThreadView {
+ id: name.to_string(),
+ name: name.to_string(),
+ is_active,
+ is_materialized: true,
+ is_pinned: false,
+ is_unread: false,
+ work_status: status,
+ };
+ let mut view = WorkspaceThreadsView {
+ pinned_threads: vec![make("pinned-idle", WorkspaceThreadWorkStatus::Idle, false)],
+ projects: vec![ProjectView {
+ id: "p".to_string(),
+ name: "p".to_string(),
+ is_active: true,
+ threads_collapsed: false,
+ threads: vec![
+ make("active-idle", WorkspaceThreadWorkStatus::Idle, true),
+ make("idle", WorkspaceThreadWorkStatus::Idle, false),
+ make("running", WorkspaceThreadWorkStatus::Running, false),
+ ],
+ is_remote: false,
+ distro: None,
+ }],
+ };
+ filter_threads_view_by_status(&mut view, &hidden);
+ assert!(view.pinned_threads.is_empty());
+ let names: Vec<_> = view.projects[0]
+ .threads
+ .iter()
+ .map(|thread| thread.name.as_str())
+ .collect();
+ assert_eq!(names, ["active-idle", "running"]);
+
+ assert!(!hidden_statuses_cover_all(&hidden));
+ assert!(hidden_statuses_cover_all(&WorkspaceThreadWorkStatus::ALL));
+ for status in WorkspaceThreadWorkStatus::ALL {
+ assert_eq!(
+ WorkspaceThreadWorkStatus::from_settings_key(status.settings_key()),
+ Some(status)
+ );
+ }
+ }
+
#[test]
fn acknowledged_finished_work_persists_but_runtime_running_state_does_not() {
let mut store = test_store();