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
feat(gui): show each thread's programs and status in the sidebar
RoversX36230ae222a4
diff --git a/thinkterm-i18n/i18n/de-DE.ftl b/thinkterm-i18n/i18n/de-DE.ftlindex 350c35ab..f78cfc69 100644--- a/thinkterm-i18n/i18n/de-DE.ftl+++ b/thinkterm-i18n/i18n/de-DE.ftl@@ -131,6 +131,21 @@ settings-mac-glass-clear = Klares Glassettings-mac-glass-clear-over-blur = Klar + Unschärfesettings-sidebar-shade = Farbe der Seitenleistensettings-sidebar-shade-description = Wie dunkel beide Seitenleisten sind, in einem durchscheinenden Fenster.+settings-appearance-sidebar-heading = Symbole und Status+settings-thread-icons = Thread-Symbole+settings-thread-icons-description = Wie ein Thread die Programme seiner Panes zeigt, in der Seitenleiste und in „Thread finden“.+settings-thread-icons-badge = Plakette+settings-thread-icons-coins = Stapel+settings-thread-icons-cluster = Gruppe+settings-thread-icons-trailing = Am Ende+settings-thread-status = Status in der Seitenleiste+settings-thread-status-description = Wie Threads zeigen, dass sie arbeiten oder auf Sie warten, in der Seitenleiste und in „Thread finden“.+settings-thread-status-ring = Ring+settings-thread-status-pulse = Puls+settings-thread-status-pixels = Pixel+settings-thread-status-dots = Punkte+settings-agents-status = Agents-Status+settings-agents-status-description = Wie Agents zeigen, dass sie arbeiten oder auf Sie warten, im Agents-Bereich und in den Hover-Karten.settings-tab-bar-shade = Farbe der Tableistensettings-tab-bar-shade-description = Wie dunkel beide Tableisten sind, in einem durchscheinenden Fenster.settings-terminal-shade = Farbe des Terminalsdiff --git a/thinkterm-i18n/i18n/en-US.ftl b/thinkterm-i18n/i18n/en-US.ftlindex cad663ce..7891d5fd 100644--- a/thinkterm-i18n/i18n/en-US.ftl+++ b/thinkterm-i18n/i18n/en-US.ftl@@ -131,6 +131,21 @@ settings-mac-glass-clear = Clear glasssettings-mac-glass-clear-over-blur = Clear + blursettings-sidebar-shade = Sidebar colorsettings-sidebar-shade-description = How dark both sidebars are, in a see-through window.+settings-appearance-sidebar-heading = Icons and status+settings-thread-icons = Thread icons+settings-thread-icons-description = How a thread shows the programs its panes run, in the sidebar and in Find Thread.+settings-thread-icons-badge = Badge+settings-thread-icons-coins = Stack+settings-thread-icons-cluster = Group+settings-thread-icons-trailing = At the end+settings-thread-status = Sidebar status+settings-thread-status-description = How threads show they are working or waiting for you, in the sidebar and in Find Thread.+settings-thread-status-ring = Ring+settings-thread-status-pulse = Pulse+settings-thread-status-pixels = Pixels+settings-thread-status-dots = Dots+settings-agents-status = Agent status+settings-agents-status-description = How agents show they are working or waiting for you, in the Agents panel and the hover cards.settings-tab-bar-shade = Tab bar colorsettings-tab-bar-shade-description = How dark both tab bars are, in a see-through window.settings-terminal-shade = Terminal colordiff --git a/thinkterm-i18n/i18n/fr-FR.ftl b/thinkterm-i18n/i18n/fr-FR.ftlindex 8b119669..97b12db1 100644--- a/thinkterm-i18n/i18n/fr-FR.ftl+++ b/thinkterm-i18n/i18n/fr-FR.ftl@@ -131,6 +131,21 @@ settings-mac-glass-clear = Verre clairsettings-mac-glass-clear-over-blur = Clair + flousettings-sidebar-shade = Couleur des barres latéralessettings-sidebar-shade-description = Le ton des deux barres latérales, dans une fenêtre transparente.+settings-appearance-sidebar-heading = Icônes et état+settings-thread-icons = Icônes des sessions+settings-thread-icons-description = Comment une session montre les programmes de ses volets, dans la barre latérale et dans « Trouver un fil ».+settings-thread-icons-badge = Pastille+settings-thread-icons-coins = Pile+settings-thread-icons-cluster = Groupe+settings-thread-icons-trailing = À la fin+settings-thread-status = État dans la barre latérale+settings-thread-status-description = Comment les sessions montrent qu'elles travaillent ou vous attendent, dans la barre latérale et dans « Trouver un fil ».+settings-thread-status-ring = Anneau+settings-thread-status-pulse = Pouls+settings-thread-status-pixels = Pixels+settings-thread-status-dots = Points+settings-agents-status = État des agents+settings-agents-status-description = Comment les agents montrent qu'ils travaillent ou vous attendent, dans le panneau Agents et les cartes au survol.settings-tab-bar-shade = Couleur des barres d'ongletssettings-tab-bar-shade-description = Le ton des deux barres d'onglets, dans une fenêtre transparente.settings-terminal-shade = Couleur du terminaldiff --git a/thinkterm-i18n/i18n/ja-JP.ftl b/thinkterm-i18n/i18n/ja-JP.ftlindex e1c3c64e..ddfcff83 100644--- a/thinkterm-i18n/i18n/ja-JP.ftl+++ b/thinkterm-i18n/i18n/ja-JP.ftl@@ -128,6 +128,21 @@ settings-mac-glass-clear = クリアガラスsettings-mac-glass-clear-over-blur = クリア+ぼかしsettings-sidebar-shade = サイドバーの色settings-sidebar-shade-description = 左右のサイドバーの濃さ。ウインドウが透けているときに効きます。+settings-appearance-sidebar-heading = アイコンと状態+settings-thread-icons = セッションのアイコン+settings-thread-icons-description = セッションのペインで動いているプログラムの見せ方。サイドバーと「スレッドを検索」で使います。+settings-thread-icons-badge = バッジ+settings-thread-icons-coins = 重ねる+settings-thread-icons-cluster = グループ+settings-thread-icons-trailing = 右端+settings-thread-status = サイドバーの状態表示+settings-thread-status-description = セッションが作業中・返事待ちのときの表示。サイドバーと「スレッドを検索」で使います。+settings-thread-status-ring = リング+settings-thread-status-pulse = 心拍+settings-thread-status-pixels = ピクセル+settings-thread-status-dots = ドット+settings-agents-status = Agents の状態表示+settings-agents-status-description = エージェントが作業中・返事待ちのときの表示。Agents パネルとホバーカードで使います。settings-tab-bar-shade = タブバーの色settings-tab-bar-shade-description = 2 段のタブバーの濃さ。ウインドウが透けているときに効きます。settings-terminal-shade = ターミナルの色diff --git a/thinkterm-i18n/i18n/zh-CN.ftl b/thinkterm-i18n/i18n/zh-CN.ftlindex 8cc2ad37..6a543e0c 100644--- a/thinkterm-i18n/i18n/zh-CN.ftl+++ b/thinkterm-i18n/i18n/zh-CN.ftl@@ -128,6 +128,21 @@ settings-mac-glass-clear = 通透玻璃settings-mac-glass-clear-over-blur = 通透+模糊settings-sidebar-shade = 侧栏颜色settings-sidebar-shade-description = 左右两个侧栏的深浅,窗口透明时生效。+settings-appearance-sidebar-heading = 图标与状态+settings-thread-icons = 会话图标样式+settings-thread-icons-description = 一个会话里有几个程序时,图标怎么摆。侧栏和“查找线程”都用它。+settings-thread-icons-badge = 角标+settings-thread-icons-coins = 硬币横叠+settings-thread-icons-cluster = 群聊头像+settings-thread-icons-trailing = 放右边+settings-thread-status = 侧栏状态样式+settings-thread-status-description = 会话在干活、等你回复时怎么显示。侧栏和“查找线程”都用它。+settings-thread-status-ring = 进度环+settings-thread-status-pulse = 心跳+settings-thread-status-pixels = 像素格+settings-thread-status-dots = 三个点+settings-agents-status = Agents 状态样式+settings-agents-status-description = agent 在干活、等你回复时怎么显示。Agents 面板和悬停卡片都用它。settings-tab-bar-shade = 标签栏颜色settings-tab-bar-shade-description = 两行标签栏的深浅,窗口透明时生效。settings-terminal-shade = 终端颜色diff --git a/wezterm-gui/src/frontend.rs b/wezterm-gui/src/frontend.rsindex b3b345ba..ca83bf6b 100644--- a/wezterm-gui/src/frontend.rs+++ b/wezterm-gui/src/frontend.rs@@ -253,6 +253,21 @@ impl GuiFrontEnd {});mux.subscribe(move |n| {+ // The sidebar shows the programs each thread's panes run: any of+ // them starting, ending or moving makes those icons stale.+ if matches!(+ n,+ MuxNotification::PaneAdded(_)+ | MuxNotification::PaneRemoved(_)+ | MuxNotification::ForegroundProgramChanged(_)+ | MuxNotification::AgentStatusChanged(_)+ | MuxNotification::TabAddedToWindow { .. }+ | MuxNotification::WindowCreated(_)+ | MuxNotification::WindowRemoved(_)+ | MuxNotification::WindowWorkspaceChanged(_)+ ) {+ crate::thread_marks::programs_changed();+ }match n {MuxNotification::WorkspaceRenamed {old_workspace,diff --git a/wezterm-gui/src/main.rs b/wezterm-gui/src/main.rsindex 1c48c2e1..16765ce3 100644--- a/wezterm-gui/src/main.rs+++ b/wezterm-gui/src/main.rs@@ -80,6 +80,7 @@ mod tab_icons;mod tabbar;mod tailnet;mod termwindow;+mod thread_marks;mod ui;mod unicode_names;mod uniforms;diff --git a/wezterm-gui/src/native_settings.rs b/wezterm-gui/src/native_settings.rsindex 842db2b1..33cc2989 100644--- a/wezterm-gui/src/native_settings.rs+++ b/wezterm-gui/src/native_settings.rs@@ -433,6 +433,59 @@ pub(crate) struct NativeAppearanceSettings {/// The terminal's shade.#[serde(deserialize_with = "choice_or_default")]pub(crate) terminal_shade: NativeShade,+ /// How a sidebar thread row draws the programs its panes run.+ #[serde(deserialize_with = "choice_or_default")]+ pub(crate) sidebar_thread_icons: NativeThreadIcons,+ /// The mark at the end of a sidebar thread row.+ #[serde(deserialize_with = "choice_or_default")]+ pub(crate) sidebar_thread_status: NativeThreadStatus,+ /// The mark an agent's state is drawn with in the Agents panel and the+ /// hover cards.+ #[serde(deserialize_with = "choice_or_default")]+ pub(crate) agents_status: NativeThreadStatus,+}++/// How a sidebar thread row draws the programs its panes run. All but+/// `Trailing` keep the icons in a slot of one width, so the names line up.+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Deserialize, Serialize)]+#[serde(rename_all = "snake_case")]+pub(crate) enum NativeThreadIcons {+ /// The first program's icon, the second's small at its corner -- or,+ /// with more, how many more.+ #[default]+ Badge,+ /// The first program's icon with the others stacked behind it, only+ /// their edges showing.+ Coins,+ /// Every program smaller, sharing the one slot.+ Cluster,+ /// The icons side by side at the row's end, before its status.+ Trailing,+}++impl NativeThreadIcons {+ /// Every layout, in the order the settings window offers them.+ pub(crate) const ALL: [Self; 4] = [Self::Badge, Self::Coins, Self::Cluster, Self::Trailing];+}++/// The mark at the end of a sidebar thread row.+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Deserialize, Serialize)]+#[serde(rename_all = "snake_case")]+pub(crate) enum NativeThreadStatus {+ /// The spinner and dots the sidebar always had.+ Ring,+ /// A heartbeat trace while working, a flat line otherwise.+ Pulse,+ /// A three-by-three grid of pixels.+ #[default]+ Pixels,+ /// Three dots rising in turn while working, one dot otherwise.+ Dots,+}++impl NativeThreadStatus {+ /// Every mark, in the order the settings window offers them.+ pub(crate) const ALL: [Self; 4] = [Self::Ring, Self::Pulse, Self::Pixels, Self::Dots];}/// What a see-through window shows behind it on macOS: the plain blur, or@@ -2136,6 +2189,9 @@ fn apply_external_change(before: &ThinkTermNativeSettings, after: &ThinkTermNati|| before.appearance.sidebar_shade != after.appearance.sidebar_shade|| before.appearance.tab_bar_shade != after.appearance.tab_bar_shade|| before.appearance.terminal_shade != after.appearance.terminal_shade+ || before.appearance.sidebar_thread_icons != after.appearance.sidebar_thread_icons+ || before.appearance.sidebar_thread_status != after.appearance.sidebar_thread_status+ || before.appearance.agents_status != after.appearance.agents_status{// Language, theme, colour scheme, opacity, chrome and app icon.apply_to_app(after);@@ -2758,6 +2814,18 @@ pub(crate) fn right_sidebar_open_with_app() -> Option<NativeOpenWithApp> {load().chrome.right_sidebar_open_with_app}+pub(crate) fn sidebar_thread_icons() -> NativeThreadIcons {+ load_shared().appearance.sidebar_thread_icons+}++pub(crate) fn sidebar_thread_status() -> NativeThreadStatus {+ load_shared().appearance.sidebar_thread_status+}++pub(crate) fn agents_status() -> NativeThreadStatus {+ load_shared().appearance.agents_status+}+pub(crate) fn workspace_sidebar_hidden_statuses() -> Vec<String> {load().chrome.workspace_sidebar_hidden_statuses}diff --git a/wezterm-gui/src/settings_window.rs b/wezterm-gui/src/settings_window.rsindex 3b7343cd..b59969ee 100644--- a/wezterm-gui/src/settings_window.rs+++ b/wezterm-gui/src/settings_window.rs@@ -1129,6 +1129,12 @@ impl SettingsSection {"Theme","Font","Weight",+ "Thread Icons",+ "Thread Status",+ "Sidebar Icons",+ "Status Style",+ "Agent Status",+ "Icons and Status",],Self::Terminal => &["Default Shell",@@ -1322,9 +1328,15 @@ impl SettingsSection {.to_lowercase().contains(query))|| (self == Self::Appearance- && crate::i18n::tr("settings-window-opacity")- .to_lowercase()- .contains(query))+ && [+ "settings-window-opacity",+ "settings-thread-icons",+ "settings-thread-status",+ "settings-agents-status",+ "settings-appearance-sidebar-heading",+ ]+ .iter()+ .any(|key| crate::i18n::tr(key).to_lowercase().contains(query)))|| (self == Self::Terminal&& ["settings-terminal-mouse-heading",@@ -1527,6 +1539,34 @@ fn localized_mac_glass_label(glass: crate::native_settings::NativeMacGlass) -> S})}+/// Which of the Icons and status card's rows is being painted.+#[derive(Debug, Clone, Copy, PartialEq, Eq)]+enum ThreadChoice {+ Icons,+ SidebarStatus,+ AgentStatus,+}++fn localized_thread_icons_label(layout: crate::native_settings::NativeThreadIcons) -> String {+ use crate::native_settings::NativeThreadIcons;+ crate::i18n::tr(match layout {+ NativeThreadIcons::Badge => "settings-thread-icons-badge",+ NativeThreadIcons::Coins => "settings-thread-icons-coins",+ NativeThreadIcons::Cluster => "settings-thread-icons-cluster",+ NativeThreadIcons::Trailing => "settings-thread-icons-trailing",+ })+}++fn localized_thread_status_label(status: crate::native_settings::NativeThreadStatus) -> String {+ use crate::native_settings::NativeThreadStatus;+ crate::i18n::tr(match status {+ NativeThreadStatus::Ring => "settings-thread-status-ring",+ NativeThreadStatus::Pulse => "settings-thread-status-pulse",+ NativeThreadStatus::Pixels => "settings-thread-status-pixels",+ NativeThreadStatus::Dots => "settings-thread-status-dots",+ })+}+fn localized_shade_label(shade: crate::native_settings::NativeShade) -> String {use crate::native_settings::NativeShade;crate::i18n::tr(match shade {@@ -1870,6 +1910,9 @@ enum SettingsAction {SetSidebarShade(crate::native_settings::NativeShade),SetTabBarShade(crate::native_settings::NativeShade),SetTerminalShade(crate::native_settings::NativeShade),+ SetThreadIcons(crate::native_settings::NativeThreadIcons),+ SetThreadStatus(crate::native_settings::NativeThreadStatus),+ SetAgentStatus(crate::native_settings::NativeThreadStatus),ToggleDownloadSourceMenu,SetDownloadSource(thinkterm_update::DownloadSource),/// Swallows clicks that land in an open dropdown's padding or row@@ -6109,6 +6152,21 @@ impl SettingsWindow {localized_shade_label(shade),|appearance| appearance.terminal_shade = shade,),+ SettingsAction::SetThreadIcons(layout) => self.apply_window_areas(+ "settings-thread-icons",+ localized_thread_icons_label(layout),+ |appearance| appearance.sidebar_thread_icons = layout,+ ),+ SettingsAction::SetThreadStatus(status) => self.apply_window_areas(+ "settings-thread-status",+ localized_thread_status_label(status),+ |appearance| appearance.sidebar_thread_status = status,+ ),+ SettingsAction::SetAgentStatus(status) => self.apply_window_areas(+ "settings-agents-status",+ localized_thread_status_label(status),+ |appearance| appearance.agents_status = status,+ ),SettingsAction::ToggleMainRendererMenu => {self.ui.open_dropdown =if self.ui.open_dropdown == Some(SettingsDropdown::MainRenderer) {@@ -8686,6 +8744,66 @@ impl SettingsWindow {Ok(rows.bottom)})?;+ let card_y = self.paint_card_heading(+ layers,+ x,+ bottom,+ max_width,+ &crate::i18n::tr("settings-appearance-sidebar-heading"),+ )?;+ let bottom = self.paint_card(layers, x, card_y, max_width, |this, layers, top| {+ let mut rows = RowCursor::new(top, this);+ let (tx, tw) = this.paint_row_tile(+ layers,+ row_x,+ rows.y,+ row_width,+ SvgIcon::Layers,+ TileColor::Orange,+ )?;+ rows.add(this.paint_thread_choice_row(+ layers,+ tx,+ rows.y,+ tw,+ rows.rule(),+ ThreadChoice::Icons,+ )?);+ let (tx, tw) = this.paint_row_tile(+ layers,+ row_x,+ rows.y,+ row_width,+ SvgIcon::Grid2x2,+ TileColor::Green,+ )?;+ rows.add(this.paint_thread_choice_row(+ layers,+ tx,+ rows.y,+ tw,+ rows.rule(),+ ThreadChoice::SidebarStatus,+ )?);+ let (tx, tw) = this.paint_row_tile(+ layers,+ row_x,+ rows.y,+ row_width,+ SvgIcon::Bot,+ TileColor::Blue,+ )?;+ rows.add(this.paint_thread_choice_row(+ layers,+ tx,+ rows.y,+ tw,+ rows.rule(),+ ThreadChoice::AgentStatus,+ )?);+ Ok(rows.bottom)+ })?;+self.ui.content_scroll.set_extents(self.content_viewport_extent(),self.settings_content_extent(bottom + scroll),@@ -9177,6 +9295,320 @@ impl SettingsWindow {)}+ /// How the sidebar's thread rows draw their programs (`icons`) or+ /// their status: the title and description, and under them a tile per+ /// choice showing it as the sidebar draws it -- still, so an open page+ /// costs nothing.+ fn paint_thread_choice_row(+ &mut self,+ layers: &mut TripleLayerQuadAllocator<'_>,+ x: f32,+ y: f32,+ width: f32,+ draw_top_rule: bool,+ choice: ThreadChoice,+ ) -> anyhow::Result<f32> {+ use crate::native_settings::{NativeThreadIcons, NativeThreadStatus};+ let palette = self.palette();+ let ui_font = Rc::clone(&self.ui_font);+ let body_font = Rc::clone(&self.body_font);+ if draw_top_rule {+ self.paint_separator(layers, x, y - self.ui_px(28.0), width)?;+ }+ let appearance = &self.native_settings.appearance;+ let title = match choice {+ ThreadChoice::Icons => "settings-thread-icons",+ ThreadChoice::SidebarStatus => "settings-thread-status",+ ThreadChoice::AgentStatus => "settings-agents-status",+ };+ let (status_action, current_status): (fn(NativeThreadStatus) -> SettingsAction, _) =+ match choice {+ ThreadChoice::AgentStatus => (SettingsAction::SetAgentStatus, appearance.agents_status),+ _ => (SettingsAction::SetThreadStatus, appearance.sidebar_thread_status),+ };+ let choices: Vec<(String, SettingsAction, bool)> = if choice == ThreadChoice::Icons {+ NativeThreadIcons::ALL+ .iter()+ .map(|layout| {+ (+ localized_thread_icons_label(*layout),+ SettingsAction::SetThreadIcons(*layout),+ *layout == appearance.sidebar_thread_icons,+ )+ })+ .collect()+ } else {+ NativeThreadStatus::ALL+ .iter()+ .map(|status| {+ (+ localized_thread_status_label(*status),+ status_action(*status),+ *status == current_status,+ )+ })+ .collect()+ };+ self.draw_text(+ layers,+ &ui_font,+ x,+ y,+ &crate::i18n::tr(title),+ palette.text,+ width,+ )?;+ let extra = self.draw_row_description(+ layers,+ x,+ y,+ &crate::i18n::tr(&format!("{title}-description")),+ width,+ )?;+ let tiles_y = self.settings_row_description_y(y)+ + self.description_line_step()+ + extra+ + self.ui_px(14.0);+ let count = choices.len() as f32;+ let gap = self.ui_px(16.0);+ let tile_width = ((width - gap * (count - 1.0)) / count)+ .min(self.ui_px(220.0))+ .floor();+ let tile_height = (tile_width * 0.44).round();+ let ring = self.ui_px(3.0).max(2.0).round();+ let edge = self.ui_px(2.0).max(1.0).round();+ let radius = self.ui_px(20.0);+ let accent = self.chrome_palette.accent;+ let tile_bg = self.chrome_palette.workspace_sidebar_bg;+ let cell_height = self.metrics.cell_size.height as f32;+ let label_y = tiles_y + tile_height + self.ui_px(10.0);+ for (index, (label, action, selected)) in choices.iter().enumerate() {+ let tile_x = x + (tile_width + gap) * index as f32;+ let hovered = self.ui.interaction.hovered == Some(*action)+ || self.ui.interaction.pressed == Some(*action);+ let (outline, outline_width) = if *selected {+ (accent, ring)+ } else if hovered {+ (accent.mul_alpha(0.4), ring)+ } else {+ (palette.rule, edge)+ };+ self.draw_rounded_rect(+ layers,+ 0,+ tile_x - outline_width,+ tiles_y - outline_width,+ tile_width + outline_width * 2.0,+ tile_height + outline_width * 2.0,+ outline,+ radius + outline_width,+ )?;+ self.draw_rounded_rect(+ layers,+ 0,+ tile_x,+ tiles_y,+ tile_width,+ tile_height,+ tile_bg,+ radius,+ )?;+ match action {+ SettingsAction::SetThreadIcons(layout) => self.draw_thread_icons_preview(+ layers,+ *layout,+ tile_x,+ tiles_y,+ tile_width,+ tile_height,+ )?,+ SettingsAction::SetThreadStatus(status) | SettingsAction::SetAgentStatus(status) => self.draw_thread_status_preview(+ layers,+ *status,+ tile_x,+ tiles_y,+ tile_width,+ tile_height,+ )?,+ _ => {}+ }+ let label_width = self.measure_text_width(&body_font, label).min(tile_width);+ self.draw_text(+ layers,+ &body_font,+ tile_x + (tile_width - label_width) / 2.0,+ label_y,+ label,+ if *selected {+ palette.text+ } else {+ palette.secondary_text+ },+ tile_width,+ )?;+ let top = tiles_y - ring;+ self.ui_context.push(+ rect(tile_x, top, tile_width, label_y + cell_height - top),+ WidgetKind::Button,+ *action,+ );+ }+ let bottom = label_y + cell_height + self.ui_px(6.0);+ Ok((bottom - (y + self.settings_row_visual_height())).max(0.0))+ }++ /// Two sidebar rows in little, their programs drawn in `layout`: one+ /// thread running Claude in a terminal, one with Codex as well.+ #[allow(clippy::too_many_arguments)]+ fn draw_thread_icons_preview(+ &self,+ layers: &mut TripleLayerQuadAllocator<'_>,+ layout: crate::native_settings::NativeThreadIcons,+ x: f32,+ y: f32,+ width: f32,+ height: f32,+ ) -> anyhow::Result<()> {+ use crate::native_settings::NativeThreadIcons;+ let catalog = crate::tab_icons::catalog();+ let claude = catalog.card_for(Some("claude"), None).resolved();+ let codex = catalog.card_for(Some("codex"), None).resolved();+ let terminal = catalog.terminal_card().resolved();+ let rows = [+ vec![claude.clone(), terminal.clone()],+ vec![claude, codex, terminal],+ ];+ let ctx = crate::ui::draw::DrawContext::new(+ self.render_state.as_ref().unwrap(),+ self.dimensions,+ &self.metrics,+ );+ let diameter = (height * 0.3).round();+ let pt_per_px = 72.0 / self.dimensions.dpi.max(1) as f64;+ let count_font = self.fonts.title_font_with_size_and_weight(+ (diameter as f64 * pt_per_px * 0.38).max(5.0),+ 700,+ )?;+ let count_metrics = RenderMetrics::with_font_metrics(&count_font.metrics());+ let style = crate::thread_marks::IconStyle {+ surface: self.chrome_palette.workspace_sidebar_bg,+ dark: self.chrome_palette.is_dark(),+ count_font: &count_font,+ count_metrics: &count_metrics,+ count_color: self.palette().secondary_text,+ };+ let pad = (height * 0.22).round();+ let bar_height = (height * 0.09).round().max(2.0);+ let gap = (diameter * 0.35).round();+ let bar_color = self.palette().secondary_text.mul_alpha(0.35);+ for (index, icons) in rows.iter().enumerate() {+ let cy = (y + height * (0.3 + 0.4 * index as f32)).round();+ let (left, right) = (x + pad, x + width - pad);+ let (bar_left, bar_right) = if layout == NativeThreadIcons::Trailing {+ let start =+ crate::thread_marks::draw_trailing(&ctx, layers, icons, right, cy, diameter, &style)?;+ (left, start - gap)+ } else {+ crate::thread_marks::draw_slot(&ctx, layers, layout, icons, left, cy, diameter, &style)?;+ (+ left + crate::thread_marks::slot_width(layout, diameter) + gap,+ right,+ )+ };+ self.draw_rounded_rect(+ layers,+ 1,+ bar_left,+ cy - bar_height / 2.0,+ (bar_right - bar_left).max(0.0),+ bar_height,+ bar_color,+ bar_height / 2.0,+ )?;+ }+ Ok(())+ }++ /// A thread's mark in `status`, still, three times over: working,+ /// waiting for an answer, and open with nothing to say -- in the colours+ /// every status is shown in.+ #[allow(clippy::too_many_arguments)]+ fn draw_thread_status_preview(+ &self,+ layers: &mut TripleLayerQuadAllocator<'_>,+ status: crate::native_settings::NativeThreadStatus,+ x: f32,+ y: f32,+ width: f32,+ height: f32,+ ) -> anyhow::Result<()> {+ use crate::native_settings::NativeThreadStatus;+ use crate::thread_marks::Mark;+ let ctx = crate::ui::draw::DrawContext::new(+ self.render_state.as_ref().unwrap(),+ self.dimensions,+ &self.metrics,+ );+ let size = (height * 0.3).round();+ let marks = [+ (Mark::Working, crate::thread_marks::WORKING_COLOR),+ (+ Mark::Waiting,+ crate::termwindow::ui::agent_panel::AGENT_BLOCKED_COLOR,+ ),+ (Mark::Still, crate::thread_marks::OPEN_COLOR),+ ];+ let cy = y + height / 2.0;+ for (index, &(mark, color)) in marks.iter().enumerate() {+ let cx = x + width * (1.0 + 2.0 * index as f32) / 6.0;+ if index > 0 {+ let rule = self.ui_px(2.0).max(1.0).round();+ self.draw_rounded_rect(+ layers,+ 1,+ (x + width * index as f32 / 3.0 - rule / 2.0).round(),+ (cy - size / 2.0).round(),+ rule,+ size,+ self.palette().rule,+ rule / 2.0,+ )?;+ }+ let (left, top) = ((cx - size / 2.0).round(), (cy - size / 2.0).round());+ match status {+ NativeThreadStatus::Ring => match mark {+ Mark::Working => {+ // The spinner, a little larger, as the sidebar+ // draws it.+ let spinner = (size * 1.3).round();+ ctx.draw_svg_icon(+ layers,+ SvgIcon::LoaderCircle,+ (cx - spinner / 2.0).round(),+ (cy - spinner / 2.0).round(),+ spinner,+ color,+ )?+ }+ Mark::Waiting => {+ ctx.draw_svg_icon(layers, SvgIcon::CircleAlert, left, top, size, color)?+ }+ _ => ctx.draw_disc(layers, 2, cx, cy, (size * 0.5).round(), color)?,+ },+ NativeThreadStatus::Pulse => {+ crate::thread_marks::draw_pulse(&ctx, layers, mark, None, left, top, size, color)?+ }+ NativeThreadStatus::Pixels => {+ crate::thread_marks::draw_pixels(&ctx, layers, mark, None, left, top, size, color)?+ }+ NativeThreadStatus::Dots => {+ crate::thread_marks::draw_dots(&ctx, layers, mark, None, left, top, size, color)?+ }+ }+ }+ Ok(())+ }+/// The app icons to switch between, shown as themselves.fn paint_app_icon_choice_row(&mut self,diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rsindex cd85e6e6..0616f209 100644--- a/wezterm-gui/src/termwindow/mod.rs+++ b/wezterm-gui/src/termwindow/mod.rs@@ -6125,7 +6125,8 @@ impl TermWindow {self.invalidate_window_if(self.agent_status_change_is_visible(pane_id));}MuxNotification::ForegroundProgramChanged(pane_id) => {- self.invalidate_if_pane_tab_shown(pane_id);+ // The pane's tab, or its thread's row in the sidebar.+ self.invalidate_window_if(self.agent_status_change_is_visible(pane_id));}MuxNotification::WindowInvalidated(_) => {window.invalidate();@@ -6598,19 +6599,6 @@ impl TermWindow {Ok(())}- /// Repaint when the pane's tab could be on screen: its tab strip shows- /// every pane of the stack, so any pane of the active tab counts.- fn invalidate_if_pane_tab_shown(&self, pane_id: PaneId) {- let shown = Mux::get()- .get_active_tab_for_window(self.mux_window_id)- .is_some_and(|tab| tab.contains_pane(pane_id));- if shown {- if let Some(window) = self.window.as_ref() {- window.invalidate();- }- }- }-fn agent_status_change_is_visible(&self, pane_id: PaneId) -> bool {let mux = Mux::get();let pane_window_id = mux.resolve_pane_id(pane_id).map(|(_, window_id, _)| window_id);diff --git a/wezterm-gui/src/termwindow/ui/agent_panel.rs b/wezterm-gui/src/termwindow/ui/agent_panel.rsindex 80b360f8..c9c83740 100644--- a/wezterm-gui/src/termwindow/ui/agent_panel.rs+++ b/wezterm-gui/src/termwindow/ui/agent_panel.rs@@ -26,17 +26,11 @@ use wezterm_font::LoadedFont;use window::color::LinearRgba;use window::{MouseEvent, MouseEventKind as WMEK, MousePress, RectF, WindowOps};-/// An agent that is working, in the same blue the left sidebar uses for a-/// live thread (`SESSION_STATUS_OPEN_COLOR`).-const AGENT_WORKING_COLOR: LinearRgba = LinearRgba::with_components(0.12, 0.48, 1.0, 1.0);-/// An agent waiting on the user: amber, matching the sidebar's other-/// "needs a human" signal. Deliberately not the notification red, which is-/// reserved for something being wrong rather than something being asked.-pub(crate) const AGENT_BLOCKED_COLOR: LinearRgba = LinearRgba::with_components(0.86, 0.45, 0.12, 1.0);-/// A finished result nobody has looked at yet: the green the left sidebar-/// gives a finished thread, the same constant so the two cannot drift.-pub(crate) const AGENT_DONE_COLOR: LinearRgba =- crate::termwindow::ui::sidebar::SESSION_STATUS_DONE_COLOR;+/// An agent's states in the colours every status is shown in+/// (`thread_marks`), so the panel and the sidebar cannot drift.+const AGENT_WORKING_COLOR: LinearRgba = crate::thread_marks::WORKING_COLOR;+pub(crate) const AGENT_BLOCKED_COLOR: LinearRgba = crate::thread_marks::WAITING_COLOR;+pub(crate) const AGENT_DONE_COLOR: LinearRgba = crate::thread_marks::FINISHED_COLOR;/// The progress bar under a row's description.pub(crate) const AGENT_PROGRESS_HEIGHT: usize = 6;/// Between two agent rows; a hairline sits in the middle of it.diff --git a/wezterm-gui/src/termwindow/ui/sidebar.rs b/wezterm-gui/src/termwindow/ui/sidebar.rsindex 3f032316..62a8e4ea 100644--- a/wezterm-gui/src/termwindow/ui/sidebar.rs+++ b/wezterm-gui/src/termwindow/ui/sidebar.rs@@ -14,7 +14,10 @@ use crate::termwindow::ui::tokens::{WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_X, WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_Y_OFFSET,WINDOW_TAB_TOP_SPACER,};+use crate::native_settings::{NativeThreadIcons, NativeThreadStatus};use crate::termwindow::{UIItem, UIItemType};+use crate::thread_marks::{self, Mark};+use crate::ui::draw::DrawContext;use crate::ui::{scale_ui_f32, scale_ui_usize, unscale_ui_usize, UiPalette};use crate::utilsprites::RenderMetrics;use crate::workspace_threads;@@ -65,10 +68,10 @@ const SESSION_ACTION_MIN_SIZE: usize = 48;const SESSION_ACTION_MAX_SIZE: usize = 52;const SESSION_ACTION_ICON_INSET: usize = 12;const SESSION_STATUS_DOT_SIZE: usize = 10;-const SESSION_STATUS_ICON_SIZE: usize = 20;+/// The square a thread's mark sits in; the Agents panel and the hover+/// cards draw theirs at this size too.+pub(crate) const SESSION_STATUS_ICON_SIZE: usize = 20;const SESSION_STATUS_ACTIVE_ICON_SIZE: usize = 26;-pub(crate) const SESSION_STATUS_DONE_COLOR: LinearRgba = LinearRgba::with_components(0.20, 0.78, 0.36, 1.0);-const SESSION_STATUS_OPEN_COLOR: LinearRgba = LinearRgba::with_components(0.12, 0.48, 1.0, 1.0);const SPACE_DISCONNECTED_COLOR: LinearRgba = LinearRgba::with_components(0.86, 0.45, 0.12, 1.0);const NOTIFICATION_BADGE_COLOR: LinearRgba = LinearRgba::with_components(0.96, 0.16, 0.22, 1.0);const NOTIFICATION_BADGE_PULSE_DURATION: Duration = Duration::from_millis(1800);@@ -145,8 +148,52 @@ pub fn workspace_sidebar_width_for_metrics(render_metrics: &RenderMetrics, dpi:.clamp(min_width, max_width)}+/// What every thread row of one paint draws its icons and mark with,+/// worked out once for the paint: the sidebar's and the thread search's.+pub(crate) struct ThreadRowMarks {+ pub(crate) layout: NativeThreadIcons,+ pub(crate) status: NativeThreadStatus,+ /// The icons by workspace.+ icons: Rc<HashMap<String, Vec<crate::tab_icons::ResolvedIcon>>>,+ /// Each thread's workspace, by thread id.+ workspaces: HashMap<workspace_threads::WorkspaceThreadId, String>,+ /// The terminal's, for a thread with nothing running.+ terminal: crate::tab_icons::ResolvedIcon,+ pub(crate) count_font: Rc<LoadedFont>,+ pub(crate) count_metrics: RenderMetrics,+}++impl ThreadRowMarks {+ /// The icons of thread `thread_id`'s programs; for one with nothing+ /// running -- closed, or not yet opened -- the terminal it would open+ /// to.+ pub(crate) fn icons(&self, thread_id: &str, live: bool) -> &[crate::tab_icons::ResolvedIcon] {+ live.then(|| self.workspaces.get(thread_id))+ .flatten()+ .and_then(|workspace| self.icons.get(workspace))+ .filter(|icons| !icons.is_empty())+ .map(Vec::as_slice)+ .unwrap_or(std::slice::from_ref(&self.terminal))+ }+}++/// `top` laid over `bottom`.+pub(crate) fn over(top: LinearRgba, bottom: LinearRgba) -> LinearRgba {+ let alpha = top.3 + bottom.3 * (1.0 - top.3);+ if alpha <= 0.0 {+ return top;+ }+ let mix = |t: f32, b: f32| (t * top.3 + b * bottom.3 * (1.0 - top.3)) / alpha;+ LinearRgba::with_components(+ mix(top.0, bottom.0),+ mix(top.1, bottom.1),+ mix(top.2, bottom.2),+ alpha,+ )+}+/// Whether a program in the thread reported that it stopped on an error.-fn thread_has_errored_agent(thread_id: &str) -> bool {+pub(crate) fn thread_has_errored_agent(thread_id: &str) -> bool {workspace_threads::thread_workspace_name(thread_id).is_some_and(|workspace| {crate::agent_status::any_agent_in_workspace(&workspace, |agent| {agent.state == crate::agent_status::AgentState::Error@@ -674,43 +721,33 @@ impl crate::TermWindow {}}+ /// A thread at rest, in the status colours (`thread_marks`): the one+ /// the user is in, `current`, in green.fn sidebar_thread_dot_color(&self,session: &workspace_threads::WorkspaceThreadView,- chrome: &UiPalette,+ current: bool,foreground: LinearRgba,- suppress_active: bool,) -> LinearRgba {- if session.is_active && !suppress_active {- LinearRgba::with_components(0.20, 0.78, 0.36, 1.0)+ if current {+ thread_marks::CURRENT_COLOR+ } else if !session.is_materialized {+ thread_marks::closed_color(foreground)} else if session.is_unread {- chrome.selected_bg- } else if session.is_pinned {- foreground.mul_alpha(0.68)- } else if session.is_materialized {- SESSION_STATUS_OPEN_COLOR+ thread_marks::unread_color(foreground)} else {- foreground.mul_alpha(0.16)+ thread_marks::OPEN_COLOR}}- fn sidebar_thread_status_color(- &self,- session: &workspace_threads::WorkspaceThreadView,- status: UiStatusKind,- chrome: &UiPalette,- foreground: LinearRgba,- suppress_active: bool,- ) -> LinearRgba {- if status == UiStatusKind::Done {- SESSION_STATUS_DONE_COLOR- } else if session.is_active && !suppress_active {- foreground- } else if status == UiStatusKind::NeedsAttention {- // The amber the Agents panel and the tabs use for a wait.- crate::termwindow::ui::agent_panel::AGENT_BLOCKED_COLOR- } else {- self.sidebar_thread_dot_color(session, chrome, foreground, suppress_active)+ /// A thread's state in the status colours; the one the user is in,+ /// `current`, works in its own green.+ fn sidebar_thread_status_color(status: UiStatusKind, current: bool) -> LinearRgba {+ match status {+ UiStatusKind::Running if current => thread_marks::CURRENT_COLOR,+ UiStatusKind::Running => thread_marks::WORKING_COLOR,+ UiStatusKind::NeedsAttention => thread_marks::WAITING_COLOR,+ UiStatusKind::Done => thread_marks::FINISHED_COLOR,}}@@ -722,16 +759,17 @@ impl crate::TermWindow {scale_ui_f32(value, self.dimensions.dpi)}+ #[allow(clippy::too_many_arguments)]fn paint_sidebar_thread_status(&self,layers: &mut TripleLayerQuadAllocator,session: &workspace_threads::WorkspaceThreadView,+ current: bool,x: usize,y: usize,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) {@@ -761,13 +799,7 @@ 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,- suppress_active,- ),+ Self::sidebar_thread_status_color(status, current),);}@@ -786,12 +818,230 @@ 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, suppress_active),+ self.sidebar_thread_dot_color(session, current, foreground),self.ui_px(SESSION_STATUS_DOT_SIZE) as f32 / 2.0,).context("sidebar thread status dot")}+ /// What every thread row of one paint draws its icons and mark with.+ pub(crate) fn sidebar_thread_row_marks(&self) -> anyhow::Result<ThreadRowMarks> {+ let count_font = self+ .fonts+ .title_font_with_size_and_weight(+ crate::native_settings::sidebar_font_size() * 0.55,+ 700,+ )+ .context("sidebar thread count font")?;+ let count_metrics = RenderMetrics::with_font_metrics(&count_font.metrics());+ Ok(ThreadRowMarks {+ layout: crate::native_settings::sidebar_thread_icons(),+ status: crate::native_settings::sidebar_thread_status(),+ icons: thread_marks::icons_by_workspace(),+ workspaces: workspace_threads::thread_workspace_names(),+ terminal: crate::tab_icons::resolve_window_tab(),+ count_font,+ count_metrics,+ })+ }++ /// A thread row's program icons and the mark at its end. The icons go+ /// at `start_x`, or before the mark when they trail; the mark ends at+ /// `end_x`. With `show_end` false the row's buttons have the end, and+ /// neither the mark nor trailing icons are drawn. A `dimmed` row -- a+ /// ref whose machine is away -- has no mark: it cannot say what the+ /// thread is doing. Returns+ /// where the name starts and the right edge it must keep clear of.+ #[allow(clippy::too_many_arguments)]+ fn paint_sidebar_thread_marks(+ &self,+ layers: &mut TripleLayerQuadAllocator,+ marks: &ThreadRowMarks,+ session: &workspace_threads::WorkspaceThreadView,+ start_x: usize,+ end_x: usize,+ y: usize,+ row_height: usize,+ surface: LinearRgba,+ show_end: bool,+ dimmed: bool,+ current: bool,+ chrome: &UiPalette,+ foreground: LinearRgba,+ ) -> anyhow::Result<(usize, usize)> {+ // As far in from the row's end as the icons sit from its start,+ // centre for centre, rather than against the edge.+ let mark_x = end_x+ .saturating_sub(self.ui_px(SESSION_STATUS_ICON_SIZE) + self.ui_px(SIDEBAR_INSET));+ let mut text_right = end_x;+ if show_end && !dimmed {+ self.paint_sidebar_thread_mark(+ layers,+ marks,+ session,+ current,+ mark_x,+ y,+ row_height,+ chrome,+ foreground,+ )?;+ text_right = mark_x;+ }+ let icons = marks.icons(&session.id, session.is_materialized);+ let diameter = (row_height as f32 * 0.56).round();+ let cy = y as f32 + row_height as f32 / 2.0;+ let gl_state = self.render_state.as_ref().unwrap();+ let ctx = DrawContext::new(gl_state, self.dimensions, &self.render_metrics);+ let style = thread_marks::IconStyle {+ surface,+ dark: chrome.is_dark(),+ count_font: &marks.count_font,+ count_metrics: &marks.count_metrics,+ count_color: chrome.secondary_text,+ };+ if marks.layout == NativeThreadIcons::Trailing {+ if show_end {+ // Where a mark would be even when there is none, so a row+ // without one lines its icons up with the rest.+ let gap = self.ui_f32(SIDEBAR_ICON_GAP as f32 * 2.0);+ let left = thread_marks::draw_trailing(+ &ctx,+ layers,+ icons,+ mark_x as f32 - gap,+ cy,+ diameter,+ &style,+ )?;+ text_right = left.max(0.0) as usize;+ }+ return Ok((start_x, text_right));+ }+ thread_marks::draw_slot(+ &ctx,+ layers,+ marks.layout,+ icons,+ start_x as f32,+ cy,+ diameter,+ &style,+ )?;+ let slot = thread_marks::slot_width(marks.layout, diameter).round() as usize;+ Ok((start_x + slot + self.ui_px(SIDEBAR_ICON_GAP), text_right))+ }++ /// The mark at a thread row's end, in the style Settings chose: the+ /// ring is the spinner and dots the sidebar always drew.+ #[allow(clippy::too_many_arguments)]+ fn paint_sidebar_thread_mark(+ &self,+ layers: &mut TripleLayerQuadAllocator,+ marks: &ThreadRowMarks,+ session: &workspace_threads::WorkspaceThreadView,+ current: bool,+ x: usize,+ y: usize,+ row_height: usize,+ chrome: &UiPalette,+ foreground: LinearRgba,+ ) -> anyhow::Result<()> {+ if marks.status == NativeThreadStatus::Ring {+ return self.paint_sidebar_thread_status(+ layers,+ session,+ current,+ x,+ y,+ row_height,+ chrome,+ foreground,+ );+ }+ let (mark, color) = match self.sidebar_thread_status_kind(session) {+ Some(UiStatusKind::NeedsAttention) if thread_has_errored_agent(&session.id) => {+ (Mark::Failed, chrome.danger)+ }+ Some(status) => (+ match status {+ UiStatusKind::Running => Mark::Working,+ UiStatusKind::NeedsAttention => Mark::Waiting,+ UiStatusKind::Done => Mark::Finished,+ },+ Self::sidebar_thread_status_color(status, current),+ ),+ None => (+ Mark::Still,+ self.sidebar_thread_dot_color(session, current, foreground),+ ),+ };+ let size = self.ui_px(SESSION_STATUS_ICON_SIZE) as f32;+ let top = (y as f32 + (row_height as f32 - size) / 2.0).round();+ self.paint_thread_mark(layers, marks.status, mark, x as f32, top, size, color)+ .context("sidebar thread mark")+ }++ /// A thread's or an agent's mark in `status`'s style, in the `size`+ /// square at `x`, `y`, moving while it works. The ring is the spinner+ /// and the status icons.+ #[allow(clippy::too_many_arguments)]+ pub(crate) fn paint_thread_mark(+ &self,+ layers: &mut TripleLayerQuadAllocator,+ status: NativeThreadStatus,+ mark: Mark,+ x: f32,+ y: f32,+ size: f32,+ color: LinearRgba,+ ) -> anyhow::Result<()> {+ if status == NativeThreadStatus::Ring {+ let icon = match mark {+ Mark::Working => {+ let spinner = (size * 1.3).round();+ let inset = (spinner - size) / 2.0;+ return self.paint_spinning_ui_icon(+ layers,+ 2,+ SvgIcon::LoaderCircle,+ (x - inset).max(0.0) as usize,+ (y - inset).max(0.0) as usize,+ spinner as usize,+ color,+ );+ }+ Mark::Waiting => SvgIcon::CircleAlert,+ Mark::Failed => SvgIcon::CircleX,+ Mark::Finished => SvgIcon::CircleCheck,+ Mark::Still => {+ let dot = (size / 2.0).round();+ let inset = (size - dot) / 2.0;+ return self.fill_rounded_rectangle(+ layers,+ 2,+ euclid::rect(x + inset, y + inset, dot, dot),+ color,+ dot / 2.0,+ );+ }+ };+ return self.paint_ui_icon(layers, 2, icon, x as usize, y as usize, size as usize, color);+ }+ let step = (mark == Mark::Working).then(|| {+ self.update_next_frame_time(Some(thread_marks::next_mark_step()));+ thread_marks::mark_step()+ });+ let gl_state = self.render_state.as_ref().unwrap();+ let ctx = DrawContext::new(gl_state, self.dimensions, &self.render_metrics);+ let draw = match status {+ NativeThreadStatus::Pulse => thread_marks::draw_pulse,+ NativeThreadStatus::Dots => thread_marks::draw_dots,+ _ => thread_marks::draw_pixels,+ };+ draw(&ctx, layers, mark, step, x, y, size, color)+ }+/// 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@@ -1157,6 +1407,7 @@ impl crate::TermWindow {.title_font_with_size(crate::native_settings::sidebar_font_size()).context("sidebar ui font")?;let ui_metrics = RenderMetrics::with_font_metrics(&ui_font.metrics());+ let row_marks = self.sidebar_thread_row_marks()?;let ui_cell_height = ui_metrics.cell_size.height as usize;let icon_size = (ui_cell_height + self.ui_px(12)).clamp(self.ui_px(30), self.ui_px(36));let layout = self.workspace_sidebar_layout(rect, ui_cell_height, icon_size);@@ -1744,10 +1995,6 @@ impl crate::TermWindow {let pinned_x = item_x + self.ui_px(SIDEBAR_INSET);let pinned_width = item_width.saturating_sub(self.ui_px(SIDEBAR_INSET) * 2);let pinned_status_x = pinned_x + self.ui_px(SIDEBAR_INSET);- let pinned_text_x = pinned_status_x- + self.ui_px(SESSION_STATUS_ICON_SIZE)- + self.ui_px(SIDEBAR_ICON_GAP)- + 6;for session in &view.pinned_threads {let row_top = list_top_f + virtual_y as f32 - scroll_offset;let row_bottom = row_top + session_row_height as f32;@@ -1825,23 +2072,32 @@ impl crate::TermWindow {.saturating_sub(self.ui_px(SIDEBAR_INSET) + action_size);let pin_x = delete_x.saturating_sub(action_size + 4);let action_y = y + ((session_row_height.saturating_sub(action_size)) / 2);- let text_right = if is_hovered && !is_renaming_session {- pin_x+ let shows_actions = is_hovered && !is_renaming_session;+ let surface = if is_selected {+ over(selected_bg, sidebar_bg)+ } else if shows_actions {+ over(chrome.sidebar_row_hover_bg, sidebar_bg)} else {- pinned_x- .saturating_add(pinned_width)- .saturating_sub(self.ui_px(SIDEBAR_INSET))+ sidebar_bg};- self.paint_sidebar_thread_status(+ let (pinned_text_x, marks_right) = self.paint_sidebar_thread_marks(layers,+ &row_marks,session,pinned_status_x,+ pinned_x+ .saturating_add(pinned_width)+ .saturating_sub(self.ui_px(SIDEBAR_INSET)),y,session_row_height,+ surface,+ !shows_actions,+ false,+ is_selected,&chrome,foreground,- suppress_own_active,)?;+ let text_right = if shows_actions { pin_x } else { marks_right };let title = self.sidebar_thread_title(&session.id, &session.name);self.paint_sidebar_text(layers,@@ -2181,10 +2437,6 @@ impl crate::TermWindow {self.ui_px(SIDEBAR_INSET) * 3 + self.ui_px(SESSION_ROW_SIDE_PADDING) * 2,);let session_status_x = session_x + self.ui_px(SIDEBAR_INSET) + 2;- let session_text_x = session_status_x- + self.ui_px(SESSION_STATUS_ICON_SIZE)- + self.ui_px(SIDEBAR_ICON_GAP)- + 6;for session in &project.threads {let row_top = list_top_f + virtual_y as f32 - scroll_offset;@@ -2251,15 +2503,6 @@ impl crate::TermWindow {let pin_x = delete_x.saturating_sub(action_size + 4);let action_y =y + ((session_row_height.saturating_sub(action_size)) / 2);- let text_right = if is_hovered && !is_renaming_session {- pin_x- } else {- session_x- .saturating_add(session_width)- .saturating_sub(self.ui_px(SIDEBAR_INSET))- };- let text_width = text_right- .saturating_sub(session_text_x + self.ui_px(SIDEBAR_INSET));if is_hovered && !is_selected && !is_renaming_session {self.fill_rounded_rectangle(layers,@@ -2275,16 +2518,35 @@ impl crate::TermWindow {).context("sidebar hovered thread")?;}- self.paint_sidebar_thread_status(- layers,- session,- session_status_x,- y,- session_row_height,- &chrome,- foreground,- suppress_own_active,- )?;+ let shows_actions = is_hovered && !is_renaming_session;+ let surface = if is_selected {+ over(selected_bg, sidebar_bg)+ } else if shows_actions {+ over(chrome.sidebar_row_hover_bg, sidebar_bg)+ } else {+ sidebar_bg+ };+ let (session_text_x, marks_right) = self+ .paint_sidebar_thread_marks(+ layers,+ &row_marks,+ session,+ session_status_x,+ session_x+ .saturating_add(session_width)+ .saturating_sub(self.ui_px(SIDEBAR_INSET)),+ y,+ session_row_height,+ surface,+ !shows_actions,+ false,+ is_selected,+ &chrome,+ foreground,+ )?;+ let text_right = if shows_actions { pin_x } else { marks_right };+ let text_width = text_right+ .saturating_sub(session_text_x + self.ui_px(SIDEBAR_INSET));let session_title =self.sidebar_thread_title(&session.id, &session.name);self.paint_sidebar_text(@@ -2535,10 +2797,6 @@ impl crate::TermWindow {self.ui_px(SIDEBAR_INSET) * 3 + self.ui_px(SESSION_ROW_SIDE_PADDING) * 2,);let session_status_x = session_x + self.ui_px(SIDEBAR_INSET) + 2;- let session_text_x = session_status_x- + self.ui_px(SESSION_STATUS_ICON_SIZE)- + self.ui_px(SIDEBAR_ICON_GAP)- + 6;for reference in &group.threads {let session = &reference.thread;let row_top = list_top_f + virtual_y as f32 - scroll_offset;@@ -2621,25 +2879,33 @@ impl crate::TermWindow {.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 text_right = if is_hovered {- delete_x+ let surface = if is_selected {+ over(selected_bg, sidebar_bg)+ } else if is_hovered {+ over(chrome.sidebar_row_hover_bg, sidebar_bg)} else {+ sidebar_bg+ };+ // A ref whose machine is away says nothing of what+ // it is doing: it keeps its icons, not its mark.+ let (session_text_x, marks_right) = self.paint_sidebar_thread_marks(+ layers,+ &row_marks,+ session,+ session_status_x,session_x.saturating_add(session_width)- .saturating_sub(self.ui_px(SIDEBAR_INSET))- };- if !dimmed {- self.paint_sidebar_thread_status(- layers,- session,- session_status_x,- y,- session_row_height,- &chrome,- foreground,- false,- )?;- }+ .saturating_sub(self.ui_px(SIDEBAR_INSET)),+ y,+ session_row_height,+ surface,+ !is_hovered,+ dimmed,+ is_selected,+ &chrome,+ foreground,+ )?;+ let text_right = if is_hovered { delete_x } else { marks_right };let text_fg = if dimmed {muted_fg.mul_alpha(0.7)} else if is_selected {diff --git a/wezterm-gui/src/thread_marks.rs b/wezterm-gui/src/thread_marks.rsnew file mode 100644index 00000000..78da6ccb--- /dev/null+++ b/wezterm-gui/src/thread_marks.rs@@ -0,0 +1,656 @@+//! What a sidebar thread row shows of its panes: the icons of the programs+//! they run, laid out as Settings says, and the mark at the row's end that+//! says what the thread is doing. Settings draws its choices with the same+//! painters, so what it offers is what the sidebar will show.+//!+//! The icons are the tab icons -- the same cards, picked for a pane the way+//! its tab picks one; only how several of them share a row is new here.++use crate::native_settings::NativeThreadIcons;+use crate::quad::{QuadTrait, TripleLayerQuadAllocator, TripleLayerQuadAllocatorTrait};+use crate::tab_icons::{self, Card, Catalog, GlyphKey, ResolvedIcon, RgbExt as _, TERMINAL_CARD};+use crate::termwindow::ui::tokens::TAB_ICON_GLYPH_RATIO;+use crate::ui::draw::{DrawContext, ShapedText};+use anyhow::Result;+use mux::Mux;+use std::cell::RefCell;+use std::collections::HashMap;+use std::rc::Rc;+use std::sync::atomic::{AtomicU64, Ordering};+use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};+use wezterm_font::LoadedFont;+use window::bitmaps::TextureRect;+use window::color::LinearRgba;++/// The layer everything here is drawn on, in order, so a later icon covers+/// an earlier one.+const LAYER: usize = 2;++/// How long the icons worked out for every thread are trusted when no+/// program said it changed: panes open and close without saying so.+const ICONS_TTL: Duration = Duration::from_secs(1);++/// The marks step on this clock, a little slower than the spinner's 80ms:+/// a spinner turning at the same time costs some repaints of its own.+pub(crate) const MARK_STEP: Duration = Duration::from_millis(100);++/// Steps in one turn of a working mark.+const MARK_STEPS: u64 = 8;++static GENERATION: AtomicU64 = AtomicU64::new(0);++/// A pane started or stopped a program, or an agent came or went: the+/// icons worked out for the threads are stale.+pub(crate) fn programs_changed() {+ GENERATION.fetch_add(1, Ordering::Relaxed);+}++struct Cached {+ generation: u64,+ at: Instant,+ catalog: Rc<Catalog>,+ by_workspace: Rc<HashMap<String, Vec<ResolvedIcon>>>,+}++thread_local! {+ /// One entry, replaced whenever it is rebuilt.+ static CACHE: RefCell<Option<Cached>> = RefCell::new(None);+ /// The counts as shaped, cleared when full.+ static SHAPED: RefCell<ShapedText> = RefCell::new(ShapedText::default());+}++/// The icons of the programs each workspace's panes run, by workspace:+/// agents first, then other programs, the terminal last, and each card+/// once however many panes wear it.+pub(crate) fn icons_by_workspace() -> Rc<HashMap<String, Vec<ResolvedIcon>>> {+ let catalog = tab_icons::catalog();+ let generation = GENERATION.load(Ordering::Relaxed);+ CACHE.with(|slot| {+ let mut slot = slot.borrow_mut();+ if let Some(cached) = slot.as_ref() {+ if cached.generation == generation+ && Rc::ptr_eq(&cached.catalog, &catalog)+ && cached.at.elapsed() < ICONS_TTL+ {+ return Rc::clone(&cached.by_workspace);+ }+ }+ let by_workspace = Rc::new(build(&catalog));+ *slot = Some(Cached {+ generation,+ at: Instant::now(),+ catalog,+ by_workspace: Rc::clone(&by_workspace),+ });+ by_workspace+ })+}++fn rank(card: &Card) -> u8 {+ if !card.agents.is_empty() {+ 0+ } else if card.id == TERMINAL_CARD {+ 2+ } else {+ 1+ }+}++fn build(catalog: &Catalog) -> HashMap<String, Vec<ResolvedIcon>> {+ let mut by_workspace: HashMap<String, Vec<(u8, String, ResolvedIcon)>> = HashMap::new();+ let mux = Mux::get();+ for window_id in mux.iter_windows() {+ let Some(window) = mux.get_window(window_id) else {+ continue;+ };+ let workspace = window.get_workspace().to_string();+ let tabs = window.iter().cloned().collect::<Vec<_>>();+ drop(window);+ let cards = by_workspace.entry(workspace).or_default();+ for tab in tabs {+ for pane in tab.iter_all_panes() {+ let agent = pane.agent_status().filter(|status| !status.ended);+ let card = catalog.card_for(+ agent.as_ref().map(|status| status.agent_id.as_str()),+ pane.foreground_program().as_ref(),+ );+ if !cards.iter().any(|(_, id, _)| *id == card.id) {+ cards.push((rank(card), card.id.clone(), card.resolved()));+ }+ }+ }+ }+ by_workspace+ .into_iter()+ .map(|(workspace, mut cards)| {+ cards.sort_by_key(|(rank, _, _)| *rank);+ (+ workspace,+ cards.into_iter().map(|(_, _, icon)| icon).collect(),+ )+ })+ .collect()+}++// ---------------------------------------------------------------------------+// Icons.++/// The width of the slot a layout keeps at the row's start for icons+/// `diameter` across; the trailing layout keeps none.+pub(crate) fn slot_width(layout: NativeThreadIcons, diameter: f32) -> f32 {+ match layout {+ NativeThreadIcons::Badge => diameter * 1.25,+ NativeThreadIcons::Coins => diameter * 1.35,+ NativeThreadIcons::Cluster => diameter * 1.2,+ NativeThreadIcons::Trailing => 0.0,+ }+}++/// How icons are drawn on a row: what sets one off from another, and what+/// a count is written in.+pub(crate) struct IconStyle<'a> {+ /// The row's colour, ringed round an icon where it covers another.+ pub surface: LinearRgba,+ pub dark: bool,+ pub count_font: &'a Rc<LoadedFont>,+ pub count_metrics: &'a crate::utilsprites::RenderMetrics,+ /// "+N" after trailing icons.+ pub count_color: LinearRgba,+}++/// Draw `icons` in the slot at `x` (see [`slot_width`]) centred on `cy`;+/// the trailing layout is [`draw_trailing`]. An empty list draws nothing.+pub(crate) fn draw_slot(+ ctx: &DrawContext,+ layers: &mut TripleLayerQuadAllocator,+ layout: NativeThreadIcons,+ icons: &[ResolvedIcon],+ x: f32,+ cy: f32,+ diameter: f32,+ style: &IconStyle,+) -> Result<()> {+ let Some(first) = icons.first() else {+ return Ok(());+ };+ let d = diameter;+ let gap = (d * 0.08).round().max(1.0);+ match layout {+ NativeThreadIcons::Badge | NativeThreadIcons::Trailing => {+ let y = cy - d / 2.0;+ draw_icon(ctx, layers, first, x, y, d, style, true, 0.0)?;+ let small = (d * 0.55).round();+ let (bx, by) = (x + d * 0.7, y + d * 0.65);+ match icons.len() {+ 1 => {}+ 2 => draw_icon(ctx, layers, &icons[1], bx, by, small, style, true, gap)?,+ count => draw_count(ctx, layers, count - 1, bx, by, small, style, gap)?,+ }+ }+ NativeThreadIcons::Coins => {+ let y = cy - d / 2.0;+ let shown = icons.len().min(3);+ for (index, icon) in icons[..shown].iter().enumerate().rev() {+ let ring = if index + 1 < shown { gap } else { 0.0 };+ let offset = d * 0.175 * index as f32;+ draw_icon(ctx, layers, icon, x + offset, y, d, style, index == 0, ring)?;+ }+ }+ NativeThreadIcons::Cluster => {+ let side = d * 1.2;+ let top = cy - side / 2.0;+ match icons.len() {+ 1 => draw_icon(ctx, layers, first, x + (side - d) / 2.0, cy - d / 2.0, d, style, true, 0.0)?,+ 2 => {+ let s = (d * 0.75).round();+ draw_icon(ctx, layers, &icons[1], x + side - s, top + side - s, s, style, true, 0.0)?;+ draw_icon(ctx, layers, first, x, top, s, style, true, gap)?;+ }+ count => {+ let s = (d * 0.65).round();+ if count == 3 {+ draw_icon(ctx, layers, &icons[2], x, top + side - s, s, style, true, 0.0)?;+ } else {+ draw_count(ctx, layers, count - 2, x, top + side - s, s, style, 0.0)?;+ }+ draw_icon(ctx, layers, &icons[1], x + side - s, top + side - s, s, style, true, gap)?;+ draw_icon(ctx, layers, first, x + (side - s) / 2.0, top, s, style, true, gap)?;+ }+ }+ }+ }+ Ok(())+}++/// Draw `icons` side by side ending at `right`, the first on top, at most+/// three and a "+N" for the rest. Returns where they start.+pub(crate) fn draw_trailing(+ ctx: &DrawContext,+ layers: &mut TripleLayerQuadAllocator,+ icons: &[ResolvedIcon],+ right: f32,+ cy: f32,+ diameter: f32,+ style: &IconStyle,+) -> Result<f32> {+ if icons.is_empty() {+ return Ok(right);+ }+ let d = diameter;+ let gap = (d * 0.08).round().max(1.0);+ let shown = icons.len().min(3);+ let step = d * 0.75;+ let more = (icons.len() > shown).then(|| format!("+{}", icons.len() - shown));+ let more_width = more+ .as_ref()+ .map(|text| count_text_width(ctx, text, style) + d * 0.15)+ .unwrap_or(0.0);+ let left = (right - more_width - d - step * (shown - 1) as f32).round();+ let y = cy - d / 2.0;+ for (index, icon) in icons[..shown].iter().enumerate().rev() {+ let ring = if index + 1 < shown { gap } else { 0.0 };+ draw_icon(ctx, layers, icon, left + step * index as f32, y, d, style, true, ring)?;+ }+ if let Some(text) = more {+ let x = left + d + step * (shown - 1) as f32 + d * 0.15;+ draw_count_text(ctx, layers, &text, x, cy, style.count_color, style)?;+ }+ Ok(left)+}++/// One icon: its plate, its glyph unless `glyph` is false, and a ring of+/// the row's colour `ring` wide round it when it covers another.+#[allow(clippy::too_many_arguments)]+fn draw_icon(+ ctx: &DrawContext,+ layers: &mut TripleLayerQuadAllocator,+ icon: &ResolvedIcon,+ x: f32,+ y: f32,+ d: f32,+ style: &IconStyle,+ glyph: bool,+ ring: f32,+) -> Result<()> {+ if ring > 0.0 {+ ctx.draw_disc(layers, LAYER, x + d / 2.0, y + d / 2.0, d + ring * 2.0, style.surface)?;+ }+ crate::ui::tile::draw_tile(+ ctx,+ layers,+ LAYER,+ x,+ y,+ d,+ d / 2.0,+ icon.circle.linear(),+ style.dark,+ &tab_icons::PLATE,+ )?;+ if glyph {+ let size = (d * TAB_ICON_GLYPH_RATIO).round();+ tab_icons::draw_glyph(+ ctx,+ layers,+ LAYER,+ &icon.glyph,+ x + (d - size) / 2.0,+ y + (d - size) / 2.0,+ size,+ icon.glyph_color.linear(),+ )?;+ }+ Ok(())+}++/// A neutral disc saying how many more programs there are.+#[allow(clippy::too_many_arguments)]+fn draw_count(+ ctx: &DrawContext,+ layers: &mut TripleLayerQuadAllocator,+ count: usize,+ x: f32,+ y: f32,+ d: f32,+ style: &IconStyle,+ ring: f32,+) -> Result<()> {+ let (cx, cy) = (x + d / 2.0, y + d / 2.0);+ if ring > 0.0 {+ ctx.draw_disc(layers, LAYER, cx, cy, d + ring * 2.0, style.surface)?;+ }+ let disc = if style.dark {+ LinearRgba::with_srgba(72, 72, 74, 255)+ } else {+ LinearRgba::with_srgba(142, 142, 147, 255)+ };+ ctx.draw_disc(layers, LAYER, cx, cy, d, disc)?;+ let text = count.min(99).to_string();+ let width = count_text_width(ctx, &text, style);+ draw_count_text(+ ctx,+ layers,+ &text,+ (cx - width / 2.0).round(),+ cy,+ LinearRgba::with_components(1.0, 1.0, 1.0, 1.0),+ style,+ )+}++/// How wide `text` is in the count font. Counts are shaped once and kept,+/// being drawn every frame.+fn count_text_width(ctx: &DrawContext, text: &str, style: &IconStyle) -> f32 {+ let ctx = ctx.with_metrics(style.count_metrics);+ SHAPED.with(|shaped| {+ ctx.measure_text_width_shaped(style.count_font, text, &mut shaped.borrow_mut())+ })+}++/// `text` in the count font from `x`, its figures centred on `cy`.+#[allow(clippy::too_many_arguments)]+fn draw_count_text(+ ctx: &DrawContext,+ layers: &mut TripleLayerQuadAllocator,+ text: &str,+ x: f32,+ cy: f32,+ color: LinearRgba,+ style: &IconStyle,+) -> Result<()> {+ let ctx = ctx.with_metrics(style.count_metrics);+ SHAPED.with(|shaped| {+ let mut shaped = shaped.borrow_mut();+ let width = ctx.measure_text_width_shaped(style.count_font, text, &mut shaped);+ ctx.draw_text_shaped_on_layer(+ layers,+ LAYER,+ style.count_font,+ x,+ text_top(style.count_metrics, cy),+ text,+ color,+ width + 1.0,+ &mut shaped,+ )+ })+}++/// Where text in `metrics` goes for its digits to sit centred on `cy`.+fn text_top(metrics: &crate::utilsprites::RenderMetrics, cy: f32) -> f32 {+ let baseline = metrics.cell_size.height as f32 + metrics.descender.get() as f32;+ // Figures stand about seven tenths of the ascent tall.+ (cy - baseline + baseline * 0.35).round()+}++// ---------------------------------------------------------------------------+// Marks.++/// The one set of colours a thread's or an agent's state is shown in,+/// wherever it is shown -- the sidebar, the thread search, the Agents+/// panel -- so a colour means the same thing everywhere. An error is the+/// chrome's own danger red.+pub(crate) const WORKING_COLOR: LinearRgba = LinearRgba::with_components(0.12, 0.48, 1.0, 1.0);+/// Waiting on the user: amber, a question rather than something wrong.+pub(crate) const WAITING_COLOR: LinearRgba = LinearRgba::with_components(0.86, 0.45, 0.12, 1.0);+/// A finished result nobody has looked at yet.+pub(crate) const FINISHED_COLOR: LinearRgba = LinearRgba::with_components(0.20, 0.78, 0.36, 1.0);++/// The thread the user is in, at rest or working. It never has an unseen+/// result, being looked at, so the green cannot be mistaken for one.+pub(crate) const CURRENT_COLOR: LinearRgba = FINISHED_COLOR;++/// Open and idle: the blue of working -- a working mark moves, an idle+/// one does not.+pub(crate) const OPEN_COLOR: LinearRgba = WORKING_COLOR;++/// Open with output nobody has seen: brighter than idle.+pub(crate) fn unread_color(text: LinearRgba) -> LinearRgba {+ text.mul_alpha(0.85)+}++/// Saved but not open.+pub(crate) fn closed_color(text: LinearRgba) -> LinearRgba {+ text.mul_alpha(0.16)+}++/// What a thread's mark says.+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub(crate) enum Mark {+ Working,+ Waiting,+ Failed,+ Finished,+ /// Anything else: active, unread, open, closed -- told apart by colour.+ Still,+}++/// Steps of [`MARK_STEP`] since the epoch, so every working mark in every+/// window steps together.+pub(crate) fn mark_step() -> u64 {+ let now = SystemTime::now()+ .duration_since(UNIX_EPOCH)+ .unwrap_or_default();+ (now.as_millis() / MARK_STEP.as_millis()) as u64+}++/// When the working marks next step.+pub(crate) fn next_mark_step() -> Instant {+ let now = SystemTime::now()+ .duration_since(UNIX_EPOCH)+ .unwrap_or_default();+ let step = MARK_STEP.as_millis();+ let into = now.as_millis() % step;+ Instant::now() + Duration::from_millis((step - into) as u64)+}++/// Pixels lit by a still mark, row by row.+const PLUS: [usize; 5] = [1, 3, 4, 5, 7];+const CROSS: [usize; 5] = [0, 2, 4, 6, 8];+/// The ring a working mark runs round, clockwise from the top left.+const RING: [usize; 8] = [0, 1, 2, 5, 8, 7, 6, 3];+/// How lit a pixel of a working mark is, by steps since the run passed it.+const TRAIL: [f32; 4] = [1.0, 0.8, 0.6, 0.39];+const UNLIT: f32 = 0.18;++/// A three-by-three grid of pixels in the `size` square at `x`, `y`.+/// `step` is [`mark_step`] for a mark that moves, `None` for a still+/// picture of one.+#[allow(clippy::too_many_arguments)]+pub(crate) fn draw_pixels(+ ctx: &DrawContext,+ layers: &mut TripleLayerQuadAllocator,+ mark: Mark,+ step: Option<u64>,+ x: f32,+ y: f32,+ size: f32,+ color: LinearRgba,+) -> Result<()> {+ // Three pixels and two gaps a little wider than the square, centred+ // on it; corners round enough to show at this size, as drawing snaps+ // a radius to whole pixels.+ let cell = (size * 0.34).round().max(2.0);+ let gap = (size * 0.1).round().max(1.0);+ let grid = cell * 3.0 + gap * 2.0;+ let left = (x + (size - grid) / 2.0).round();+ let top = (y + (size - grid) / 2.0).round();+ for index in 0..9 {+ let alpha = pixel_alpha(mark, step, index);+ let (column, row) = ((index % 3) as f32, (index / 3) as f32);+ ctx.draw_rounded_rect(+ layers,+ LAYER,+ left + column * (cell + gap),+ top + row * (cell + gap),+ cell,+ cell,+ color.mul_alpha(alpha),+ cell * 0.3,+ )?;+ }+ Ok(())+}++fn pixel_alpha(mark: Mark, step: Option<u64>, index: usize) -> f32 {+ let lit = |pixels: &[usize]| if pixels.contains(&index) { 1.0 } else { UNLIT };+ match mark {+ Mark::Working => {+ let Some(place) = RING.iter().position(|&pixel| pixel == index) else {+ return 0.5;+ };+ // A still picture shows the run three pixels in.+ let step = step.unwrap_or(2);+ let since = (step + MARK_STEPS - place as u64 % MARK_STEPS) % MARK_STEPS;+ TRAIL.get(since as usize).copied().unwrap_or(UNLIT)+ }+ Mark::Failed => lit(&CROSS),+ Mark::Finished => 1.0,+ Mark::Waiting | Mark::Still => lit(&PLUS),+ }+}++/// How high a dot of a working mark is lifted, by steps since the wave+/// reached it.+const LIFT: [f32; 3] = [0.5, 1.0, 0.5];++/// Three dots rising in turn while working, like someone typing; one dot+/// otherwise, in the `size` square at `x`, `y`.+#[allow(clippy::too_many_arguments)]+pub(crate) fn draw_dots(+ ctx: &DrawContext,+ layers: &mut TripleLayerQuadAllocator,+ mark: Mark,+ step: Option<u64>,+ x: f32,+ y: f32,+ size: f32,+ color: LinearRgba,+) -> Result<()> {+ let dot = (size * 0.24).round().max(2.0);+ let cy = y + size / 2.0;+ if mark != Mark::Working {+ return ctx.draw_disc(layers, LAYER, x + size / 2.0, cy, dot, color);+ }+ let gap = ((size - dot * 3.0) / 2.0).max(1.0);+ let left = x + (size - dot * 3.0 - gap * 2.0) / 2.0;+ for index in 0..3u64 {+ let lift = dot_lift(step, index);+ ctx.draw_disc(+ layers,+ LAYER,+ left + dot / 2.0 + (dot + gap) * index as f32,+ cy - lift * size * 0.15,+ dot,+ color.mul_alpha(0.4 + 0.6 * lift),+ )?;+ }+ Ok(())+}++fn dot_lift(step: Option<u64>, index: u64) -> f32 {+ // A still picture shows the wave at the middle dot.+ let step = step.unwrap_or(3);+ let since = (step + MARK_STEPS - (index * 2 + 1) % MARK_STEPS) % MARK_STEPS;+ LIFT.get(since as usize).copied().unwrap_or(0.0)+}++/// A heartbeat trace drawn left to right while working, a flat line+/// otherwise, in the `size` square at `x`, `y`.+#[allow(clippy::too_many_arguments)]+pub(crate) fn draw_pulse(+ ctx: &DrawContext,+ layers: &mut TripleLayerQuadAllocator,+ mark: Mark,+ step: Option<u64>,+ x: f32,+ y: f32,+ size: f32,+ color: LinearRgba,+) -> Result<()> {+ if mark != Mark::Working {+ let thickness = ctx.px(3.2).round().max(1.0);+ let width = (size * 0.85).round();+ return ctx.draw_rounded_rect(+ layers,+ LAYER,+ (x + (size - width) / 2.0).round(),+ (y + (size - thickness) / 2.0).round(),+ width,+ thickness,+ color,+ thickness / 2.0,+ );+ }+ // Drawn out from a third of the way, never from nothing: a trace that+ // has barely begun reads as no mark at all.+ let drawn = match step {+ Some(step) => (0.35 + 0.65 * (step % MARK_STEPS) as f32 / 4.0).min(1.0),+ None => 1.0,+ };+ let glyph = GlyphKey::Builtin(thinkterm_tab_icons::BuiltinGlyph::Activity);+ let sprite = ctx+ .render_state+ .glyph_cache+ .borrow_mut()+ .cached_tab_glyph(&glyph, size.round() as usize)?;+ let Some(sprite) = sprite else {+ return Ok(());+ };+ let coords = sprite.texture_coords();+ let coords = TextureRect::new(+ coords.origin,+ euclid::size2(coords.size.width * drawn, coords.size.height),+ );+ let left_offset = ctx.dimensions.pixel_width as f32 / 2.0;+ let top_offset = ctx.dimensions.pixel_height as f32 / 2.0;+ let mut quad = layers.allocate(LAYER)?;+ quad.set_position(+ x - left_offset,+ y - top_offset,+ x + size * drawn - left_offset,+ y + size - top_offset,+ );+ quad.set_texture(coords);+ quad.set_fg_color(color);+ quad.set_alt_color_and_mix_value(color, 0.0);+ quad.set_hsv(None);+ quad.set_has_color(false);+ quad.set_grayscale();+ Ok(())+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn a_working_mark_runs_round_the_edge_and_leaves_the_middle_half_lit() {+ assert_eq!(pixel_alpha(Mark::Working, Some(0), 0), 1.0);+ assert_eq!(pixel_alpha(Mark::Working, Some(1), 1), 1.0);+ assert_eq!(pixel_alpha(Mark::Working, Some(1), 0), 0.8);+ // Step 3 is at the top right's neighbour below it.+ assert_eq!(pixel_alpha(Mark::Working, Some(3), 5), 1.0);+ assert_eq!(pixel_alpha(Mark::Working, Some(3), 3), UNLIT);+ assert_eq!(pixel_alpha(Mark::Working, Some(7), 4), 0.5);+ assert_eq!(pixel_alpha(Mark::Working, Some(8), 0), 1.0);+ }++ #[test]+ fn working_dots_rise_one_after_another() {+ // Each dot peaks two steps after the one before it.+ assert_eq!(dot_lift(Some(2), 0), 1.0);+ assert_eq!(dot_lift(Some(4), 1), 1.0);+ assert_eq!(dot_lift(Some(6), 2), 1.0);+ assert_eq!(dot_lift(Some(2), 2), 0.0);+ }++ #[test]+ fn still_marks_light_a_plus_a_cross_or_every_pixel() {+ let lit = |mark| (0..9).filter(|&i| pixel_alpha(mark, None, i) == 1.0).collect::<Vec<_>>();+ assert_eq!(lit(Mark::Still), PLUS);+ assert_eq!(lit(Mark::Waiting), PLUS);+ assert_eq!(lit(Mark::Failed), CROSS);+ assert_eq!(lit(Mark::Finished), (0..9).collect::<Vec<_>>());+ }+}diff --git a/wezterm-gui/src/workspace_threads.rs b/wezterm-gui/src/workspace_threads.rsindex 8c22553b..6ee804e1 100644--- a/wezterm-gui/src/workspace_threads.rs+++ b/wezterm-gui/src/workspace_threads.rs@@ -1744,6 +1744,25 @@ pub fn move_thread_to_space(thread_id: &str, target_space_id: &str) -> Option<Mooutcome}+/// [`thread_workspace_name`] for every thread at once, by thread id: for a+/// painter that would otherwise look each row up on its own.+pub fn thread_workspace_names() -> std::collections::HashMap<WorkspaceThreadId, String> {+ let store = THREAD_STORE.lock();+ store+ .projects+ .iter()+ .flat_map(|project| {+ project.threads.iter().map(move |thread| {+ let workspace = thread+ .materialized_workspace_name+ .clone()+ .unwrap_or_else(|| workspace_name_for_thread(&project.id, &thread.id));+ (thread.id.clone(), workspace)+ })+ })+ .collect()+}+/// The workspace `thread_id`'s terminal shows under right now — its/// materialized name, or the one its project derives. The window compares/// this against its own workspace to learn whether an action just detached