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 live terminal overview

RoversX25493da69665
diff --git a/config/src/keyassignment.rs b/config/src/keyassignment.rs
index ecefbeeb..01dac7d5 100644
--- a/config/src/keyassignment.rs
+++ b/config/src/keyassignment.rs
@@ -682,6 +682,7 @@ pub enum KeyAssignment {
OpenUri(String),
OpenSettings,
OpenSshHosts,
+ ToggleLiveOverview,
ActivateCommandPalette,
ActivateWindow(usize),
ActivateWindowRelative(isize),
diff --git a/wezterm-gui/i18n/en-US.ftl b/wezterm-gui/i18n/en-US.ftl
index 472630b3..0936d31a 100644
--- a/wezterm-gui/i18n/en-US.ftl
+++ b/wezterm-gui/i18n/en-US.ftl
@@ -319,6 +319,13 @@ right-confirm-delete-items = Delete { $count } items permanently
right-confirm-delete-name = Delete “{ $name }” permanently
right-confirm-upload = Upload { $count } items
ssh-hosts-title = SSH Hosts
+live-overview-title = Live Overview
+live-overview-offline = Offline
+live-overview-empty = No live terminals
+live-overview-close-title = Close “{ $title }”?
+live-overview-close-detail = Closing it ends all split panes and running programs in this terminal.
+live-overview-close-cancel = Cancel
+live-overview-close-confirm = Close Terminal
ssh-no-hosts = No hosts yet. Click + to add.
ssh-select-host = Select a host, or click + to add a new one.
ssh-search = Search hosts…
diff --git a/wezterm-gui/i18n/fr-FR.ftl b/wezterm-gui/i18n/fr-FR.ftl
index 4db25c52..d0161653 100644
--- a/wezterm-gui/i18n/fr-FR.ftl
+++ b/wezterm-gui/i18n/fr-FR.ftl
@@ -319,6 +319,13 @@ right-confirm-delete-items = Supprimer définitivement { $count } éléments
right-confirm-delete-name = Supprimer définitivement « { $name } »
right-confirm-upload = Envoyer { $count } éléments
ssh-hosts-title = Hôtes SSH
+live-overview-title = Aperçu en direct
+live-overview-offline = Hors ligne
+live-overview-empty = Aucun terminal actif
+live-overview-close-title = Fermer « { $title } » ?
+live-overview-close-detail = Tous les volets et programmes en cours dans ce terminal seront arrêtés.
+live-overview-close-cancel = Annuler
+live-overview-close-confirm = Fermer le terminal
ssh-no-hosts = Aucun hôte. Cliquez sur + pour en ajouter un.
ssh-select-host = Sélectionnez un hôte ou cliquez sur + pour en ajouter un.
ssh-search = Rechercher des hôtes…
diff --git a/wezterm-gui/i18n/ja-JP.ftl b/wezterm-gui/i18n/ja-JP.ftl
index 14480985..af8d69b4 100644
--- a/wezterm-gui/i18n/ja-JP.ftl
+++ b/wezterm-gui/i18n/ja-JP.ftl
@@ -319,6 +319,13 @@ right-confirm-delete-items = { $count } 項目を完全に削除
right-confirm-delete-name = 「{ $name }」を完全に削除
right-confirm-upload = { $count } 項目をアップロード
ssh-hosts-title = SSH ホスト
+live-overview-title = ライブ概要
+live-overview-offline = オフライン
+live-overview-empty = ライブターミナルはありません
+live-overview-close-title = 「{ $title }」を閉じますか?
+live-overview-close-detail = このターミナル内のすべての分割ペインと実行中のプログラムが終了します。
+live-overview-close-cancel = キャンセル
+live-overview-close-confirm = ターミナルを閉じる
ssh-no-hosts = ホストはまだありません。+ をクリックして追加してください。
ssh-select-host = ホストを選択するか、+ をクリックして追加してください。
ssh-search = ホストを検索…
diff --git a/wezterm-gui/i18n/zh-CN.ftl b/wezterm-gui/i18n/zh-CN.ftl
index f02dbb57..a60dd975 100644
--- a/wezterm-gui/i18n/zh-CN.ftl
+++ b/wezterm-gui/i18n/zh-CN.ftl
@@ -319,6 +319,13 @@ right-confirm-delete-items = 永久删除 { $count } 个项目
right-confirm-delete-name = 永久删除“{ $name }”
right-confirm-upload = 上传 { $count } 个项目
ssh-hosts-title = SSH 主机
+live-overview-title = 实时总览
+live-overview-offline = 离线
+live-overview-empty = 暂无实时终端
+live-overview-close-title = 关闭“{ $title }”?
+live-overview-close-detail = 关闭后将结束这个终端中的所有分屏和正在运行的程序。
+live-overview-close-cancel = 取消
+live-overview-close-confirm = 关闭终端
ssh-no-hosts = 还没有主机。点击 + 添加。
ssh-select-host = 选择主机,或点击 + 新建。
ssh-search = 搜索主机…
diff --git a/wezterm-gui/src/commands.rs b/wezterm-gui/src/commands.rs
index 451b39a3..08ef7af7 100644
--- a/wezterm-gui/src/commands.rs
+++ b/wezterm-gui/src/commands.rs
@@ -758,6 +758,14 @@ pub fn derive_command_from_key_assignment(action: &KeyAssignment) -> Option<Comm
menubar: &["Shell"],
icon: Some("md_server_network"),
},
+ ToggleLiveOverview => CommandDef {
+ brief: "Live Overview".into(),
+ doc: "Shows all live ThinkTerm threads grouped by Space".into(),
+ keys: vec![],
+ args: &[ArgType::ActiveWindow],
+ menubar: &["Shell"],
+ icon: Some("cod_multiple_windows"),
+ },
SpawnWindow => CommandDef {
brief: "New Window".into(),
doc: "Launches the default program into a new window".into(),
@@ -2265,6 +2273,7 @@ fn compute_default_actions() -> Vec<KeyAssignment> {
#[cfg(target_os = "macos")]
QuitApplication,
// ----------------- Shell
+ ToggleLiveOverview,
OpenSshHosts,
SpawnTab(SpawnTabDomain::CurrentPaneDomain),
SpawnWindow,
diff --git a/wezterm-gui/src/quad.rs b/wezterm-gui/src/quad.rs
index d51f8978..24709270 100644
--- a/wezterm-gui/src/quad.rs
+++ b/wezterm-gui/src/quad.rs
@@ -5,6 +5,7 @@
use crate::renderstate::BorrowedLayers;
use ::window::bitmaps::TextureRect;
use ::window::color::LinearRgba;
+use ::window::RectF;
use config::HsbTransform;
/// Each cell is composed of two triangles built from 4 vertices.
@@ -100,6 +101,21 @@ pub trait QuadTrait {
fn set_fg_color(&mut self, color: LinearRgba);
+ /// Set an independently colored corner on each vertex. The GPU
+ /// interpolates these colors across the quad, allowing a subtle
+ /// two-dimensional native UI gradient without uploading a texture.
+ fn set_corner_gradient(
+ &mut self,
+ top_left: LinearRgba,
+ top_right: LinearRgba,
+ bottom_left: LinearRgba,
+ bottom_right: LinearRgba,
+ );
+
+ /// Set a smoothly interpolated foreground color from the top edge to the
+ /// bottom edge. Solid-background quads use this for native UI gradients.
+ fn set_vertical_gradient(&mut self, top: LinearRgba, bottom: LinearRgba);
+
/// Must be called after set_fg_color
fn set_alt_color_and_mix_value(&mut self, color: LinearRgba, mix_value: f32);
@@ -134,6 +150,26 @@ impl<'a> QuadTrait for QuadImpl<'a> {
}
}
+ fn set_corner_gradient(
+ &mut self,
+ top_left: LinearRgba,
+ top_right: LinearRgba,
+ bottom_left: LinearRgba,
+ bottom_right: LinearRgba,
+ ) {
+ match self {
+ Self::Vert(q) => q.set_corner_gradient(top_left, top_right, bottom_left, bottom_right),
+ Self::Boxed(q) => q.set_corner_gradient(top_left, top_right, bottom_left, bottom_right),
+ }
+ }
+
+ fn set_vertical_gradient(&mut self, top: LinearRgba, bottom: LinearRgba) {
+ match self {
+ Self::Vert(q) => q.set_vertical_gradient(top, bottom),
+ Self::Boxed(q) => q.set_vertical_gradient(top, bottom),
+ }
+ }
+
fn set_alt_color_and_mix_value(&mut self, color: LinearRgba, mix_value: f32) {
match self {
Self::Vert(q) => q.set_alt_color_and_mix_value(color, mix_value),
@@ -182,6 +218,23 @@ impl<'a> QuadTrait for Quad<'a> {
self.set_alt_color_and_mix_value(color, 0.);
}
+ fn set_corner_gradient(
+ &mut self,
+ top_left: LinearRgba,
+ top_right: LinearRgba,
+ bottom_left: LinearRgba,
+ bottom_right: LinearRgba,
+ ) {
+ self.vert[V_TOP_LEFT].fg_color = top_left.into();
+ self.vert[V_TOP_RIGHT].fg_color = top_right.into();
+ self.vert[V_BOT_LEFT].fg_color = bottom_left.into();
+ self.vert[V_BOT_RIGHT].fg_color = bottom_right.into();
+ }
+
+ fn set_vertical_gradient(&mut self, top: LinearRgba, bottom: LinearRgba) {
+ self.set_corner_gradient(top, top, bottom, bottom);
+ }
+
/// Must be called after set_fg_color
fn set_alt_color_and_mix_value(&mut self, color: LinearRgba, mix_value: f32) {
for v in self.vert.iter_mut() {
@@ -222,10 +275,11 @@ pub trait TripleLayerQuadAllocatorTrait {
/// and the total amount of contiguous memory is in the MB range,
/// which is a bit gnarly to reallocate, and can waste several MB
/// in unused capacity
-#[derive(Default)]
+#[derive(Clone, Default)]
pub struct BoxedQuad {
position: (f32, f32, f32, f32),
fg_color: [f32; 4],
+ fg_color_corners: Option<Box<[[f32; 4]; 4]>>,
alt_color: [f32; 4],
tex: (f32, f32, f32, f32),
hsv: [f32; 3],
@@ -244,6 +298,30 @@ impl QuadTrait for BoxedQuad {
fn set_fg_color(&mut self, color: LinearRgba) {
self.fg_color = color.into();
+ self.fg_color_corners = None;
+ }
+ fn set_corner_gradient(
+ &mut self,
+ top_left: LinearRgba,
+ top_right: LinearRgba,
+ bottom_left: LinearRgba,
+ bottom_right: LinearRgba,
+ ) {
+ let colors = [
+ top_left.into(),
+ top_right.into(),
+ bottom_left.into(),
+ bottom_right.into(),
+ ];
+ self.fg_color = colors[V_TOP_LEFT];
+ self.fg_color_corners = colors
+ .iter()
+ .skip(1)
+ .any(|color| *color != colors[V_TOP_LEFT])
+ .then(|| Box::new(colors));
+ }
+ fn set_vertical_gradient(&mut self, top: LinearRgba, bottom: LinearRgba) {
+ self.set_corner_gradient(top, top, bottom, bottom);
}
fn set_alt_color_and_mix_value(&mut self, color: LinearRgba, mix_value: f32) {
self.alt_color = color.into();
@@ -268,12 +346,24 @@ impl BoxedQuad {
let [left, top] = verts[V_TOP_LEFT].position;
let [right, bottom] = verts[V_BOT_RIGHT].position;
+ let fg_color_corners = [
+ verts[V_TOP_LEFT].fg_color,
+ verts[V_TOP_RIGHT].fg_color,
+ verts[V_BOT_LEFT].fg_color,
+ verts[V_BOT_RIGHT].fg_color,
+ ];
+ let fg_color = fg_color_corners[V_TOP_LEFT];
Self {
tex: (x1, x2, y1, y2),
position: (left, top, right, bottom),
has_color: verts[V_TOP_LEFT].has_color,
alt_color: verts[V_TOP_LEFT].alt_color,
- fg_color: verts[V_TOP_LEFT].fg_color,
+ fg_color,
+ fg_color_corners: fg_color_corners
+ .iter()
+ .skip(1)
+ .any(|color| *color != fg_color)
+ .then(|| Box::new(fg_color_corners)),
hsv: verts[V_TOP_LEFT].hsv,
mix_value: verts[V_TOP_LEFT].mix_value,
}
@@ -296,16 +386,95 @@ impl BoxedQuad {
saturation,
brightness,
}));
- quad.set_fg_color(LinearRgba::with_components(
- self.fg_color[0],
- self.fg_color[1],
- self.fg_color[2],
- self.fg_color[3],
- ));
+ if let Some(colors) = self.fg_color_corners.as_deref() {
+ quad.set_corner_gradient(
+ colors[V_TOP_LEFT].into(),
+ colors[V_TOP_RIGHT].into(),
+ colors[V_BOT_LEFT].into(),
+ colors[V_BOT_RIGHT].into(),
+ );
+ } else {
+ quad.set_fg_color(self.fg_color.into());
+ }
quad.set_alt_color_and_mix_value(self.alt_color.into(), self.mix_value);
vert
}
+
+ fn clipped_to(&self, clip: (f32, f32, f32, f32)) -> Option<Self> {
+ let (left, top, right, bottom) = self.position;
+ let (clip_left, clip_top, clip_right, clip_bottom) = clip;
+ if !(right > left && bottom > top && clip_right > clip_left && clip_bottom > clip_top) {
+ return None;
+ }
+
+ let visible_left = left.max(clip_left);
+ let visible_top = top.max(clip_top);
+ let visible_right = right.min(clip_right);
+ let visible_bottom = bottom.min(clip_bottom);
+ if visible_right <= visible_left || visible_bottom <= visible_top {
+ return None;
+ }
+ if visible_left == left
+ && visible_top == top
+ && visible_right == right
+ && visible_bottom == bottom
+ {
+ return Some(self.clone());
+ }
+
+ let x0 = (visible_left - left) / (right - left);
+ let x1 = (visible_right - left) / (right - left);
+ let y0 = (visible_top - top) / (bottom - top);
+ let y1 = (visible_bottom - top) / (bottom - top);
+ let (u0, u1, v0, v1) = self.tex;
+ let source_colors = self
+ .fg_color_corners
+ .as_deref()
+ .copied()
+ .unwrap_or([self.fg_color; VERTICES_PER_CELL]);
+ let clipped_colors = [
+ bilerp_color(source_colors, x0, y0),
+ bilerp_color(source_colors, x1, y0),
+ bilerp_color(source_colors, x0, y1),
+ bilerp_color(source_colors, x1, y1),
+ ];
+ let fg_color = clipped_colors[V_TOP_LEFT];
+
+ Some(Self {
+ position: (visible_left, visible_top, visible_right, visible_bottom),
+ fg_color,
+ fg_color_corners: clipped_colors
+ .iter()
+ .skip(1)
+ .any(|color| *color != fg_color)
+ .then(|| Box::new(clipped_colors)),
+ alt_color: self.alt_color,
+ tex: (
+ lerp(u0, u1, x0),
+ lerp(u0, u1, x1),
+ lerp(v0, v1, y0),
+ lerp(v0, v1, y1),
+ ),
+ hsv: self.hsv,
+ has_color: self.has_color,
+ mix_value: self.mix_value,
+ })
+ }
+}
+
+fn lerp(start: f32, end: f32, amount: f32) -> f32 {
+ start + (end - start) * amount
+}
+
+fn lerp_color(start: [f32; 4], end: [f32; 4], amount: f32) -> [f32; 4] {
+ std::array::from_fn(|index| lerp(start[index], end[index], amount))
+}
+
+fn bilerp_color(corners: [[f32; 4]; 4], x: f32, y: f32) -> [f32; 4] {
+ let top = lerp_color(corners[V_TOP_LEFT], corners[V_TOP_RIGHT], x);
+ let bottom = lerp_color(corners[V_BOT_LEFT], corners[V_BOT_RIGHT], x);
+ lerp_color(top, bottom, y)
}
#[derive(Default)]
@@ -332,6 +501,39 @@ impl HeapQuadAllocator {
metrics::histogram!("quad_buffer_apply").record(start.elapsed());
Ok(())
}
+
+ /// Copy these heap-backed quads into `other`, hard-clipped to a surface
+ /// pixel rectangle. Position, texture coordinates and per-corner colors are
+ /// cropped together, so glyphs and gradients retain their original shape.
+ pub fn apply_to_clipped(
+ &self,
+ other: &mut TripleLayerQuadAllocator,
+ clip: RectF,
+ surface_width: f32,
+ surface_height: f32,
+ ) -> anyhow::Result<()> {
+ if clip.size.width <= 0.0 || clip.size.height <= 0.0 {
+ return Ok(());
+ }
+ let left_offset = surface_width / 2.0;
+ let top_offset = surface_height / 2.0;
+ let centered_clip = (
+ clip.min_x() - left_offset,
+ clip.min_y() - top_offset,
+ clip.max_x() - left_offset,
+ clip.max_y() - top_offset,
+ );
+ let start = std::time::Instant::now();
+ for (layer_num, quads) in [(0, &self.layer0), (1, &self.layer1), (2, &self.layer2)] {
+ for quad in quads {
+ if let Some(clipped) = quad.clipped_to(centered_clip) {
+ other.extend_with(layer_num, &clipped.to_vertices());
+ }
+ }
+ }
+ metrics::histogram!("quad_buffer_apply_clipped").record(start.elapsed());
+ Ok(())
+ }
}
impl TripleLayerQuadAllocatorTrait for HeapQuadAllocator {
@@ -399,5 +601,93 @@ impl<'a> TripleLayerQuadAllocatorTrait for TripleLayerQuadAllocator<'a> {
#[test]
fn size() {
assert_eq!(std::mem::size_of::<Vertex>() * VERTICES_PER_CELL, 272);
- assert_eq!(std::mem::size_of::<BoxedQuad>(), 84);
+ assert_eq!(std::mem::size_of::<BoxedQuad>(), 96);
+}
+
+#[cfg(test)]
+#[test]
+fn boxed_quad_preserves_vertical_gradient_colors() {
+ let top = LinearRgba::with_components(0.1, 0.2, 0.3, 1.0);
+ let bottom = LinearRgba::with_components(0.4, 0.5, 0.6, 1.0);
+ let mut quad = BoxedQuad::default();
+ quad.set_vertical_gradient(top, bottom);
+ let vertices = quad.to_vertices();
+ let top: [f32; 4] = top.into();
+ let bottom: [f32; 4] = bottom.into();
+ assert_eq!(vertices[V_TOP_LEFT].fg_color, top);
+ assert_eq!(vertices[V_TOP_RIGHT].fg_color, top);
+ assert_eq!(vertices[V_BOT_LEFT].fg_color, bottom);
+ assert_eq!(vertices[V_BOT_RIGHT].fg_color, bottom);
+}
+
+#[cfg(test)]
+#[test]
+fn boxed_quad_preserves_corner_gradient_colors() {
+ let top_left = LinearRgba::with_components(0.1, 0.2, 0.3, 1.0);
+ let top_right = LinearRgba::with_components(0.2, 0.3, 0.4, 1.0);
+ let bottom_left = LinearRgba::with_components(0.3, 0.4, 0.5, 1.0);
+ let bottom_right = LinearRgba::with_components(0.4, 0.5, 0.6, 1.0);
+ let mut quad = BoxedQuad::default();
+ quad.set_corner_gradient(top_left, top_right, bottom_left, bottom_right);
+ let vertices = quad.to_vertices();
+ assert_eq!(vertices[V_TOP_LEFT].fg_color, <[f32; 4]>::from(top_left));
+ assert_eq!(vertices[V_TOP_RIGHT].fg_color, <[f32; 4]>::from(top_right));
+ assert_eq!(vertices[V_BOT_LEFT].fg_color, <[f32; 4]>::from(bottom_left));
+ assert_eq!(
+ vertices[V_BOT_RIGHT].fg_color,
+ <[f32; 4]>::from(bottom_right)
+ );
+}
+
+#[cfg(test)]
+#[test]
+fn boxed_quad_keeps_solid_colors_inline() {
+ let color = LinearRgba::with_components(0.1, 0.2, 0.3, 1.0);
+ let mut quad = BoxedQuad::default();
+ quad.set_fg_color(color);
+ assert!(quad.fg_color_corners.is_none());
+ quad.set_vertical_gradient(color, color);
+ assert!(quad.fg_color_corners.is_none());
+}
+
+#[cfg(test)]
+#[test]
+fn boxed_quad_clip_crops_position_texture_and_gradient_together() {
+ let mut quad = BoxedQuad::default();
+ quad.set_position(0.0, 0.0, 100.0, 80.0);
+ quad.set_texture_discrete(0.1, 0.9, 0.2, 0.6);
+ quad.set_corner_gradient(
+ LinearRgba::with_components(0.0, 0.0, 0.0, 1.0),
+ LinearRgba::with_components(1.0, 0.0, 0.0, 1.0),
+ LinearRgba::with_components(0.0, 1.0, 0.0, 1.0),
+ LinearRgba::with_components(1.0, 1.0, 0.0, 1.0),
+ );
+
+ let clipped = quad.clipped_to((25.0, 20.0, 75.0, 60.0)).unwrap();
+ assert_eq!(clipped.position, (25.0, 20.0, 75.0, 60.0));
+ for (actual, expected) in std::iter::zip(
+ [clipped.tex.0, clipped.tex.1, clipped.tex.2, clipped.tex.3]
+ .iter()
+ .copied(),
+ [0.3, 0.7, 0.3, 0.5].iter().copied(),
+ ) {
+ assert!((actual - expected).abs() < 0.000_001);
+ }
+ let colors = clipped.fg_color_corners.unwrap();
+ assert_eq!(colors[V_TOP_LEFT], [0.25, 0.25, 0.0, 1.0]);
+ assert_eq!(colors[V_TOP_RIGHT], [0.75, 0.25, 0.0, 1.0]);
+ assert_eq!(colors[V_BOT_LEFT], [0.25, 0.75, 0.0, 1.0]);
+ assert_eq!(colors[V_BOT_RIGHT], [0.75, 0.75, 0.0, 1.0]);
+}
+
+#[cfg(test)]
+#[test]
+fn boxed_quad_clip_rejects_outside_and_preserves_inside() {
+ let mut quad = BoxedQuad::default();
+ quad.set_position(10.0, 20.0, 30.0, 40.0);
+ quad.set_texture_discrete(0.2, 0.6, 0.3, 0.7);
+ assert!(quad.clipped_to((30.0, 0.0, 50.0, 50.0)).is_none());
+ let inside = quad.clipped_to((0.0, 0.0, 50.0, 50.0)).unwrap();
+ assert_eq!(inside.position, quad.position);
+ assert_eq!(inside.tex, quad.tex);
}
diff --git a/wezterm-gui/src/termwindow/content_view.rs b/wezterm-gui/src/termwindow/content_view.rs
index 231cc728..9a6647df 100644
--- a/wezterm-gui/src/termwindow/content_view.rs
+++ b/wezterm-gui/src/termwindow/content_view.rs
@@ -6,15 +6,69 @@
use crate::quad::TripleLayerQuadAllocator;
use crate::termwindow::TermWindow;
use crate::ui::{DrawContext, UiPalette};
+use mux::pane::PaneId;
+use mux::renderable::{RenderableDimensions, StableCursorPosition};
+use mux::tab::PositionedSplit;
use std::path::PathBuf;
use std::rc::Rc;
+use std::sync::Arc;
use std::time::Instant;
use wezterm_font::LoadedFont;
-use wezterm_term::{KeyCode, KeyModifiers};
+use wezterm_term::color::ColorPalette;
+use wezterm_term::{KeyCode, KeyModifiers, Line, StableRowIndex, TerminalSize};
use window::{MouseEventKind as WMEK, RectF};
pub(crate) type ContentViewId = u64;
+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
+pub(crate) enum ContentViewPresentation {
+ #[default]
+ ContentArea,
+ FullWindow,
+}
+
+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
+pub(crate) enum ContentViewTypography {
+ #[default]
+ Default,
+ Overview,
+}
+
+/// Immutable terminal state captured once by the owning ContentView. The
+/// renderer consumes this value without looking the tab up in the mux again,
+/// so a transient detach cannot turn a card into a blank rectangle halfway
+/// through a frame.
+#[derive(Clone, Debug)]
+pub(crate) struct TerminalPreviewSnapshot {
+ pub tab_size: TerminalSize,
+ pub panes: Vec<TerminalPreviewPaneSnapshot>,
+ pub splits: Vec<PositionedSplit>,
+}
+
+#[derive(Clone, Debug)]
+pub(crate) struct TerminalPreviewPaneSnapshot {
+ pub pane_id: PaneId,
+ pub is_active: bool,
+ pub left: usize,
+ pub top: usize,
+ pub width: usize,
+ pub height: usize,
+ pub cols: usize,
+ pub rows: usize,
+ pub resolved_top: StableRowIndex,
+ pub lines: Vec<Line>,
+ pub dimensions: RenderableDimensions,
+ pub palette: ColorPalette,
+ pub cursor: StableCursorPosition,
+}
+
+#[derive(Clone, Debug)]
+pub(crate) struct TerminalPreviewRequest {
+ pub snapshot: Arc<TerminalPreviewSnapshot>,
+ pub area: RectF,
+ pub clip: RectF,
+}
+
/// Progress of an SSH connection that a content view kicked off, pushed by the
/// owning `TermWindow` while it polls the remote domain. Only the remote-thread
/// view consumes it; `Authenticating`/`Connected` are not pushed because at that
@@ -46,6 +100,34 @@ pub(crate) trait ContentView {
true
}
+ /// How much of the native window this view owns while it is foreground.
+ /// Full-window views preserve the OS title bar but temporarily suppress
+ /// ThinkTerm's tab bar and sidebars without changing their saved state.
+ fn presentation(&self) -> ContentViewPresentation {
+ ContentViewPresentation::ContentArea
+ }
+
+ /// Paint the background for the complete client surface before the view's
+ /// safe content area is laid out. Full-window views can use this to blend
+ /// through the native title-bar region without placing controls beneath
+ /// the traffic lights.
+ fn paint_surface_background(
+ &mut self,
+ _ctx: &DrawContext,
+ _layers: &mut TripleLayerQuadAllocator<'_>,
+ _surface: RectF,
+ _palette: UiPalette,
+ ) -> anyhow::Result<()> {
+ Ok(())
+ }
+
+ /// Select a native chrome font role rather than inventing view-local font
+ /// sizes. Overview uses the same sidebar, pane-header and settings roles
+ /// as the rest of ThinkTerm.
+ fn typography(&self) -> ContentViewTypography {
+ ContentViewTypography::Default
+ }
+
/// Stable key used to activate an existing tab instead of opening a duplicate.
fn tab_key(&self) -> Option<String> {
None
@@ -78,6 +160,43 @@ pub(crate) trait ContentView {
None
}
+ /// Inform the active view that the native window is in an interactive
+ /// resize. Returning true means the state changed and a final repaint is
+ /// required even if the last resize event repeats the same dimensions.
+ fn set_live_resizing(&mut self, _live_resizing: bool) -> bool {
+ false
+ }
+
+ /// Terminal tabs to paint as read-only live thumbnails after the view's
+ /// regular UI layers have been prepared.
+ fn terminal_previews(&self) -> Vec<TerminalPreviewRequest> {
+ Vec::new()
+ }
+
+ /// Paint masks and chrome that must sit above terminal preview glyphs.
+ /// Most ContentViews do not embed terminal snapshots and need no second
+ /// pass.
+ #[allow(clippy::too_many_arguments)]
+ fn paint_after_terminal_previews(
+ &mut self,
+ _ctx: &DrawContext,
+ _layers: &mut TripleLayerQuadAllocator<'_>,
+ _area: RectF,
+ _palette: UiPalette,
+ _font: &Rc<LoadedFont>,
+ _title_font: &Rc<LoadedFont>,
+ _section_font: &Rc<LoadedFont>,
+ ) -> anyhow::Result<()> {
+ Ok(())
+ }
+
+ /// Whether output from this pane should invalidate the view. Normal
+ /// content views do not display panes; Live Overview opts in only for the
+ /// previews currently intersecting its viewport.
+ fn wants_pane_output(&self, _pane_id: PaneId) -> bool {
+ false
+ }
+
/// Paint the view into `area` (the terminal content rect). `cursor_on` is
/// the current blink phase for any focused caret.
fn paint(
@@ -123,3 +242,48 @@ pub(crate) trait ContentView {
None
}
}
+
+/// ContentViews defer mux geometry while they own the foreground. Consume the
+/// deferred resize only on the transition back to terminal content; opening
+/// and closing a view without an intervening size change is a strict no-op.
+pub(crate) fn take_deferred_mux_resize_on_exit(
+ deferred: &mut bool,
+ was_foreground: bool,
+ is_foreground: bool,
+) -> bool {
+ if was_foreground && !is_foreground && *deferred {
+ *deferred = false;
+ true
+ } else {
+ false
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::take_deferred_mux_resize_on_exit;
+
+ #[test]
+ fn deferred_mux_resize_flushes_once_on_terminal_return() {
+ let mut deferred = true;
+ assert!(!take_deferred_mux_resize_on_exit(&mut deferred, true, true));
+ assert!(deferred);
+ assert!(take_deferred_mux_resize_on_exit(&mut deferred, true, false));
+ assert!(!deferred);
+ assert!(!take_deferred_mux_resize_on_exit(
+ &mut deferred,
+ true,
+ false
+ ));
+ }
+
+ #[test]
+ fn closing_unresized_content_view_does_not_touch_mux_geometry() {
+ let mut deferred = false;
+ assert!(!take_deferred_mux_resize_on_exit(
+ &mut deferred,
+ true,
+ false
+ ));
+ }
+}
diff --git a/wezterm-gui/src/termwindow/keyevent.rs b/wezterm-gui/src/termwindow/keyevent.rs
index 9b822e4e..4c76222b 100644
--- a/wezterm-gui/src/termwindow/keyevent.rs
+++ b/wezterm-gui/src/termwindow/keyevent.rs
@@ -188,6 +188,34 @@ enum OnlyKeyBindings {
No,
}
+fn content_view_consumes_unhandled_key(
+ only_key_bindings: OnlyKeyBindings,
+ content_view_foreground: bool,
+) -> bool {
+ only_key_bindings == OnlyKeyBindings::No && content_view_foreground
+}
+
+#[cfg(test)]
+mod content_view_key_routing_tests {
+ use super::{content_view_consumes_unhandled_key, OnlyKeyBindings};
+
+ #[test]
+ fn foreground_content_view_owns_unhandled_terminal_input() {
+ assert!(content_view_consumes_unhandled_key(
+ OnlyKeyBindings::No,
+ true
+ ));
+ assert!(!content_view_consumes_unhandled_key(
+ OnlyKeyBindings::Yes,
+ true
+ ));
+ assert!(!content_view_consumes_unhandled_key(
+ OnlyKeyBindings::No,
+ false
+ ));
+ }
+}
+
impl super::TermWindow {
fn paste_text_into_inline_tab_rename(&mut self, text: &str) {
if let Some(rename) = self.inline_tab_rename.as_mut() {
@@ -614,6 +642,14 @@ impl super::TermWindow {
return true;
}
+ // Foreground content views get first refusal above, followed by the
+ // application's configured key bindings. If neither handled the
+ // event, the view still owns it: falling through here would encode the
+ // press/release for the terminal pane hidden underneath the view.
+ if content_view_consumes_unhandled_key(only_key_bindings, self.content_view_foreground()) {
+ return true;
+ }
+
// While the leader modifier is active, only registered
// keybindings are recognized.
let only_key_bindings = match (only_key_bindings, leader_active) {
diff --git a/wezterm-gui/src/termwindow/live_overview.rs b/wezterm-gui/src/termwindow/live_overview.rs
new file mode 100644
index 00000000..8cbc544d
--- /dev/null
+++ b/wezterm-gui/src/termwindow/live_overview.rs
@@ -0,0 +1,2156 @@
+use crate::quad::TripleLayerQuadAllocator;
+use crate::termwindow::content_view::{
+ ContentView, ContentViewPresentation, ContentViewResponse, ContentViewTypography,
+ TerminalPreviewPaneSnapshot, TerminalPreviewRequest, TerminalPreviewSnapshot,
+};
+use crate::termwindow::ui::icons::SvgIcon;
+use crate::termwindow::{TermWindow, TermWindowNotif};
+use crate::ui::{
+ draw_button_on_layer, draw_icon_button, draw_icon_button_on_layer, draw_scrollbar_on_layer,
+ wheel_delta_pixels, ButtonSpec, ControlState, DrawContext, InteractionState, ScrollState,
+ UiContext, UiPalette, UiTokens, WidgetKind,
+};
+use crate::workspace_threads;
+use fluent_bundle::FluentArgs;
+use mux::domain::DomainState;
+use mux::pane::{CloseReason, PaneId};
+use mux::renderable::{RenderableDimensions, StableCursorPosition};
+use mux::tab::{PositionedSplit, TabId};
+use mux::Mux;
+use std::collections::{HashMap, HashSet};
+use std::hash::{DefaultHasher, Hash, Hasher};
+use std::rc::Rc;
+use std::sync::Arc;
+use std::time::{Duration, Instant};
+use wezterm_client::domain::FrontendRecoverySlot;
+use wezterm_font::LoadedFont;
+use wezterm_term::{KeyCode, KeyModifiers, TerminalSize};
+use window::color::LinearRgba;
+use window::{Appearance, MouseEventKind as WMEK, MousePress, RectF, WindowOps};
+
+pub(crate) const LIVE_OVERVIEW_CONTENT_VIEW_KEY: &str = "live-overview";
+
+// All geometry is authored in ThinkTerm's 2x macOS backing-pixel design grid
+// and converted through DrawContext::px. 3000 design pixels equal 1500 logical
+// window pixels on every supported DPI; this is a breakpoint, not a content
+// max-width.
+const PAGE_PAD_X: f32 = 84.0;
+const PAGE_PAD_TOP: f32 = 40.0;
+const PAGE_PAD_BOTTOM: f32 = 44.0;
+const GROUP_HEADER_HEIGHT: f32 = 42.0;
+const GROUP_TITLE_CARD_GAP: f32 = 8.0;
+const GROUP_GAP: f32 = 48.0;
+const CARD_GAP: f32 = 16.0;
+const CARD_MIN_WIDTH: f32 = 400.0;
+const CARD_ORPHAN_COMFORT_WIDTH: f32 = 480.0;
+const CARD_MAX_WIDTH: f32 = 640.0;
+const CARD_HEADER_HEIGHT: f32 = 44.0;
+const CARD_RADIUS: f32 = 18.0;
+const CARD_INSET: f32 = 8.0;
+const CARD_CLOSE_BUTTON_SIZE: f32 = 32.0;
+const CARD_CLOSE_RIGHT_PAD: f32 = 8.0;
+const CARD_TITLE_CLOSE_GAP: f32 = 8.0;
+const PREVIEW_RADIUS: f32 = 12.0;
+const CLOSE_BUTTON_SIZE: f32 = 44.0;
+const CONFIRM_MIN_WIDTH: f32 = 640.0;
+const CONFIRM_MAX_WIDTH: f32 = 880.0;
+const CONFIRM_SIDE_MARGIN: f32 = 64.0;
+const CONFIRM_PADDING: f32 = 36.0;
+const CONFIRM_RADIUS: f32 = 24.0;
+const CONFIRM_TEXT_GAP: f32 = 18.0;
+const CONFIRM_BUTTON_GAP: f32 = 12.0;
+const MAX_COLUMNS: usize = 5;
+const MAX_COLUMNS_BELOW_WIDE_BREAKPOINT: usize = 4;
+const FIVE_COLUMN_WINDOW_WIDTH: f32 = 3000.0;
+const LIVE_RESIZE_PREVIEW_INTERVAL: Duration = Duration::from_millis(33);
+const SCROLLBAR_VISIBLE_INTERVAL: Duration = Duration::from_millis(900);
+const SCROLL_MASK_FADE_HEIGHT: f32 = 32.0;
+
+#[derive(Clone, Debug, PartialEq, Eq, Hash)]
+struct LiveThreadKey {
+ space_id: String,
+ thread_id: String,
+}
+
+#[derive(Clone, Debug, PartialEq, Eq)]
+struct TerminalPreviewFingerprint {
+ tab_id: TabId,
+ tab_size: TerminalSize,
+ panes: Vec<TerminalPreviewPaneFingerprint>,
+ splits: Vec<PositionedSplit>,
+}
+
+#[derive(Clone, Debug, PartialEq, Eq)]
+struct TerminalPreviewPaneFingerprint {
+ pane_id: PaneId,
+ index: usize,
+ is_active: bool,
+ is_zoomed: bool,
+ left: usize,
+ top: usize,
+ width: usize,
+ height: usize,
+ dimensions: RenderableDimensions,
+ seqno: usize,
+ palette_identity: u64,
+ cursor: StableCursorPosition,
+}
+
+#[derive(Clone, Debug)]
+struct CachedPreview<T> {
+ fingerprint: TerminalPreviewFingerprint,
+ snapshot: Arc<T>,
+ captured_at: Instant,
+}
+
+#[derive(Clone, Debug)]
+struct LiveCard {
+ key: LiveThreadKey,
+ title: String,
+ tab_id: TabId,
+ active: bool,
+}
+
+#[derive(Clone, Debug)]
+struct LiveGroup {
+ name: String,
+ offline: bool,
+ cards: Vec<LiveCard>,
+}
+
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+enum OverviewAction {
+ CloseOverview,
+ OpenThread(TabId),
+ CloseTab(TabId),
+ ConfirmCloseTab,
+ CancelCloseTab,
+}
+
+#[derive(Clone, Debug, PartialEq, Eq)]
+struct PendingClose {
+ tab_id: TabId,
+ title: String,
+}
+
+#[derive(Clone, Copy, Debug)]
+struct GroupGrid {
+ columns: usize,
+ rows: usize,
+ card_width: f32,
+ card_height: f32,
+}
+
+#[derive(Clone, Copy, Debug)]
+struct GroupLayout {
+ header_y: f32,
+ cards_y: f32,
+ grid: GroupGrid,
+}
+
+#[derive(Clone, Copy, Debug)]
+struct CardChrome {
+ preview: RectF,
+ clip: RectF,
+ fill: LinearRgba,
+ border: LinearRgba,
+}
+
+#[derive(Clone, Copy, Debug)]
+struct OverviewColors {
+ surface_top_left: LinearRgba,
+ surface_top_right: LinearRgba,
+ surface_bottom_left: LinearRgba,
+ surface_bottom_right: LinearRgba,
+ card: LinearRgba,
+ card_hover: LinearRgba,
+ card_pressed: LinearRgba,
+ shadow: LinearRgba,
+ preview: LinearRgba,
+ preview_border: LinearRgba,
+ active_border: LinearRgba,
+ modal_scrim: LinearRgba,
+}
+
+pub(crate) struct LiveOverviewView {
+ owner_id: u64,
+ active: Option<LiveThreadKey>,
+ host_preview_aspect: f32,
+ scroll: ScrollState,
+ last_ui_scale: f32,
+ viewport: RectF,
+ widgets: UiContext<OverviewAction>,
+ interaction: InteractionState<OverviewAction>,
+ card_keys: HashMap<TabId, LiveThreadKey>,
+ card_titles: HashMap<TabId, String>,
+ pending_close: Option<PendingClose>,
+ snapshot_cache: HashMap<LiveThreadKey, CachedPreview<TerminalPreviewSnapshot>>,
+ previews: Vec<TerminalPreviewRequest>,
+ preview_chrome: Vec<CardChrome>,
+ visible_panes: HashSet<PaneId>,
+ live_resizing: bool,
+ next_preview_refresh: Option<Instant>,
+ scrollbar_visible_until: Option<Instant>,
+}
+
+impl LiveOverviewView {
+ pub(crate) fn new(
+ owner_id: u64,
+ active_space_id: &str,
+ active_workspace: &str,
+ host_preview_aspect: f32,
+ ) -> Self {
+ Self {
+ owner_id,
+ active: workspace_threads::thread_id_for_workspace(active_space_id, active_workspace)
+ .map(|thread_id| LiveThreadKey {
+ space_id: active_space_id.to_string(),
+ thread_id,
+ }),
+ // Extremely narrow/tall terminals still need a useful overview;
+ // within this safety range every card keeps the exact same host
+ // aspect instead of inheriting a source mux tab's split geometry.
+ host_preview_aspect: host_preview_aspect.clamp(1.2, 3.4),
+ scroll: ScrollState::new(),
+ last_ui_scale: 1.0,
+ viewport: euclid::rect(0.0, 0.0, 0.0, 0.0),
+ widgets: UiContext::default(),
+ interaction: InteractionState::default(),
+ card_keys: HashMap::new(),
+ card_titles: HashMap::new(),
+ pending_close: None,
+ snapshot_cache: HashMap::new(),
+ previews: Vec::new(),
+ preview_chrome: Vec::new(),
+ visible_panes: HashSet::new(),
+ live_resizing: false,
+ next_preview_refresh: None,
+ scrollbar_visible_until: None,
+ }
+ }
+
+ fn collect_groups(&self) -> Vec<LiveGroup> {
+ let mux = Mux::get();
+ let live_workspaces = mux.iter_workspaces();
+ let mut groups = Vec::new();
+
+ for space in workspace_threads::spaces_for_window(self.owner_id) {
+ let offline = space.domain.as_deref().is_some_and(|domain_name| {
+ mux.get_domain_by_name(domain_name)
+ .is_none_or(|domain| domain.state() != DomainState::Attached)
+ });
+ let mut cards = Vec::new();
+
+ if !offline {
+ for project_id in workspace_threads::ordered_project_ids(&space.id) {
+ for thread_id in workspace_threads::ordered_thread_ids(&project_id) {
+ let Some(state) = workspace_threads::thread_connection_state(
+ &thread_id,
+ &live_workspaces,
+ ) else {
+ continue;
+ };
+ if state.space_id != space.id || !state.is_live {
+ continue;
+ }
+
+ let key = LiveThreadKey {
+ space_id: space.id.clone(),
+ thread_id: state.thread_id.clone(),
+ };
+ let Some(tab_id) = live_tab_for_workspace(&state.workspace_name) else {
+ continue;
+ };
+
+ cards.push(LiveCard {
+ active: self.active.as_ref() == Some(&key),
+ key,
+ title: card_title(&state.project_name, &state.thread_name),
+ tab_id,
+ });
+ }
+ }
+ }
+
+ // Online empty Spaces add no information to a live-only overview.
+ // Keep an offline remote Space so the missing cards have an
+ // explicit cause rather than silently displaying stale snapshots.
+ if !cards.is_empty() || offline {
+ groups.push(LiveGroup {
+ name: space.name,
+ offline,
+ cards,
+ });
+ }
+ }
+
+ groups
+ }
+
+ #[allow(clippy::too_many_arguments)]
+ fn paint_impl(
+ &mut self,
+ ctx: &DrawContext,
+ layers: &mut TripleLayerQuadAllocator<'_>,
+ area: RectF,
+ palette: UiPalette,
+ settings_font: &Rc<LoadedFont>,
+ group_font: &Rc<LoadedFont>,
+ card_font: &Rc<LoadedFont>,
+ ) -> anyhow::Result<()> {
+ self.last_ui_scale = ctx.scale();
+ self.widgets.clear();
+ self.card_keys.clear();
+ self.card_titles.clear();
+ self.previews.clear();
+ self.preview_chrome.clear();
+ self.visible_panes.clear();
+ self.next_preview_refresh = None;
+
+ let appearance = crate::native_settings::effective_appearance();
+ let colors = overview_colors(appearance);
+
+ let pad = horizontal_page_pad(ctx, area);
+ let content_x = area.origin.x + pad;
+ let content_width = (area.size.width - pad * 2.0).max(1.0);
+ let viewport_top = area.origin.y + ctx.px(PAGE_PAD_TOP);
+ let viewport_bottom = (area.max_y() - ctx.px(PAGE_PAD_BOTTOM)).max(viewport_top);
+ self.viewport = euclid::rect(
+ content_x,
+ viewport_top,
+ content_width,
+ viewport_bottom - viewport_top,
+ );
+
+ let settings_line_height =
+ crate::utilsprites::RenderMetrics::with_font_metrics(&settings_font.metrics())
+ .cell_size
+ .height as f32;
+ let group_line_height =
+ crate::utilsprites::RenderMetrics::with_font_metrics(&group_font.metrics())
+ .cell_size
+ .height as f32;
+ let card_line_height =
+ crate::utilsprites::RenderMetrics::with_font_metrics(&card_font.metrics())
+ .cell_size
+ .height as f32;
+ let group_header_height = ctx
+ .px(GROUP_HEADER_HEIGHT)
+ .max(group_line_height + ctx.px(12.0));
+ let title_card_gap = ctx.px(GROUP_TITLE_CARD_GAP);
+ let card_header_height = ctx
+ .px(CARD_HEADER_HEIGHT)
+ .max(card_line_height + ctx.px(18.0));
+ let card_inset = ctx.px(CARD_INSET);
+ let gap = ctx.px(CARD_GAP);
+ let group_gap = ctx.px(GROUP_GAP);
+ let max_columns = max_columns_for_surface_width(
+ ctx.dimensions.pixel_width as f32,
+ ctx.px(FIVE_COLUMN_WINDOW_WIDTH),
+ );
+
+ let groups = self.collect_groups();
+ let now = Instant::now();
+ let refresh_interval = self.live_resizing.then_some(LIVE_RESIZE_PREVIEW_INTERVAL);
+ let mut warm_keys = HashSet::new();
+ if groups.is_empty() {
+ self.scroll.set_extents(self.viewport.size.height, 0.0);
+ self.paint_empty(ctx, layers, palette, settings_font)?;
+ } else {
+ let counts = groups
+ .iter()
+ .map(|group| group.cards.len())
+ .collect::<Vec<_>>();
+ let (layouts, content_height) = group_layouts(
+ &counts,
+ content_width,
+ max_columns,
+ ctx.px(CARD_MIN_WIDTH),
+ ctx.px(CARD_ORPHAN_COMFORT_WIDTH),
+ ctx.px(CARD_MAX_WIDTH),
+ gap,
+ group_header_height,
+ title_card_gap,
+ card_header_height,
+ card_inset,
+ self.host_preview_aspect,
+ group_gap,
+ );
+ self.scroll
+ .set_extents(self.viewport.size.height, content_height);
+
+ for (group, layout) in groups.iter().zip(layouts) {
+ let heading_y = self.viewport.origin.y + layout.header_y - self.scroll.offset;
+ if row_visible(heading_y, group_header_height, self.viewport) {
+ let heading_text_y =
+ heading_y + (group_header_height - group_line_height).max(0.0) / 2.0;
+ let title_width = if layout.header_y == 0.0 {
+ (content_width - ctx.px(CLOSE_BUTTON_SIZE + 20.0)).max(1.0)
+ } else {
+ content_width
+ };
+ ctx.draw_text(
+ layers,
+ group_font,
+ content_x,
+ heading_text_y,
+ &group.name,
+ palette.text,
+ title_width,
+ )?;
+ if group.offline {
+ self.paint_offline_badge(
+ ctx,
+ layers,
+ palette,
+ settings_font,
+ content_x,
+ heading_y
+ + (group_header_height
+ - (settings_line_height + ctx.px(8.0)).max(ctx.px(24.0)))
+ .max(0.0)
+ / 2.0,
+ &group.name,
+ group_font,
+ title_width,
+ settings_line_height,
+ )?;
+ }
+ }
+
+ for (index, card) in group.cards.iter().enumerate() {
+ let rect = card_rect(
+ index,
+ group.cards.len(),
+ layout.grid,
+ content_x,
+ content_width,
+ self.viewport.origin.y + layout.cards_y - self.scroll.offset,
+ gap,
+ );
+
+ // Keep one complete row warm above and below the viewport
+ // so a scroll does not reveal an uncaptured thumbnail. All
+ // other cards remain metadata-only.
+ let overscan = layout.grid.card_height + gap;
+ let snapshot = if card_is_warm(rect, self.viewport, overscan) {
+ warm_keys.insert(card.key.clone());
+ let fingerprint = terminal_preview_fingerprint(card.tab_id);
+ let (snapshot, refresh_due) = resolve_snapshot(
+ &mut self.snapshot_cache,
+ &card.key,
+ fingerprint,
+ now,
+ refresh_interval,
+ || capture_terminal_snapshot(card.tab_id),
+ );
+ if let Some(refresh_due) = refresh_due {
+ self.next_preview_refresh = Some(
+ self.next_preview_refresh
+ .map_or(refresh_due, |current| current.min(refresh_due)),
+ );
+ }
+ snapshot
+ } else {
+ None
+ };
+
+ let Some(visible) = rect.intersection(&self.viewport) else {
+ continue;
+ };
+ if visible.size.width <= 1.0 || visible.size.height <= 1.0 {
+ continue;
+ }
+
+ let tab_id = card.tab_id;
+ let action = OverviewAction::OpenThread(tab_id);
+ let close_action = OverviewAction::CloseTab(tab_id);
+ let card_hovered = matches!(
+ self.interaction.hovered,
+ Some(OverviewAction::OpenThread(id) | OverviewAction::CloseTab(id))
+ if id == tab_id
+ );
+ let fill = if self.interaction.pressed == Some(action) {
+ colors.card_pressed
+ } else if card_hovered {
+ colors.card_hover
+ } else {
+ colors.card
+ };
+ let border = if card.active {
+ colors.active_border
+ } else {
+ palette.control_border
+ };
+ // Keep the card's real geometry even when the viewport
+ // intersects only part of it. The fixed header/footer masks
+ // clip the overflow in the final pass; flattening `visible`
+ // into a plain rectangle destroys corners that are still on
+ // screen (notably the top corners of the last row).
+ ctx.draw_elevated_surface(
+ layers,
+ 0,
+ rect,
+ fill,
+ border,
+ colors.shadow,
+ ctx.px(CARD_RADIUS),
+ )?;
+
+ let icon_size = ctx.px(20.0);
+ let icon_x = rect.origin.x + ctx.px(16.0);
+ let icon_y = rect.origin.y + (card_header_height - icon_size) / 2.0;
+ let title_y =
+ rect.origin.y + (card_header_height - card_line_height).max(0.0) / 2.0;
+ let close_size = ctx.px(CARD_CLOSE_BUTTON_SIZE);
+ let close_x = rect.max_x() - ctx.px(CARD_CLOSE_RIGHT_PAD) - close_size;
+ let close_y = rect.origin.y + (card_header_height - close_size) / 2.0;
+ let header_fully_visible =
+ row_fully_visible(rect.origin.y, card_header_height, self.viewport);
+ if row_fully_visible(title_y, card_line_height, self.viewport) {
+ ctx.draw_svg_icon(
+ layers,
+ SvgIcon::SquareTerminal,
+ icon_x,
+ icon_y,
+ icon_size,
+ palette.secondary_text,
+ )?;
+ let text_x = icon_x + icon_size + ctx.px(10.0);
+ ctx.draw_text(
+ layers,
+ card_font,
+ text_x,
+ title_y,
+ &card.title,
+ palette.text,
+ (close_x - ctx.px(CARD_TITLE_CLOSE_GAP) - text_x).max(1.0),
+ )?;
+ }
+
+ let preview_width = (rect.size.width - card_inset * 2.0).max(1.0);
+ let preview = euclid::rect(
+ rect.origin.x + card_inset,
+ rect.origin.y + card_header_height,
+ preview_width,
+ preview_width / self.host_preview_aspect,
+ );
+ if let Some(clip) = preview.intersection(&self.viewport) {
+ if clip.size.width > 1.0 && clip.size.height > 1.0 {
+ ctx.draw_rounded_rect(
+ layers,
+ 0,
+ preview.origin.x,
+ preview.origin.y,
+ preview.size.width,
+ preview.size.height,
+ colors.preview,
+ ctx.px(PREVIEW_RADIUS),
+ )?;
+ if let Some(snapshot) = snapshot.as_ref() {
+ self.previews.push(TerminalPreviewRequest {
+ snapshot: Arc::clone(snapshot),
+ area: preview,
+ clip,
+ });
+ self.visible_panes
+ .extend(snapshot.panes.iter().map(|pane| pane.pane_id));
+ }
+ self.preview_chrome.push(CardChrome {
+ preview,
+ clip,
+ fill,
+ border: colors.preview_border,
+ });
+ }
+ }
+
+ self.card_keys.insert(tab_id, card.key.clone());
+ self.card_titles.insert(tab_id, card.title.clone());
+ self.widgets.push(visible, WidgetKind::SidebarRow, action);
+ if header_fully_visible {
+ if card_hovered {
+ draw_icon_button(
+ ctx,
+ layers,
+ &mut self.widgets,
+ &self.interaction,
+ palette,
+ close_x,
+ close_y,
+ close_size,
+ SvgIcon::X,
+ close_action,
+ )?;
+ } else {
+ self.widgets.push(
+ RectF::new(
+ euclid::point2(close_x, close_y),
+ euclid::size2(close_size, close_size),
+ ),
+ WidgetKind::Button,
+ close_action,
+ );
+ }
+ }
+ }
+ }
+ }
+ if self.scroll.max_offset() <= 0.0 {
+ self.scrollbar_visible_until = None;
+ }
+ self.snapshot_cache.retain(|key, _| warm_keys.contains(key));
+
+ Ok(())
+ }
+
+ fn paint_scroll_masks(
+ &self,
+ ctx: &DrawContext,
+ layers: &mut TripleLayerQuadAllocator<'_>,
+ ) -> anyhow::Result<()> {
+ let surface = euclid::rect(
+ 0.0,
+ 0.0,
+ ctx.dimensions.pixel_width as f32,
+ ctx.dimensions.pixel_height as f32,
+ );
+ let colors = overview_colors(crate::native_settings::effective_appearance());
+ let top = self
+ .viewport
+ .min_y()
+ .clamp(surface.min_y(), surface.max_y());
+ let bottom = self
+ .viewport
+ .max_y()
+ .clamp(surface.min_y(), surface.max_y());
+
+ draw_surface_gradient_slice(
+ ctx,
+ layers,
+ surface,
+ euclid::rect(
+ surface.min_x(),
+ surface.min_y(),
+ surface.size.width,
+ top - surface.min_y(),
+ ),
+ colors,
+ 1.0,
+ 1.0,
+ )?;
+ draw_surface_gradient_slice(
+ ctx,
+ layers,
+ surface,
+ euclid::rect(
+ surface.min_x(),
+ bottom,
+ surface.size.width,
+ surface.max_y() - bottom,
+ ),
+ colors,
+ 1.0,
+ 1.0,
+ )?;
+
+ let fade = ctx
+ .px(SCROLL_MASK_FADE_HEIGHT)
+ .min(self.viewport.size.height / 3.0);
+ if self.scroll.offset > 0.5 && fade > 0.0 {
+ draw_surface_gradient_slice(
+ ctx,
+ layers,
+ surface,
+ euclid::rect(surface.min_x(), top, surface.size.width, fade),
+ colors,
+ 1.0,
+ 0.0,
+ )?;
+ }
+ if self.scroll.offset < self.scroll.max_offset() - 0.5 && fade > 0.0 {
+ draw_surface_gradient_slice(
+ ctx,
+ layers,
+ surface,
+ euclid::rect(surface.min_x(), bottom - fade, surface.size.width, fade),
+ colors,
+ 0.0,
+ 1.0,
+ )?;
+ }
+ Ok(())
+ }
+
+ fn paint_fixed_controls(
+ &mut self,
+ ctx: &DrawContext,
+ layers: &mut TripleLayerQuadAllocator<'_>,
+ area: RectF,
+ palette: UiPalette,
+ ) -> anyhow::Result<()> {
+ if self.scrollbar_visible_at(Instant::now()) {
+ let scrollbar_area = euclid::rect(
+ self.viewport.origin.x,
+ self.viewport.origin.y,
+ self.viewport.size.width,
+ self.viewport.size.height,
+ );
+ draw_scrollbar_on_layer(
+ ctx,
+ layers,
+ palette,
+ UiTokens::for_dpi(ctx.dimensions.dpi),
+ scrollbar_area,
+ self.scroll,
+ 2,
+ )?;
+ }
+
+ // Register this last so a long first Space title can never steal the
+ // close target. Drawing it after the scroll mask keeps the shared icon
+ // button visible without hand-authoring a second control style.
+ let pad = horizontal_page_pad(ctx, area);
+ let close_size = ctx.px(CLOSE_BUTTON_SIZE);
+ draw_icon_button_on_layer(
+ ctx,
+ layers,
+ &mut self.widgets,
+ &self.interaction,
+ palette,
+ area.max_x() - pad - close_size,
+ area.origin.y + ctx.px(14.0),
+ close_size,
+ SvgIcon::X,
+ OverviewAction::CloseOverview,
+ 2,
+ )
+ }
+
+ fn reveal_scrollbar(&mut self, now: Instant) {
+ if self.scroll.max_offset() > 0.0 {
+ self.scrollbar_visible_until = Some(now + SCROLLBAR_VISIBLE_INTERVAL);
+ }
+ }
+
+ fn scrollbar_visible_at(&self, now: Instant) -> bool {
+ self.scroll.max_offset() > 0.0
+ && self
+ .scrollbar_visible_until
+ .is_some_and(|until| until > now)
+ }
+
+ fn next_frame_deadline(&self, now: Instant) -> Option<Instant> {
+ let scrollbar_deadline = self.scrollbar_visible_until.filter(|until| *until > now);
+ match (self.next_preview_refresh, scrollbar_deadline) {
+ (Some(preview), Some(scrollbar)) => Some(preview.min(scrollbar)),
+ (Some(preview), None) => Some(preview),
+ (None, Some(scrollbar)) => Some(scrollbar),
+ (None, None) => None,
+ }
+ }
+
+ fn paint_empty(
+ &self,
+ ctx: &DrawContext,
+ layers: &mut TripleLayerQuadAllocator<'_>,
+ palette: UiPalette,
+ font: &Rc<LoadedFont>,
+ ) -> anyhow::Result<()> {
+ let icon_size = ctx.px(42.0);
+ let center_x = self.viewport.origin.x + self.viewport.size.width / 2.0;
+ let center_y = self.viewport.origin.y + self.viewport.size.height * 0.42;
+ ctx.draw_svg_icon(
+ layers,
+ SvgIcon::SquareTerminal,
+ center_x - icon_size / 2.0,
+ center_y - icon_size,
+ icon_size,
+ palette.muted_text,
+ )?;
+ let label = crate::i18n::tr("live-overview-empty");
+ let width = ctx.measure_text_width(font, &label);
+ ctx.draw_text(
+ layers,
+ font,
+ center_x - width / 2.0,
+ center_y + ctx.px(10.0),
+ &label,
+ palette.muted_text,
+ width.max(1.0),
+ )
+ }
+
+ #[allow(clippy::too_many_arguments)]
+ fn paint_offline_badge(
+ &self,
+ ctx: &DrawContext,
+ layers: &mut TripleLayerQuadAllocator<'_>,
+ palette: UiPalette,
+ font: &Rc<LoadedFont>,
+ x: f32,
+ y: f32,
+ group_name: &str,
+ group_font: &Rc<LoadedFont>,
+ available_width: f32,
+ line_height: f32,
+ ) -> anyhow::Result<()> {
+ let group_width = ctx.measure_text_width(group_font, group_name);
+ let label = crate::i18n::tr("live-overview-offline");
+ let text_width = ctx.measure_text_width(font, &label);
+ let badge_width = text_width + ctx.px(18.0);
+ let badge_height = (line_height + ctx.px(8.0)).max(ctx.px(24.0));
+ let badge_x = (x + group_width + ctx.px(14.0))
+ .min(x + available_width - badge_width)
+ .max(x);
+ ctx.draw_rounded_rect(
+ layers,
+ 0,
+ badge_x,
+ y,
+ badge_width,
+ badge_height,
+ palette.sidebar_row_hover_bg,
+ badge_height / 2.0,
+ )?;
+ ctx.draw_text(
+ layers,
+ font,
+ badge_x + ctx.px(9.0),
+ y + (badge_height - line_height).max(0.0) / 2.0,
+ &label,
+ palette.muted_text,
+ text_width.max(1.0),
+ )
+ }
+
+ fn action_state(&self, action: OverviewAction) -> ControlState {
+ if self.interaction.pressed == Some(action) {
+ ControlState::Pressed
+ } else if self.interaction.hovered == Some(action) {
+ ControlState::Hovered
+ } else {
+ ControlState::Normal
+ }
+ }
+
+ #[allow(clippy::too_many_arguments)]
+ fn paint_close_confirmation(
+ &mut self,
+ ctx: &DrawContext,
+ layers: &mut TripleLayerQuadAllocator<'_>,
+ area: RectF,
+ palette: UiPalette,
+ font: &Rc<LoadedFont>,
+ title_font: &Rc<LoadedFont>,
+ ) -> anyhow::Result<()> {
+ let Some(pending) = self.pending_close.as_ref() else {
+ return Ok(());
+ };
+ let pending_title = pending.title.clone();
+ let colors = overview_colors(crate::native_settings::effective_appearance());
+ ctx.draw_rect(
+ layers,
+ 2,
+ 0.0,
+ 0.0,
+ ctx.dimensions.pixel_width as f32,
+ ctx.dimensions.pixel_height as f32,
+ colors.modal_scrim,
+ )?;
+
+ let tokens = UiTokens::for_dpi(ctx.dimensions.dpi);
+ let side_margin = ctx.px(CONFIRM_SIDE_MARGIN);
+ let available_width = (area.size.width - side_margin).max(1.0);
+ let dialog_width = (area.size.width * 0.5)
+ .clamp(ctx.px(CONFIRM_MIN_WIDTH), ctx.px(CONFIRM_MAX_WIDTH))
+ .min(available_width);
+ let padding = ctx.px(CONFIRM_PADDING).min(dialog_width * 0.12);
+ let title_height =
+ crate::utilsprites::RenderMetrics::with_font_metrics(&title_font.metrics())
+ .cell_size
+ .height as f32;
+ let body_height = crate::utilsprites::RenderMetrics::with_font_metrics(&font.metrics())
+ .cell_size
+ .height as f32;
+ let text_gap = ctx.px(CONFIRM_TEXT_GAP);
+ let dialog_height = padding * 2.0
+ + title_height
+ + text_gap
+ + body_height
+ + ctx.px(28.0)
+ + tokens.control_height;
+ let dialog = euclid::rect(
+ area.origin.x + (area.size.width - dialog_width) / 2.0,
+ area.origin.y + (area.size.height - dialog_height).max(0.0) / 2.0,
+ dialog_width,
+ dialog_height.min(area.size.height.max(1.0)),
+ );
+ ctx.draw_elevated_surface(
+ layers,
+ 2,
+ dialog,
+ palette.sidebar_bg,
+ palette.control_border,
+ colors.shadow,
+ ctx.px(CONFIRM_RADIUS),
+ )?;
+
+ let mut args = FluentArgs::new();
+ args.set("title", pending_title);
+ let title = crate::i18n::tr_args("live-overview-close-title", &args);
+ let detail = crate::i18n::tr("live-overview-close-detail");
+ let text_width = (dialog.size.width - padding * 2.0).max(1.0);
+ ctx.draw_text_on_layer(
+ layers,
+ 2,
+ title_font,
+ dialog.origin.x + padding,
+ dialog.origin.y + padding,
+ &title,
+ palette.text,
+ text_width,
+ )?;
+ ctx.draw_text_on_layer(
+ layers,
+ 2,
+ font,
+ dialog.origin.x + padding,
+ dialog.origin.y + padding + title_height + text_gap,
+ &detail,
+ palette.secondary_text,
+ text_width,
+ )?;
+
+ let cancel_label = crate::i18n::tr("live-overview-close-cancel");
+ let confirm_label = crate::i18n::tr("live-overview-close-confirm");
+ let button_gap = ctx.px(CONFIRM_BUTTON_GAP);
+ let button_available = (dialog.size.width - padding * 2.0 - button_gap).max(2.0);
+ let desired_cancel = ctx.measure_text_width(font, &cancel_label) + ctx.px(36.0);
+ let desired_confirm = ctx.measure_text_width(font, &confirm_label) + ctx.px(36.0);
+ let (cancel_width, confirm_width) = if desired_cancel + desired_confirm <= button_available
+ {
+ (desired_cancel, desired_confirm)
+ } else {
+ (button_available / 2.0, button_available / 2.0)
+ };
+ let buttons_y = dialog.max_y() - padding - tokens.control_height;
+ let confirm_x = dialog.max_x() - padding - confirm_width;
+ let cancel_x = confirm_x - button_gap - cancel_width;
+ let cancel_state = self.action_state(OverviewAction::CancelCloseTab);
+ draw_button_on_layer(
+ ctx,
+ layers,
+ font,
+ &mut self.widgets,
+ palette,
+ ButtonSpec {
+ label: &cancel_label,
+ action: OverviewAction::CancelCloseTab,
+ rect: euclid::rect(cancel_x, buttons_y, cancel_width, tokens.control_height),
+ state: cancel_state,
+ kind: WidgetKind::Button,
+ },
+ 2,
+ )?;
+ let confirm_state = self.action_state(OverviewAction::ConfirmCloseTab);
+ draw_button_on_layer(
+ ctx,
+ layers,
+ font,
+ &mut self.widgets,
+ palette,
+ ButtonSpec {
+ label: &confirm_label,
+ action: OverviewAction::ConfirmCloseTab,
+ rect: euclid::rect(confirm_x, buttons_y, confirm_width, tokens.control_height),
+ state: confirm_state,
+ kind: WidgetKind::Button,
+ },
+ 2,
+ )
+ }
+
+ fn request_close_tab(&mut self, tab_id: TabId) -> ContentViewResponse {
+ let Some(tab) = Mux::get().get_tab(tab_id) else {
+ return ContentViewResponse::Redraw;
+ };
+ if tab.can_close_without_prompting(CloseReason::Tab) {
+ close_tab_response(tab_id)
+ } else {
+ self.pending_close = Some(PendingClose {
+ tab_id,
+ title: self
+ .card_titles
+ .get(&tab_id)
+ .cloned()
+ .unwrap_or_else(|| "Terminal".to_string()),
+ });
+ self.interaction = InteractionState::default();
+ ContentViewResponse::Redraw
+ }
+ }
+
+ fn confirm_close_tab(&mut self) -> ContentViewResponse {
+ let Some(pending) = self.pending_close.take() else {
+ return ContentViewResponse::Redraw;
+ };
+ self.interaction = InteractionState::default();
+ close_tab_response(pending.tab_id)
+ }
+
+ fn cancel_close_tab(&mut self) -> ContentViewResponse {
+ self.pending_close = None;
+ self.interaction = InteractionState::default();
+ ContentViewResponse::Redraw
+ }
+
+ fn on_mouse_impl(&mut self, x: f32, y: f32, kind: WMEK) -> ContentViewResponse {
+ let modal_active = self.pending_close.is_some();
+ let hit = self
+ .widgets
+ .hit_test(x, y)
+ .map(|target| target.action)
+ .filter(|action| {
+ !modal_active
+ || matches!(
+ action,
+ OverviewAction::ConfirmCloseTab | OverviewAction::CancelCloseTab
+ )
+ });
+ match kind {
+ WMEK::VertWheel(_) if modal_active => ContentViewResponse::Ignored,
+ WMEK::VertWheel(amount) => {
+ let old = self.scroll.offset;
+ self.scroll
+ .scroll_by(wheel_delta_pixels(amount, self.last_ui_scale));
+ if (old - self.scroll.offset).abs() > 0.01 {
+ self.reveal_scrollbar(Instant::now());
+ ContentViewResponse::Redraw
+ } else {
+ ContentViewResponse::Ignored
+ }
+ }
+ WMEK::Move => {
+ if hit != self.interaction.hovered {
+ self.interaction.hovered = hit;
+ ContentViewResponse::Redraw
+ } else {
+ ContentViewResponse::Ignored
+ }
+ }
+ WMEK::Press(MousePress::Left) => {
+ self.interaction.pressed = hit;
+ ContentViewResponse::Redraw
+ }
+ WMEK::Release(MousePress::Left) => {
+ let pressed = self.interaction.pressed.take();
+ if hit.is_some() && hit == pressed {
+ match hit.expect("checked as some") {
+ OverviewAction::CloseOverview => ContentViewResponse::Close,
+ OverviewAction::OpenThread(tab_id) => self
+ .card_keys
+ .get(&tab_id)
+ .cloned()
+ .map(|key| open_thread_response(key, self.owner_id))
+ .unwrap_or(ContentViewResponse::Redraw),
+ OverviewAction::CloseTab(tab_id) => self.request_close_tab(tab_id),
+ OverviewAction::ConfirmCloseTab => self.confirm_close_tab(),
+ OverviewAction::CancelCloseTab => self.cancel_close_tab(),
+ }
+ } else {
+ ContentViewResponse::Redraw
+ }
+ }
+ _ => ContentViewResponse::Ignored,
+ }
+ }
+}
+
+impl ContentView for LiveOverviewView {
+ fn title(&self) -> String {
+ crate::i18n::tr("live-overview-title")
+ }
+
+ fn show_in_tab_bar(&self) -> bool {
+ false
+ }
+
+ fn presentation(&self) -> ContentViewPresentation {
+ ContentViewPresentation::FullWindow
+ }
+
+ fn paint_surface_background(
+ &mut self,
+ ctx: &DrawContext,
+ layers: &mut TripleLayerQuadAllocator<'_>,
+ surface: RectF,
+ _palette: UiPalette,
+ ) -> anyhow::Result<()> {
+ let colors = overview_colors(crate::native_settings::effective_appearance());
+ ctx.draw_corner_gradient(
+ layers,
+ 0,
+ surface,
+ colors.surface_top_left,
+ colors.surface_top_right,
+ colors.surface_bottom_left,
+ colors.surface_bottom_right,
+ )
+ }
+
+ fn typography(&self) -> ContentViewTypography {
+ ContentViewTypography::Overview
+ }
+
+ fn tab_key(&self) -> Option<String> {
+ Some(LIVE_OVERVIEW_CONTENT_VIEW_KEY.to_string())
+ }
+
+ fn on_reactivated(&mut self) -> ContentViewResponse {
+ self.interaction = InteractionState::default();
+ self.pending_close = None;
+ self.scrollbar_visible_until = None;
+ ContentViewResponse::Redraw
+ }
+
+ fn next_frame_time(&self) -> Option<Instant> {
+ self.next_frame_deadline(Instant::now())
+ }
+
+ fn set_live_resizing(&mut self, live_resizing: bool) -> bool {
+ if self.live_resizing == live_resizing {
+ false
+ } else {
+ self.live_resizing = live_resizing;
+ true
+ }
+ }
+
+ fn terminal_previews(&self) -> Vec<TerminalPreviewRequest> {
+ self.previews.clone()
+ }
+
+ fn paint_after_terminal_previews(
+ &mut self,
+ ctx: &DrawContext,
+ layers: &mut TripleLayerQuadAllocator<'_>,
+ area: RectF,
+ palette: UiPalette,
+ font: &Rc<LoadedFont>,
+ _title_font: &Rc<LoadedFont>,
+ section_font: &Rc<LoadedFont>,
+ ) -> anyhow::Result<()> {
+ for chrome in &self.preview_chrome {
+ ctx.draw_rounded_preview_chrome(
+ layers,
+ 2,
+ chrome.preview,
+ chrome.clip,
+ chrome.fill,
+ chrome.border,
+ ctx.px(PREVIEW_RADIUS),
+ )?;
+ }
+ self.paint_scroll_masks(ctx, layers)?;
+ self.paint_fixed_controls(ctx, layers, area, palette)?;
+ if self
+ .pending_close
+ .as_ref()
+ .is_some_and(|pending| Mux::get().get_tab(pending.tab_id).is_none())
+ {
+ self.pending_close = None;
+ self.interaction = InteractionState::default();
+ }
+ self.paint_close_confirmation(ctx, layers, area, palette, font, section_font)
+ }
+
+ fn wants_pane_output(&self, pane_id: PaneId) -> bool {
+ self.visible_panes.contains(&pane_id)
+ }
+
+ fn paint(
+ &mut self,
+ ctx: &DrawContext,
+ layers: &mut TripleLayerQuadAllocator<'_>,
+ area: RectF,
+ palette: UiPalette,
+ font: &Rc<LoadedFont>,
+ title_font: &Rc<LoadedFont>,
+ section_font: &Rc<LoadedFont>,
+ _cursor_on: bool,
+ ) -> anyhow::Result<()> {
+ self.paint_impl(ctx, layers, area, palette, font, title_font, section_font)
+ }
+
+ fn on_mouse(&mut self, x: f32, y: f32, kind: WMEK) -> ContentViewResponse {
+ self.on_mouse_impl(x, y, kind)
+ }
+
+ fn on_key(&mut self, key: KeyCode, _mods: KeyModifiers) -> ContentViewResponse {
+ if key == KeyCode::Escape {
+ if self.pending_close.is_some() {
+ self.cancel_close_tab()
+ } else {
+ ContentViewResponse::Close
+ }
+ } else {
+ ContentViewResponse::Ignored
+ }
+ }
+}
+
+fn overview_colors(appearance: Appearance) -> OverviewColors {
+ match appearance {
+ Appearance::Light | Appearance::LightHighContrast => OverviewColors {
+ surface_top_left: srgb(238, 238, 242, 255),
+ surface_top_right: srgb(239, 240, 245, 255),
+ surface_bottom_left: srgb(230, 232, 238, 255),
+ surface_bottom_right: srgb(231, 234, 241, 255),
+ card: srgb(255, 255, 255, 248),
+ card_hover: srgb(250, 250, 252, 250),
+ card_pressed: srgb(242, 242, 245, 252),
+ shadow: srgb(0, 0, 0, 110),
+ preview: srgb(229, 229, 232, 255),
+ preview_border: srgb(45, 45, 52, 42),
+ active_border: srgb(60, 60, 64, 96),
+ modal_scrim: srgb(18, 18, 22, 72),
+ },
+ Appearance::Dark | Appearance::DarkHighContrast => OverviewColors {
+ surface_top_left: srgb(25, 25, 26, 255),
+ surface_top_right: srgb(26, 26, 29, 255),
+ surface_bottom_left: srgb(20, 21, 24, 255),
+ surface_bottom_right: srgb(21, 22, 27, 255),
+ card: srgb(42, 42, 46, 248),
+ card_hover: srgb(48, 48, 52, 250),
+ card_pressed: srgb(54, 54, 58, 252),
+ shadow: srgb(0, 0, 0, 148),
+ preview: srgb(17, 17, 19, 255),
+ preview_border: srgb(255, 255, 255, 28),
+ active_border: srgb(205, 205, 210, 92),
+ modal_scrim: srgb(0, 0, 0, 112),
+ },
+ }
+}
+
+fn srgb(red: u8, green: u8, blue: u8, alpha: u8) -> LinearRgba {
+ LinearRgba::with_srgba(red, green, blue, alpha)
+}
+
+fn horizontal_page_pad(ctx: &DrawContext, area: RectF) -> f32 {
+ ctx.px(PAGE_PAD_X).min(area.size.width * 0.075)
+}
+
+fn interpolate_color(from: LinearRgba, to: LinearRgba, amount: f32) -> LinearRgba {
+ let amount = amount.clamp(0.0, 1.0);
+ LinearRgba(
+ from.0 + (to.0 - from.0) * amount,
+ from.1 + (to.1 - from.1) * amount,
+ from.2 + (to.2 - from.2) * amount,
+ from.3 + (to.3 - from.3) * amount,
+ )
+}
+
+#[allow(clippy::too_many_arguments)]
+fn draw_surface_gradient_slice(
+ ctx: &DrawContext,
+ layers: &mut TripleLayerQuadAllocator<'_>,
+ surface: RectF,
+ slice: RectF,
+ colors: OverviewColors,
+ top_alpha: f32,
+ bottom_alpha: f32,
+) -> anyhow::Result<()> {
+ if slice.size.width <= 0.0 || slice.size.height <= 0.0 || surface.size.height <= 0.0 {
+ return Ok(());
+ }
+ let row = |y: f32, top: LinearRgba, bottom: LinearRgba| {
+ let amount = ((y - surface.min_y()) / surface.size.height).clamp(0.0, 1.0);
+ interpolate_color(top, bottom, amount)
+ };
+ let top_left = row(
+ slice.min_y(),
+ colors.surface_top_left,
+ colors.surface_bottom_left,
+ )
+ .mul_alpha(top_alpha);
+ let top_right = row(
+ slice.min_y(),
+ colors.surface_top_right,
+ colors.surface_bottom_right,
+ )
+ .mul_alpha(top_alpha);
+ let bottom_left = row(
+ slice.max_y(),
+ colors.surface_top_left,
+ colors.surface_bottom_left,
+ )
+ .mul_alpha(bottom_alpha);
+ let bottom_right = row(
+ slice.max_y(),
+ colors.surface_top_right,
+ colors.surface_bottom_right,
+ )
+ .mul_alpha(bottom_alpha);
+ ctx.draw_corner_gradient(
+ layers,
+ 2,
+ slice,
+ top_left,
+ top_right,
+ bottom_left,
+ bottom_right,
+ )
+}
+
+fn live_tab_for_workspace(workspace: &str) -> Option<TabId> {
+ let mux = Mux::get();
+ for window_id in mux.iter_windows_in_workspace(workspace) {
+ let Some(tab) = mux.get_active_tab_for_window(window_id) else {
+ continue;
+ };
+ if tab.iter_panes().is_empty() {
+ continue;
+ }
+ return Some(tab.tab_id());
+ }
+ None
+}
+
+fn terminal_preview_fingerprint(tab_id: TabId) -> Option<TerminalPreviewFingerprint> {
+ let tab = Mux::get().get_tab(tab_id)?;
+ let tab_size = tab.get_size();
+ if tab_size.cols == 0 || tab_size.rows == 0 {
+ return None;
+ }
+
+ let splits = tab.iter_splits();
+ let panes = tab
+ .iter_panes()
+ .into_iter()
+ .map(|positioned| {
+ let pane = positioned.pane;
+ let palette = pane.palette_override().unwrap_or_else(|| pane.palette());
+ TerminalPreviewPaneFingerprint {
+ pane_id: pane.pane_id(),
+ index: positioned.index,
+ is_active: positioned.is_active,
+ is_zoomed: positioned.is_zoomed,
+ left: positioned.left,
+ top: positioned.top,
+ width: positioned.width,
+ height: positioned.height,
+ dimensions: pane.get_dimensions(),
+ seqno: pane.get_current_seqno(),
+ palette_identity: palette_identity(&palette),
+ cursor: pane.get_cursor_position(),
+ }
+ })
+ .collect::<Vec<_>>();
+ if panes.is_empty() {
+ None
+ } else {
+ Some(TerminalPreviewFingerprint {
+ tab_id,
+ tab_size,
+ panes,
+ splits,
+ })
+ }
+}
+
+fn palette_identity(palette: &wezterm_term::color::ColorPalette) -> u64 {
+ let mut hasher = DefaultHasher::new();
+ palette.colors.0.hash(&mut hasher);
+ palette.foreground.hash(&mut hasher);
+ palette.background.hash(&mut hasher);
+ palette.cursor_fg.hash(&mut hasher);
+ palette.cursor_bg.hash(&mut hasher);
+ palette.cursor_border.hash(&mut hasher);
+ palette.selection_fg.hash(&mut hasher);
+ palette.selection_bg.hash(&mut hasher);
+ palette.scrollbar_thumb.hash(&mut hasher);
+ palette.split.hash(&mut hasher);
+ hasher.finish()
+}
+
+fn capture_terminal_snapshot(tab_id: TabId) -> Option<TerminalPreviewSnapshot> {
+ let tab = Mux::get().get_tab(tab_id)?;
+ let tab_size = tab.get_size();
+ if tab_size.cols == 0 || tab_size.rows == 0 {
+ return None;
+ }
+
+ let splits = tab.iter_splits();
+ let mut snapshots = Vec::new();
+ for positioned in tab.iter_panes() {
+ let pane = positioned.pane;
+ let dimensions = pane.get_dimensions();
+ let rows = positioned.height.min(dimensions.viewport_rows);
+ let cols = positioned.width.min(dimensions.cols);
+ let first_row = dimensions
+ .physical_top
+ .saturating_add(dimensions.viewport_rows.saturating_sub(rows) as isize);
+ let (resolved_top, lines) = if rows == 0 || cols == 0 {
+ (first_row, Vec::new())
+ } else {
+ pane.get_lines(first_row..first_row.saturating_add(rows as isize))
+ };
+ snapshots.push(TerminalPreviewPaneSnapshot {
+ pane_id: pane.pane_id(),
+ is_active: positioned.is_active,
+ left: positioned.left,
+ top: positioned.top,
+ width: positioned.width,
+ height: positioned.height,
+ cols,
+ rows,
+ resolved_top,
+ lines,
+ dimensions,
+ palette: pane.palette_override().unwrap_or_else(|| pane.palette()),
+ cursor: pane.get_cursor_position(),
+ });
+ }
+ if snapshots.is_empty() {
+ None
+ } else {
+ Some(TerminalPreviewSnapshot {
+ tab_size,
+ panes: snapshots,
+ splits,
+ })
+ }
+}
+
+fn resolve_snapshot<T, F>(
+ cache: &mut HashMap<LiveThreadKey, CachedPreview<T>>,
+ key: &LiveThreadKey,
+ fingerprint: Option<TerminalPreviewFingerprint>,
+ now: Instant,
+ refresh_interval: Option<Duration>,
+ capture: F,
+) -> (Option<Arc<T>>, Option<Instant>)
+where
+ F: FnOnce() -> Option<T>,
+{
+ let Some(fingerprint) = fingerprint else {
+ return (
+ cache.get(key).map(|cached| Arc::clone(&cached.snapshot)),
+ None,
+ );
+ };
+
+ if let Some(cached) = cache.get(key) {
+ if cached.fingerprint == fingerprint {
+ return (Some(Arc::clone(&cached.snapshot)), None);
+ }
+ if let Some(refresh_interval) = refresh_interval {
+ let refresh_due = cached.captured_at + refresh_interval;
+ if now < refresh_due {
+ return (Some(Arc::clone(&cached.snapshot)), Some(refresh_due));
+ }
+ }
+ }
+
+ if let Some(snapshot) = capture() {
+ cache.insert(
+ key.clone(),
+ CachedPreview {
+ fingerprint,
+ snapshot: Arc::new(snapshot),
+ captured_at: now,
+ },
+ );
+ }
+ (
+ cache.get(key).map(|cached| Arc::clone(&cached.snapshot)),
+ None,
+ )
+}
+
+fn card_title(project_name: &str, thread_name: &str) -> String {
+ if project_name.is_empty() || project_name == thread_name {
+ thread_name.to_string()
+ } else {
+ format!("{project_name} · {thread_name}")
+ }
+}
+
+fn close_tab_response(tab_id: TabId) -> ContentViewResponse {
+ ContentViewResponse::Run(Box::new(move |term_window: &mut TermWindow| {
+ Mux::get().remove_tab(tab_id);
+ term_window.invalidate_window();
+ }))
+}
+
+fn live_tab_for_key(key: &LiveThreadKey) -> Option<TabId> {
+ let mux = Mux::get();
+ let live_workspaces = mux.iter_workspaces();
+ let state = workspace_threads::thread_connection_state(&key.thread_id, &live_workspaces)?;
+ if state.space_id != key.space_id || !state.is_live {
+ return None;
+ }
+ if let Some(domain_name) = workspace_threads::client_domain_for_space(&key.space_id) {
+ if mux
+ .get_domain_by_name(&domain_name)
+ .is_none_or(|domain| domain.state() != DomainState::Attached)
+ {
+ return None;
+ }
+ }
+ live_tab_for_workspace(&state.workspace_name)
+}
+
+fn open_thread_response(key: LiveThreadKey, source_owner_id: u64) -> ContentViewResponse {
+ ContentViewResponse::Run(Box::new(move |term_window: &mut TermWindow| {
+ if live_tab_for_key(&key).is_none() {
+ term_window.invalidate_window();
+ return;
+ }
+
+ let Some(source_window) = term_window.window.clone() else {
+ return;
+ };
+
+ if let Some(target_owner_id) = workspace_threads::window_owner_for_space(&key.space_id) {
+ if target_owner_id != source_owner_id {
+ let Some(target) = crate::frontend::front_end()
+ .gui_window_for_recovery_slot(FrontendRecoverySlot::Window(target_owner_id))
+ else {
+ term_window.invalidate_window();
+ return;
+ };
+ let target_window = target.window.clone();
+ target.window.notify(TermWindowNotif::Apply(Box::new(
+ move |target_term_window| {
+ // Ownership and liveness can change between the click
+ // and this window's event-loop callback. Do not steal a
+ // Space or close the source overview on a stale lookup.
+ if workspace_threads::window_owner_for_space(&key.space_id)
+ != Some(target_owner_id)
+ || target_term_window.frontend_recovery_slot()
+ != FrontendRecoverySlot::Window(target_owner_id)
+ || live_tab_for_key(&key).is_none()
+ {
+ source_window.invalidate();
+ return;
+ }
+
+ target_term_window
+ .activate_workspace_thread(key.thread_id.clone(), &target_window);
+ target_window.focus();
+ source_window.notify(TermWindowNotif::Apply(Box::new(
+ |source_term_window| {
+ if source_term_window
+ .active_content_view_key_is(LIVE_OVERVIEW_CONTENT_VIEW_KEY)
+ {
+ source_term_window.close_content_view();
+ }
+ },
+ )));
+ },
+ )));
+ return;
+ }
+ }
+
+ if term_window.switch_space_to_thread(key.space_id, Some(key.thread_id), &source_window) {
+ // `switch_space_to_thread` deactivates content views as part of a
+ // successful navigation. Remove this singleton so its next entry
+ // captures a fresh host aspect and live snapshot set.
+ term_window.close_content_view();
+ }
+ }))
+}
+
+fn max_columns_for_surface_width(surface_width: f32, five_column_width: f32) -> usize {
+ if surface_width >= five_column_width {
+ MAX_COLUMNS
+ } else {
+ MAX_COLUMNS_BELOW_WIDE_BREAKPOINT
+ }
+}
+
+fn grid_columns(width: f32, minimum: f32, gap: f32, maximum: usize) -> usize {
+ if maximum == 0 {
+ return 0;
+ }
+ if maximum == 1 || width <= minimum {
+ 1
+ } else {
+ (((width + gap) / (minimum + gap)).floor() as usize).clamp(1, maximum)
+ }
+}
+
+fn single_orphan_group_count(counts: &[usize], columns: usize) -> usize {
+ if columns == 0 {
+ return 0;
+ }
+ counts
+ .iter()
+ .filter(|&&count| count > columns && count % columns == 1)
+ .count()
+}
+
+fn shared_grid_columns(
+ counts: &[usize],
+ content_width: f32,
+ maximum_columns: usize,
+ minimum: f32,
+ orphan_comfort_width: f32,
+ gap: f32,
+) -> usize {
+ let mut columns = grid_columns(content_width, minimum, gap, maximum_columns);
+ if columns == 0 {
+ return 0;
+ }
+ let initial_available =
+ (content_width - gap * columns.saturating_sub(1) as f32) / columns as f32;
+ if columns > 2 && initial_available < orphan_comfort_width {
+ let reduced_columns = columns - 1;
+ if single_orphan_group_count(counts, reduced_columns)
+ < single_orphan_group_count(counts, columns)
+ {
+ columns = reduced_columns;
+ }
+ }
+ columns
+}
+
+#[allow(clippy::too_many_arguments)]
+fn group_grid(
+ count: usize,
+ content_width: f32,
+ columns: usize,
+ maximum: f32,
+ gap: f32,
+ card_header_height: f32,
+ card_inset: f32,
+ preview_aspect: f32,
+) -> GroupGrid {
+ if columns == 0 {
+ return GroupGrid {
+ columns: 0,
+ rows: 0,
+ card_width: 0.0,
+ card_height: 0.0,
+ };
+ }
+ let available = (content_width - gap * columns.saturating_sub(1) as f32) / columns as f32;
+ let card_width = available.min(maximum).max(1.0);
+ let preview_width = (card_width - card_inset * 2.0).max(1.0);
+ GroupGrid {
+ columns,
+ rows: (count + columns - 1) / columns,
+ card_width,
+ card_height: card_header_height + preview_width / preview_aspect + card_inset,
+ }
+}
+
+#[allow(clippy::too_many_arguments)]
+fn group_layouts(
+ counts: &[usize],
+ content_width: f32,
+ maximum_columns: usize,
+ minimum: f32,
+ orphan_comfort_width: f32,
+ maximum: f32,
+ card_gap: f32,
+ header_height: f32,
+ title_card_gap: f32,
+ card_header_height: f32,
+ card_inset: f32,
+ preview_aspect: f32,
+ group_gap: f32,
+) -> (Vec<GroupLayout>, f32) {
+ let mut layouts = Vec::with_capacity(counts.len());
+ let mut y = 0.0;
+ let columns = shared_grid_columns(
+ counts,
+ content_width,
+ maximum_columns,
+ minimum,
+ orphan_comfort_width,
+ card_gap,
+ );
+ for &count in counts {
+ let grid = group_grid(
+ count,
+ content_width,
+ columns,
+ maximum,
+ card_gap,
+ card_header_height,
+ card_inset,
+ preview_aspect,
+ );
+ let cards_y = y + header_height + if count > 0 { title_card_gap } else { 0.0 };
+ layouts.push(GroupLayout {
+ header_y: y,
+ cards_y,
+ grid,
+ });
+ y = cards_y;
+ if grid.rows > 0 {
+ y +=
+ grid.rows as f32 * grid.card_height + grid.rows.saturating_sub(1) as f32 * card_gap;
+ }
+ y += group_gap;
+ }
+ (layouts, (y - group_gap).max(0.0))
+}
+
+fn card_rect(
+ index: usize,
+ count: usize,
+ grid: GroupGrid,
+ content_x: f32,
+ content_width: f32,
+ cards_y: f32,
+ gap: f32,
+) -> RectF {
+ let row = index / grid.columns;
+ let column = index % grid.columns;
+ let row_start = row * grid.columns;
+ let row_count = (count - row_start).min(grid.columns);
+ let row_width = row_count as f32 * grid.card_width + row_count.saturating_sub(1) as f32 * gap;
+ let row_x = content_x + (content_width - row_width).max(0.0) / 2.0;
+ euclid::rect(
+ row_x + column as f32 * (grid.card_width + gap),
+ cards_y + row as f32 * (grid.card_height + gap),
+ grid.card_width,
+ grid.card_height,
+ )
+}
+
+fn row_visible(y: f32, height: f32, viewport: RectF) -> bool {
+ y + height > viewport.min_y() && y < viewport.max_y()
+}
+
+fn card_is_warm(rect: RectF, viewport: RectF, overscan: f32) -> bool {
+ let warm_top = viewport.min_y() - overscan.max(0.0);
+ let warm_bottom = viewport.max_y() + overscan.max(0.0);
+ rect.max_y() > warm_top && rect.min_y() < warm_bottom
+}
+
+fn row_fully_visible(y: f32, height: f32, viewport: RectF) -> bool {
+ y >= viewport.min_y() && y + height <= viewport.max_y()
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[allow(clippy::too_many_arguments)]
+ fn test_group_grid(
+ count: usize,
+ content_width: f32,
+ maximum_columns: usize,
+ minimum: f32,
+ orphan_comfort_width: f32,
+ maximum: f32,
+ gap: f32,
+ card_header_height: f32,
+ card_inset: f32,
+ preview_aspect: f32,
+ ) -> GroupGrid {
+ let columns = shared_grid_columns(
+ &[count],
+ content_width,
+ maximum_columns,
+ minimum,
+ orphan_comfort_width,
+ gap,
+ );
+ group_grid(
+ count,
+ content_width,
+ columns,
+ maximum,
+ gap,
+ card_header_height,
+ card_inset,
+ preview_aspect,
+ )
+ }
+
+ #[test]
+ fn five_columns_begin_at_1500_logical_pixels_at_every_dpi() {
+ for scale in [0.5_f32, 1.0, 1.5, 2.0] {
+ let threshold = FIVE_COLUMN_WINDOW_WIDTH * scale;
+ assert_eq!(max_columns_for_surface_width(threshold, threshold), 5);
+ assert_eq!(max_columns_for_surface_width(threshold - 1.0, threshold), 4);
+
+ let content_width = threshold - PAGE_PAD_X * scale * 2.0;
+ let wide = test_group_grid(
+ 5,
+ content_width,
+ 5,
+ CARD_MIN_WIDTH * scale,
+ CARD_ORPHAN_COMFORT_WIDTH * scale,
+ CARD_MAX_WIDTH * scale,
+ CARD_GAP * scale,
+ CARD_HEADER_HEIGHT * scale,
+ CARD_INSET * scale,
+ 1.8,
+ );
+ let narrow = test_group_grid(
+ 5,
+ content_width - 1.0,
+ 4,
+ CARD_MIN_WIDTH * scale,
+ CARD_ORPHAN_COMFORT_WIDTH * scale,
+ CARD_MAX_WIDTH * scale,
+ CARD_GAP * scale,
+ CARD_HEADER_HEIGHT * scale,
+ CARD_INSET * scale,
+ 1.8,
+ );
+ assert_eq!((wide.columns, wide.rows), (5, 1));
+ assert_eq!((narrow.columns, narrow.rows), (4, 2));
+ }
+ }
+
+ #[test]
+ fn retina_window_from_review_wraps_the_fifth_card() {
+ assert_eq!(max_columns_for_surface_width(2202.0, 3000.0), 4);
+ assert_eq!(max_columns_for_surface_width(3000.0, 3000.0), 5);
+ }
+
+ #[test]
+ fn compressed_five_card_window_balances_as_three_plus_two() {
+ let surface_width = 1616.0;
+ let content_width = surface_width - PAGE_PAD_X * 2.0;
+ let grid = test_group_grid(
+ 5,
+ content_width,
+ max_columns_for_surface_width(surface_width, FIVE_COLUMN_WINDOW_WIDTH),
+ CARD_MIN_WIDTH,
+ CARD_ORPHAN_COMFORT_WIDTH,
+ CARD_MAX_WIDTH,
+ CARD_GAP,
+ CARD_HEADER_HEIGHT,
+ CARD_INSET,
+ 1.8,
+ );
+ assert_eq!((grid.columns, grid.rows), (3, 2));
+ }
+
+ #[test]
+ fn roomy_sub_1500_window_keeps_four_plus_one() {
+ let surface_width = 2600.0;
+ let content_width = surface_width - PAGE_PAD_X * 2.0;
+ let grid = test_group_grid(
+ 5,
+ content_width,
+ max_columns_for_surface_width(surface_width, FIVE_COLUMN_WINDOW_WIDTH),
+ CARD_MIN_WIDTH,
+ CARD_ORPHAN_COMFORT_WIDTH,
+ CARD_MAX_WIDTH,
+ CARD_GAP,
+ CARD_HEADER_HEIGHT,
+ CARD_INSET,
+ 1.8,
+ );
+ assert_eq!((grid.columns, grid.rows), (4, 2));
+ }
+
+ #[test]
+ fn responsive_grid_falls_back_through_four_three_two_one() {
+ assert_eq!(grid_columns(1648.0, 400.0, 16.0, 4), 4);
+ assert_eq!(grid_columns(1232.0, 400.0, 16.0, 4), 3);
+ assert_eq!(grid_columns(816.0, 400.0, 16.0, 4), 2);
+ assert_eq!(grid_columns(400.0, 400.0, 16.0, 4), 1);
+ }
+
+ #[test]
+ fn one_to_ten_cards_form_complete_non_overlapping_rows() {
+ for count in 1..=10 {
+ let grid = test_group_grid(count, 1332.0, 5, 400.0, 480.0, 640.0, 16.0, 44.0, 8.0, 1.8);
+ let rects = (0..count)
+ .map(|idx| card_rect(idx, count, grid, 84.0, 1332.0, 100.0, 16.0))
+ .collect::<Vec<_>>();
+ assert_eq!(grid.rows, (count + grid.columns - 1) / grid.columns);
+ for (idx, rect) in rects.iter().enumerate() {
+ assert!(rect.min_x() >= 84.0);
+ assert!(rect.max_x() <= 84.0 + 1332.0 + 0.01);
+ for other in rects.iter().skip(idx + 1) {
+ assert!(rect.intersection(other).is_none());
+ }
+ }
+ }
+ }
+
+ #[test]
+ fn groups_with_different_counts_share_one_card_size() {
+ let (layouts, _) = group_layouts(
+ &[3, 4],
+ 2464.0,
+ 4,
+ 400.0,
+ 480.0,
+ 640.0,
+ 16.0,
+ 42.0,
+ 8.0,
+ 44.0,
+ 8.0,
+ 1.8,
+ 48.0,
+ );
+ assert_eq!(layouts[0].grid.columns, 4);
+ assert_eq!(layouts[1].grid.columns, 4);
+ assert_eq!(layouts[0].grid.card_width, layouts[1].grid.card_width);
+ assert_eq!(layouts[0].grid.card_height, layouts[1].grid.card_height);
+ }
+
+ #[test]
+ fn orphan_rebalance_is_shared_by_every_group() {
+ let (layouts, _) = group_layouts(
+ &[3, 5],
+ 1800.0,
+ 4,
+ 400.0,
+ 480.0,
+ 640.0,
+ 16.0,
+ 42.0,
+ 8.0,
+ 44.0,
+ 8.0,
+ 1.8,
+ 48.0,
+ );
+ assert_eq!(layouts[0].grid.columns, 3);
+ assert_eq!(layouts[1].grid.columns, 3);
+ assert_eq!(layouts[0].grid.card_width, layouts[1].grid.card_width);
+ }
+
+ #[test]
+ fn every_card_uses_the_same_host_preview_aspect() {
+ let aspect = 1.73;
+ for count in [1, 3, 5, 8] {
+ let grid = test_group_grid(
+ count, 1332.0, 5, 400.0, 480.0, 640.0, 16.0, 44.0, 8.0, aspect,
+ );
+ let preview_width = grid.card_width - 16.0;
+ let preview_height = grid.card_height - 44.0 - 8.0;
+ assert!((preview_width / preview_height - aspect).abs() < 0.001);
+ }
+ }
+
+ #[test]
+ fn card_hit_rect_matches_painted_geometry() {
+ let grid = test_group_grid(5, 1332.0, 5, 400.0, 480.0, 640.0, 16.0, 44.0, 8.0, 1.8);
+ let rect = card_rect(2, 5, grid, 84.0, 1332.0, 100.0, 16.0);
+ let mut widgets = UiContext::default();
+ widgets.push(rect, WidgetKind::SidebarRow, OverviewAction::OpenThread(42));
+ let hit = widgets
+ .hit_test(rect.center().x, rect.center().y)
+ .expect("card center should hit");
+ assert_eq!(hit.action, OverviewAction::OpenThread(42));
+ }
+
+ #[test]
+ fn card_close_hit_target_wins_over_card_open_target() {
+ let card = euclid::rect(10.0, 20.0, 320.0, 180.0);
+ let close = euclid::rect(294.0, 26.0, 28.0, 28.0);
+ let mut widgets = UiContext::default();
+ widgets.push(card, WidgetKind::SidebarRow, OverviewAction::OpenThread(42));
+ widgets.push(close, WidgetKind::Button, OverviewAction::CloseTab(42));
+ let hit = widgets
+ .hit_test(close.center().x, close.center().y)
+ .expect("close button should hit");
+ assert_eq!(hit.action, OverviewAction::CloseTab(42));
+ }
+
+ #[test]
+ fn pending_close_can_be_cancelled_or_confirmed_without_closing_overview() {
+ let mut view = LiveOverviewView::new(0, "space", "workspace", 1.8);
+ view.pending_close = Some(PendingClose {
+ tab_id: 42,
+ title: "main".to_string(),
+ });
+ assert!(matches!(
+ view.cancel_close_tab(),
+ ContentViewResponse::Redraw
+ ));
+ assert!(view.pending_close.is_none());
+
+ view.pending_close = Some(PendingClose {
+ tab_id: 42,
+ title: "main".to_string(),
+ });
+ assert!(matches!(
+ view.confirm_close_tab(),
+ ContentViewResponse::Run(_)
+ ));
+ assert!(view.pending_close.is_none());
+ }
+
+ #[test]
+ fn scrollbar_is_transient_and_schedules_its_hide_frame() {
+ let mut view = LiveOverviewView::new(0, "space", "workspace", 1.8);
+ view.scroll.set_extents(100.0, 300.0);
+ let now = Instant::now();
+ assert!(!view.scrollbar_visible_at(now));
+
+ view.reveal_scrollbar(now);
+ let deadline = now + SCROLLBAR_VISIBLE_INTERVAL;
+ assert!(view.scrollbar_visible_at(deadline - Duration::from_millis(1)));
+ assert!(!view.scrollbar_visible_at(deadline));
+ assert_eq!(view.next_frame_deadline(now), Some(deadline));
+ }
+
+ #[test]
+ fn snapshot_cache_reuses_unchanged_content_and_throttles_live_resize() {
+ let key = LiveThreadKey {
+ space_id: "local".to_string(),
+ thread_id: "thread".to_string(),
+ };
+ let mut cache = HashMap::new();
+ let now = Instant::now();
+ let first_fingerprint = test_fingerprint(1);
+ let (snapshot, due) = resolve_snapshot(
+ &mut cache,
+ &key,
+ Some(first_fingerprint.clone()),
+ now,
+ None,
+ || Some(7_u8),
+ );
+ assert_eq!(*snapshot.unwrap(), 7);
+ assert!(due.is_none());
+
+ let (snapshot, due) = resolve_snapshot(
+ &mut cache,
+ &key,
+ Some(first_fingerprint),
+ now + Duration::from_millis(1),
+ None,
+ || panic!("unchanged fingerprint must not recapture"),
+ );
+ assert_eq!(*snapshot.unwrap(), 7);
+ assert!(due.is_none());
+
+ let changed_fingerprint = test_fingerprint(2);
+ let (snapshot, due) = resolve_snapshot(
+ &mut cache,
+ &key,
+ Some(changed_fingerprint.clone()),
+ now + Duration::from_millis(10),
+ Some(LIVE_RESIZE_PREVIEW_INTERVAL),
+ || panic!("live resize must reuse until the refresh deadline"),
+ );
+ assert_eq!(*snapshot.unwrap(), 7);
+ assert_eq!(due, Some(now + LIVE_RESIZE_PREVIEW_INTERVAL));
+
+ let (snapshot, due) = resolve_snapshot(
+ &mut cache,
+ &key,
+ Some(changed_fingerprint),
+ now + Duration::from_millis(34),
+ Some(LIVE_RESIZE_PREVIEW_INTERVAL),
+ || Some(8_u8),
+ );
+ assert_eq!(*snapshot.unwrap(), 8);
+ assert!(due.is_none());
+
+ let (snapshot, _) = resolve_snapshot(
+ &mut cache,
+ &key,
+ None,
+ now + Duration::from_millis(35),
+ None,
+ || panic!("missing live tab keeps the last successful snapshot"),
+ );
+ assert_eq!(*snapshot.unwrap(), 8);
+ let live = HashSet::<LiveThreadKey>::new();
+ cache.retain(|cached, _| live.contains(cached));
+ assert!(cache.is_empty());
+ }
+
+ #[test]
+ fn overview_warms_only_visible_and_adjacent_rows() {
+ let viewport = euclid::rect(0.0, 110.0, 1000.0, 100.0);
+ let card_height = 100.0;
+ let gap = 10.0;
+ let warm = (0..100)
+ .filter(|index| {
+ let row = index / 5;
+ let rect = euclid::rect(
+ (index % 5) as f32 * 100.0,
+ row as f32 * (card_height + gap),
+ 90.0,
+ card_height,
+ );
+ card_is_warm(rect, viewport, card_height + gap)
+ })
+ .count();
+ assert_eq!(warm, 15, "five visible cards plus one row on each side");
+ }
+
+ #[test]
+ fn group_layout_accounts_for_wrapped_rows_and_offline_heading() {
+ let (layouts, height) = group_layouts(
+ &[8, 0],
+ 1332.0,
+ 5,
+ 400.0,
+ 480.0,
+ 640.0,
+ 16.0,
+ 42.0,
+ 10.0,
+ 44.0,
+ 8.0,
+ 1.8,
+ 48.0,
+ );
+ assert_eq!(layouts.len(), 2);
+ assert!(layouts[1].header_y > layouts[0].cards_y);
+ assert_eq!(height, layouts[1].cards_y);
+ }
+
+ fn test_fingerprint(seqno: usize) -> TerminalPreviewFingerprint {
+ TerminalPreviewFingerprint {
+ tab_id: 1,
+ tab_size: TerminalSize::default(),
+ panes: vec![TerminalPreviewPaneFingerprint {
+ pane_id: 1,
+ index: 0,
+ is_active: true,
+ is_zoomed: false,
+ left: 0,
+ top: 0,
+ width: 80,
+ height: 24,
+ dimensions: RenderableDimensions::default(),
+ seqno,
+ palette_identity: 1,
+ cursor: StableCursorPosition::default(),
+ }],
+ splits: Vec::new(),
+ }
+ }
+
+ #[test]
+ fn scoped_keys_do_not_collide_across_spaces() {
+ let first = LiveThreadKey {
+ space_id: "local".to_string(),
+ thread_id: "thread-1".to_string(),
+ };
+ let second = LiveThreadKey {
+ space_id: "server".to_string(),
+ thread_id: "thread-1".to_string(),
+ };
+ assert_ne!(first, second);
+ }
+
+ #[test]
+ fn card_title_keeps_project_and_thread_on_one_line() {
+ assert_eq!(card_title("ThinkTerm", "main"), "ThinkTerm · main");
+ assert_eq!(card_title("main", "main"), "main");
+ }
+}
diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rs
index d5b601dd..1aea987b 100644
--- a/wezterm-gui/src/termwindow/mod.rs
+++ b/wezterm-gui/src/termwindow/mod.rs
@@ -18,7 +18,7 @@ use crate::tabbar::{TabBarItem, TabBarState};
use crate::termwindow::background::{
load_background_image, reload_background_image, LoadedBackgroundLayer,
};
-use crate::termwindow::content_view::{ContentView, ContentViewId};
+use crate::termwindow::content_view::{ContentView, ContentViewId, ContentViewPresentation};
use crate::termwindow::keyevent::{KeyTableArgs, KeyTableState};
use crate::termwindow::modal::Modal;
use crate::termwindow::render::paint::AllowImage;
@@ -150,6 +150,7 @@ pub mod charselect;
pub mod clipboard;
pub mod content_view;
pub mod keyevent;
+pub(crate) mod live_overview;
pub mod modal;
mod mouseevent;
pub mod onboarding;
@@ -437,6 +438,7 @@ pub enum UIItemType {
WorkspaceSidebarSettings,
WorkspaceSidebarViewOptions,
WorkspaceSidebarSshHosts,
+ WorkspaceSidebarLiveOverview,
WorkspaceSidebarNotifications,
RightSidebarToggle,
RightSidebarMode(RightSidebarMode),
@@ -1476,6 +1478,10 @@ pub struct TermWindow {
content_views: Vec<ContentViewTab>,
active_content_view_id: Option<ContentViewId>,
content_view_response_tab_id: Option<ContentViewId>,
+ /// A real terminal-size change arrived while a ContentView owned the
+ /// foreground. It is flushed once when terminal content becomes visible
+ /// again; merely opening and closing a view must not resize mux tabs.
+ content_view_deferred_mux_resize: bool,
next_content_view_id: ContentViewId,
registered_content_view_surfaces: HashMap<ContentViewId, MuxWindowId>,
/// Tracks SSH connections kicked off by `RemoteThreadView`s.
@@ -2255,6 +2261,7 @@ impl TermWindow {
content_views: vec![],
active_content_view_id: None,
content_view_response_tab_id: None,
+ content_view_deferred_mux_resize: false,
next_content_view_id: 1,
registered_content_view_surfaces: HashMap::new(),
remote_connects: HashMap::new(),
@@ -3485,7 +3492,10 @@ impl TermWindow {
fn mux_pane_output_event(&mut self, pane_id: PaneId) {
metrics::histogram!("mux.pane_output_event.rate").record(1.);
- if self.is_pane_visible(pane_id) {
+ let content_view_wants_output = self
+ .active_content_view()
+ .is_some_and(|view| view.wants_pane_output(pane_id));
+ if content_view_wants_output || self.is_pane_visible(pane_id) {
if let Some(ref win) = self.window {
win.invalidate();
}
@@ -4177,8 +4187,47 @@ impl TermWindow {
self.active_content_view_index().is_some()
}
+ pub(crate) fn active_content_view_presentation(&self) -> ContentViewPresentation {
+ self.active_content_view()
+ .map(|view| view.presentation())
+ .unwrap_or_default()
+ }
+
+ pub(crate) fn content_view_is_full_window(&self) -> bool {
+ self.content_view_foreground()
+ && self.active_content_view_presentation() == ContentViewPresentation::FullWindow
+ }
+
+ pub(crate) fn full_window_client_chrome_height(&self) -> f32 {
+ if crate::termwindow::ui::platform_chrome::full_window_needs_client_chrome(
+ self.config.window_decorations,
+ self.window_state,
+ cfg!(target_os = "macos"),
+ ) {
+ self.tab_bar_pixel_height().unwrap_or(0.0)
+ } else {
+ 0.0
+ }
+ }
+
pub(crate) fn content_view_area(&self) -> RectF {
let border = self.get_os_border();
+ if self.content_view_is_full_window() {
+ let left = border.left.get() as f32;
+ // Full-window views suppress the app tab strip, not the platform's
+ // essential controls. Reserve the same row independently of
+ // enable_tab_bar/hide_tab_bar_if_only_one_tab.
+ let top = border.top.get() as f32 + self.full_window_client_chrome_height();
+ let right = self
+ .dimensions
+ .pixel_width
+ .saturating_sub(border.right.get() as usize) as f32;
+ let bottom = self
+ .dimensions
+ .pixel_height
+ .saturating_sub(border.bottom.get() as usize) as f32;
+ return euclid::rect(left, top, (right - left).max(0.0), (bottom - top).max(0.0));
+ }
let top_tab_h = if self.show_tab_bar && !self.config.tab_bar_at_bottom {
self.tab_bar_pixel_height().unwrap_or(0.0)
} else {
@@ -4350,7 +4399,12 @@ impl TermWindow {
});
self.sync_content_view_surfaces_with_mux();
self.sync_workspace_sidebar_pending_thread_selection();
- if was_foreground && !self.content_view_foreground() {
+ let is_foreground = self.content_view_foreground();
+ if crate::termwindow::content_view::take_deferred_mux_resize_on_exit(
+ &mut self.content_view_deferred_mux_resize,
+ was_foreground,
+ is_foreground,
+ ) {
self.resize_mux_tabs_to_current_terminal_size();
}
self.invalidate_window();
@@ -4420,7 +4474,12 @@ impl TermWindow {
self.sync_content_view_surfaces_with_mux();
self.sync_workspace_sidebar_pending_thread_selection();
- if was_foreground && !self.content_view_foreground() {
+ let is_foreground = self.content_view_foreground();
+ if crate::termwindow::content_view::take_deferred_mux_resize_on_exit(
+ &mut self.content_view_deferred_mux_resize,
+ was_foreground,
+ is_foreground,
+ ) {
self.resize_mux_tabs_to_current_terminal_size();
}
self.invalidate_window();
@@ -4519,6 +4578,39 @@ impl TermWindow {
}
}
+ /// Toggle the global Safari-style live terminal overview. It is a
+ /// full-window ContentView, but keeps the terminal grid and the user's
+ /// sidebar preferences untouched behind it.
+ pub(crate) fn toggle_live_overview_view(&mut self) {
+ let key = crate::termwindow::live_overview::LIVE_OVERVIEW_CONTENT_VIEW_KEY;
+ if self.active_content_view_key_is(key) {
+ self.close_content_view();
+ } else if let Some(id) = self.content_view_id_for_key(key) {
+ self.activate_content_view(id);
+ } else {
+ let active_workspace = self
+ .current_mux_workspace()
+ .unwrap_or_else(|| Mux::get().active_workspace());
+ let host_preview_aspect = if self.terminal_size.pixel_height > 0 {
+ self.terminal_size.pixel_width as f32 / self.terminal_size.pixel_height as f32
+ } else {
+ let width = self.terminal_size.cols as f32
+ * self.render_metrics.cell_size.width.max(1) as f32;
+ let height = self.terminal_size.rows as f32
+ * self.render_metrics.cell_size.height.max(1) as f32;
+ width / height.max(1.0)
+ };
+ self.open_content_view(Box::new(
+ crate::termwindow::live_overview::LiveOverviewView::new(
+ self.space_owner_id,
+ &self.active_space_id,
+ &active_workspace,
+ host_preview_aspect,
+ ),
+ ));
+ }
+ }
+
fn invalidate_window(&self) {
if let Some(window) = self.window.as_ref() {
window.invalidate();
@@ -6770,6 +6862,9 @@ impl TermWindow {
OpenSshHosts => {
self.toggle_ssh_hosts_view();
}
+ ToggleLiveOverview => {
+ self.toggle_live_overview_view();
+ }
ActivateCommandPalette => {
let modal = crate::termwindow::palette::CommandPalette::new(self);
self.set_modal(Rc::new(modal));
diff --git a/wezterm-gui/src/termwindow/mouseevent.rs b/wezterm-gui/src/termwindow/mouseevent.rs
index c35b8ba9..78ddef81 100644
--- a/wezterm-gui/src/termwindow/mouseevent.rs
+++ b/wezterm-gui/src/termwindow/mouseevent.rs
@@ -1016,6 +1016,7 @@ impl super::TermWindow {
| UIItemType::WorkspaceSidebarSettings
| UIItemType::WorkspaceSidebarViewOptions
| UIItemType::WorkspaceSidebarSshHosts
+ | UIItemType::WorkspaceSidebarLiveOverview
| UIItemType::WorkspaceSidebarNotifications
| UIItemType::RightSidebarToggle
| UIItemType::RightSidebarMode(_)
@@ -1097,6 +1098,7 @@ impl super::TermWindow {
| UIItemType::WorkspaceSidebarSettings
| UIItemType::WorkspaceSidebarViewOptions
| UIItemType::WorkspaceSidebarSshHosts
+ | UIItemType::WorkspaceSidebarLiveOverview
| UIItemType::WorkspaceSidebarNotifications
| UIItemType::RightSidebarToggle
| UIItemType::RightSidebarMode(_)
@@ -3024,6 +3026,12 @@ impl super::TermWindow {
self.toggle_ssh_hosts_view();
}
}
+ UIItemType::WorkspaceSidebarLiveOverview => {
+ context.set_cursor(Some(MouseCursor::Hand));
+ if event.kind == WMEK::Press(MousePress::Left) {
+ self.toggle_live_overview_view();
+ }
+ }
UIItemType::ContentViewClose(id) => {
context.set_cursor(Some(MouseCursor::Hand));
if event.kind == WMEK::Press(MousePress::Left) {
@@ -3418,6 +3426,12 @@ impl super::TermWindow {
self.toggle_ssh_hosts_view();
}
}
+ UIItemType::WorkspaceSidebarLiveOverview => {
+ context.set_cursor(Some(MouseCursor::Hand));
+ if event.kind == WMEK::Press(MousePress::Left) {
+ self.toggle_live_overview_view();
+ }
+ }
UIItemType::WorkspaceSidebarViewOptions => {
self.mouse_event_workspace_sidebar_view_options(item, event, context);
}
diff --git a/wezterm-gui/src/termwindow/render/corners.rs b/wezterm-gui/src/termwindow/render/corners.rs
index a1a93b9f..c20caa2f 100644
--- a/wezterm-gui/src/termwindow/render/corners.rs
+++ b/wezterm-gui/src/termwindow/render/corners.rs
@@ -36,6 +36,118 @@ pub const BOTTOM_RIGHT_ROUNDED_CORNER: &[Poly] = &[Poly {
style: PolyStyle::Fill,
}];
+// The complementary pieces outside a rounded corner. They are used after a
+// live terminal preview has been painted: covering those four small wedges is
+// the GPU equivalent of a rounded clip, without introducing a stencil pass or
+// re-rasterising the terminal into an intermediate texture.
+
+pub const TOP_LEFT_ROUNDED_CORNER_MASK: &[Poly] = &[Poly {
+ path: &[
+ PolyCommand::MoveTo(BlockCoord::Zero, BlockCoord::Zero),
+ PolyCommand::LineTo(BlockCoord::One, BlockCoord::Zero),
+ PolyCommand::QuadTo {
+ control: (BlockCoord::Zero, BlockCoord::Zero),
+ to: (BlockCoord::Zero, BlockCoord::One),
+ },
+ PolyCommand::Close,
+ ],
+ intensity: BlockAlpha::Full,
+ style: PolyStyle::Fill,
+}];
+
+pub const TOP_RIGHT_ROUNDED_CORNER_MASK: &[Poly] = &[Poly {
+ path: &[
+ PolyCommand::MoveTo(BlockCoord::Zero, BlockCoord::Zero),
+ PolyCommand::LineTo(BlockCoord::One, BlockCoord::Zero),
+ PolyCommand::LineTo(BlockCoord::One, BlockCoord::One),
+ PolyCommand::QuadTo {
+ control: (BlockCoord::One, BlockCoord::Zero),
+ to: (BlockCoord::Zero, BlockCoord::Zero),
+ },
+ PolyCommand::Close,
+ ],
+ intensity: BlockAlpha::Full,
+ style: PolyStyle::Fill,
+}];
+
+pub const BOTTOM_LEFT_ROUNDED_CORNER_MASK: &[Poly] = &[Poly {
+ path: &[
+ PolyCommand::MoveTo(BlockCoord::Zero, BlockCoord::Zero),
+ PolyCommand::LineTo(BlockCoord::Zero, BlockCoord::One),
+ PolyCommand::LineTo(BlockCoord::One, BlockCoord::One),
+ PolyCommand::QuadTo {
+ control: (BlockCoord::Zero, BlockCoord::One),
+ to: (BlockCoord::Zero, BlockCoord::Zero),
+ },
+ PolyCommand::Close,
+ ],
+ intensity: BlockAlpha::Full,
+ style: PolyStyle::Fill,
+}];
+
+pub const BOTTOM_RIGHT_ROUNDED_CORNER_MASK: &[Poly] = &[Poly {
+ path: &[
+ PolyCommand::MoveTo(BlockCoord::One, BlockCoord::Zero),
+ PolyCommand::LineTo(BlockCoord::One, BlockCoord::One),
+ PolyCommand::LineTo(BlockCoord::Zero, BlockCoord::One),
+ PolyCommand::QuadTo {
+ control: (BlockCoord::One, BlockCoord::One),
+ to: (BlockCoord::One, BlockCoord::Zero),
+ },
+ PolyCommand::Close,
+ ],
+ intensity: BlockAlpha::Full,
+ style: PolyStyle::Fill,
+}];
+
+pub const TOP_LEFT_ROUNDED_CORNER_OUTLINE: &[Poly] = &[Poly {
+ path: &[
+ PolyCommand::MoveTo(BlockCoord::One, BlockCoord::Zero),
+ PolyCommand::QuadTo {
+ control: (BlockCoord::Zero, BlockCoord::Zero),
+ to: (BlockCoord::Zero, BlockCoord::One),
+ },
+ ],
+ intensity: BlockAlpha::Full,
+ style: PolyStyle::OutlineThin,
+}];
+
+pub const TOP_RIGHT_ROUNDED_CORNER_OUTLINE: &[Poly] = &[Poly {
+ path: &[
+ PolyCommand::MoveTo(BlockCoord::Zero, BlockCoord::Zero),
+ PolyCommand::QuadTo {
+ control: (BlockCoord::One, BlockCoord::Zero),
+ to: (BlockCoord::One, BlockCoord::One),
+ },
+ ],
+ intensity: BlockAlpha::Full,
+ style: PolyStyle::OutlineThin,
+}];
+
+pub const BOTTOM_LEFT_ROUNDED_CORNER_OUTLINE: &[Poly] = &[Poly {
+ path: &[
+ PolyCommand::MoveTo(BlockCoord::Zero, BlockCoord::Zero),
+ PolyCommand::QuadTo {
+ control: (BlockCoord::Zero, BlockCoord::One),
+ to: (BlockCoord::One, BlockCoord::One),
+ },
+ ],
+ intensity: BlockAlpha::Full,
+ style: PolyStyle::OutlineThin,
+}];
+
+pub const BOTTOM_RIGHT_ROUNDED_CORNER_OUTLINE: &[Poly] = &[Poly {
+ path: &[
+ PolyCommand::MoveTo(BlockCoord::One, BlockCoord::Zero),
+ PolyCommand::QuadTo {
+ control: (BlockCoord::One, BlockCoord::One),
+ to: (BlockCoord::Zero, BlockCoord::One),
+ },
+ ],
+ intensity: BlockAlpha::Full,
+ style: PolyStyle::OutlineThin,
+}];
+
// Quarter-annulus ring corners: the border stroke of a rounded corner,
// filled as outer arc + inner arc with a ring thickness of 1/5 of the
// corner cell. Together with edge strips of the same thickness they form
diff --git a/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs b/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs
index e879db0e..ec0d3c15 100644
--- a/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs
+++ b/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs
@@ -363,6 +363,69 @@ impl crate::TermWindow {
Ok(ui_items)
}
+ /// Paint only the essential native/client window chrome over a full-window
+ /// ContentView. The normal tabs and sidebar actions stay suppressed, while
+ /// the blank row retains window dragging and integrated buttons retain the
+ /// exact same hit targets and visual treatment as the fancy tab bar.
+ pub(crate) fn paint_full_window_chrome(
+ &self,
+ layers: &mut TripleLayerQuadAllocator,
+ ) -> anyhow::Result<Vec<UIItem>> {
+ let row_height = self.full_window_client_chrome_height().ceil() as usize;
+ if row_height == 0 {
+ return Ok(Vec::new());
+ }
+
+ let border = self.get_os_border();
+ let row_x = border.left.get() as usize;
+ let row_y = border.top.get() as usize;
+ let row_right = self
+ .dimensions
+ .pixel_width
+ .saturating_sub(border.right.get() as usize);
+ let row_width = row_right.saturating_sub(row_x);
+ if row_width == 0 {
+ return Ok(Vec::new());
+ }
+
+ let mut ui_items = vec![UIItem {
+ x: row_x,
+ y: row_y,
+ width: row_width,
+ height: row_height,
+ item_type: UIItemType::TabBar(TabBarItem::None),
+ }];
+
+ if self.fancy_tab_bar_shows_window_buttons() {
+ let chrome = UiPalette::for_appearance(crate::native_settings::effective_appearance());
+ let font = self
+ .fonts
+ .title_font_with_size(crate::native_settings::tab_font_size())?;
+ let metrics = RenderMetrics::with_font_metrics(&font.metrics());
+ let content_top_spacer = self.ui_px(WINDOW_TAB_TOP_SPACER).min(row_height);
+ let content_row_y = row_y + content_top_spacer;
+ let content_row_height = row_height.saturating_sub(content_top_spacer);
+ let icon_size = fancy_tab_icon_size(&metrics, content_row_height as f32) as usize;
+ let button_size = content_row_height
+ .saturating_sub(self.ui_px(TAB_VERTICAL_PADDING) * 2)
+ .max(icon_size);
+ let action_right = row_right.saturating_sub(self.ui_px(WINDOW_TAB_INSET) + 2);
+ self.paint_window_tab_window_buttons(
+ layers,
+ &mut ui_items,
+ action_right,
+ content_row_y,
+ content_row_height,
+ button_size,
+ icon_size,
+ chrome.text,
+ chrome.secondary_text,
+ )?;
+ }
+
+ Ok(ui_items)
+ }
+
fn fancy_tab_bar_shows_window_buttons(&self) -> bool {
uses_integrated_window_buttons(self.config.window_decorations, self.window_state)
&& self.config.integrated_title_button_style != IntegratedTitleButtonStyle::MacOsNative
diff --git a/wezterm-gui/src/termwindow/render/mod.rs b/wezterm-gui/src/termwindow/render/mod.rs
index 15ba5f1e..03a2009a 100644
--- a/wezterm-gui/src/termwindow/render/mod.rs
+++ b/wezterm-gui/src/termwindow/render/mod.rs
@@ -184,6 +184,11 @@ pub struct RenderScreenLineParams<'a> {
pub font_identity: u64,
pub shape_key: Option<LineToEleShapeCacheKey>,
pub password_input: bool,
+
+ /// Whether terminal image cells should be emitted for this render pass.
+ /// Live Overview keeps the source line untouched and suppresses only the
+ /// image quads; regular terminal painting enables them.
+ pub allow_images: bool,
}
#[derive(Debug, Hash, PartialEq, Eq, Clone)]
diff --git a/wezterm-gui/src/termwindow/render/paint.rs b/wezterm-gui/src/termwindow/render/paint.rs
index 997dfe5a..b40ddd6f 100644
--- a/wezterm-gui/src/termwindow/render/paint.rs
+++ b/wezterm-gui/src/termwindow/render/paint.rs
@@ -1,13 +1,82 @@
-use crate::quad::{QuadTrait, TripleLayerQuadAllocator};
+use crate::quad::{HeapQuadAllocator, QuadTrait, TripleLayerQuadAllocator};
+use crate::termwindow::content_view::{ContentViewTypography, TerminalPreviewRequest};
+use crate::termwindow::render::{LineToEleShapeCacheKey, RenderScreenLineParams};
use crate::termwindow::{RenderFrame, TermWindowNotif};
use crate::ui::{DrawContext, UiPalette};
use ::window::bitmaps::atlas::OutOfTextureSpace;
use ::window::color::LinearRgba;
use ::window::WindowOps;
use anyhow::Context;
+use mux::renderable::StableCursorPosition;
+use mux::tab::SplitDirection;
use smol::Timer;
+use std::collections::hash_map::DefaultHasher;
+use std::hash::{Hash, Hasher};
use std::time::{Duration, Instant};
use wezterm_font::ClearShapeCache;
+use wezterm_term::color::ColorAttribute;
+
+const TERMINAL_PREVIEW_EXTENT_BUCKET_DESIGN_PX: f32 = 8.0;
+const TERMINAL_PREVIEW_SCALE_BUCKETS_PER_UNIT: f64 = 128.0;
+
+fn quantized_terminal_preview_extent(extent: f32, dpi: usize) -> f32 {
+ let bucket = crate::ui::scale_ui_f32(TERMINAL_PREVIEW_EXTENT_BUCKET_DESIGN_PX, dpi).max(1.0);
+ if extent <= bucket {
+ extent.max(1.0)
+ } else {
+ (extent / bucket).floor() * bucket
+ }
+}
+
+fn minimum_terminal_preview_scale(font_size: f64, dpi: usize, global_scale: f64) -> f64 {
+ let global_scale = global_scale.max(1.0 / TERMINAL_PREVIEW_SCALE_BUCKETS_PER_UNIT);
+ if !font_size.is_finite() || font_size <= 0.0 || dpi == 0 {
+ return (1.0 / TERMINAL_PREVIEW_SCALE_BUCKETS_PER_UNIT).min(global_scale);
+ }
+ (72.0 / (font_size * dpi as f64))
+ .max(1.0 / TERMINAL_PREVIEW_SCALE_BUCKETS_PER_UNIT)
+ .min(global_scale)
+}
+
+fn quantize_terminal_preview_scale_down(scale: f64, minimum: f64) -> f64 {
+ if !scale.is_finite() {
+ return minimum;
+ }
+ ((scale * TERMINAL_PREVIEW_SCALE_BUCKETS_PER_UNIT).floor()
+ / TERMINAL_PREVIEW_SCALE_BUCKETS_PER_UNIT)
+ .max(minimum)
+}
+
+#[cfg(test)]
+mod terminal_preview_tests {
+ use super::{
+ minimum_terminal_preview_scale, quantize_terminal_preview_scale_down,
+ quantized_terminal_preview_extent,
+ };
+
+ #[test]
+ fn preview_extent_uses_four_logical_pixel_buckets() {
+ let design_dpi = if cfg!(target_os = "macos") { 144 } else { 192 };
+ let one_x_dpi = if cfg!(target_os = "macos") { 72 } else { 96 };
+ assert_eq!(quantized_terminal_preview_extent(103.0, design_dpi), 96.0);
+ assert_eq!(quantized_terminal_preview_extent(104.0, design_dpi), 104.0);
+ assert_eq!(quantized_terminal_preview_extent(103.0, one_x_dpi), 100.0);
+ }
+
+ #[test]
+ fn preview_scale_can_shrink_below_the_old_twelve_percent_floor() {
+ let minimum = minimum_terminal_preview_scale(14.0, 144, 1.0);
+ assert!(minimum < 0.12);
+ assert_eq!(
+ quantize_terminal_preview_scale_down(0.08, minimum),
+ 0.078125
+ );
+ assert_eq!(
+ quantize_terminal_preview_scale_down(0.001, minimum),
+ minimum
+ );
+ }
+}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AllowImage {
@@ -351,17 +420,34 @@ impl crate::TermWindow {
layers: &mut TripleLayerQuadAllocator<'_>,
) -> anyhow::Result<()> {
let settings = crate::native_settings::load();
- let font_size = crate::native_settings::home_font_size(&settings);
let font_weight = crate::native_settings::settings_font_weight(&settings);
- let ui_font = self
- .fonts
- .command_palette_font_with_size_and_weight(font_size, font_weight)?;
- let title_font = self
- .fonts
- .title_font_with_size_and_weight(font_size + 10.0, font_weight.max(760))?;
- let section_font = self
- .fonts
- .title_font_with_size_and_weight(font_size + 2.0, font_weight.max(700))?;
+ let active_content_view_idx = self.active_content_view_index();
+ let typography = active_content_view_idx
+ .map(|idx| self.content_views[idx].view.typography())
+ .unwrap_or_default();
+ let (ui_font, title_font, section_font) = match typography {
+ ContentViewTypography::Default => {
+ let font_size = crate::native_settings::home_font_size(&settings);
+ (
+ self.fonts
+ .command_palette_font_with_size_and_weight(font_size, font_weight)?,
+ self.fonts
+ .title_font_with_size_and_weight(font_size + 10.0, font_weight.max(760))?,
+ self.fonts
+ .title_font_with_size_and_weight(font_size + 2.0, font_weight.max(700))?,
+ )
+ }
+ ContentViewTypography::Overview => (
+ self.fonts.command_palette_font_with_size_and_weight(
+ crate::native_settings::settings_font_size(&settings),
+ font_weight,
+ )?,
+ self.fonts
+ .title_font_with_size(crate::native_settings::sidebar_font_size())?,
+ self.fonts
+ .title_font_with_size(crate::native_settings::pane_header_font_size())?,
+ ),
+ };
let render_metrics =
crate::utilsprites::RenderMetrics::with_font_metrics(&ui_font.metrics());
let dimensions = self.dimensions;
@@ -370,8 +456,12 @@ impl crate::TermWindow {
// Occupy the terminal content area between the workspace and right
// sidebars, below the top tab bar and above a bottom tab bar.
let area = self.content_view_area();
- let active_content_view_idx = self.active_content_view_index();
-
+ let surface = euclid::rect(
+ 0.0,
+ 0.0,
+ dimensions.pixel_width as f32,
+ dimensions.pixel_height as f32,
+ );
// Cursor blink: only animate when the view wants it (focused input).
let wants_blink = active_content_view_idx
.map(|idx| self.content_views[idx].view.wants_cursor_blink())
@@ -390,28 +480,350 @@ impl crate::TermWindow {
self.update_next_frame_time(Some(Instant::now() + Duration::from_millis(blink_ms)));
}
- let gl_state = self.render_state.as_ref().unwrap();
- let ctx = DrawContext::new(gl_state, dimensions, &render_metrics);
- let next_frame = if let Some(idx) = active_content_view_idx {
- let view = self.content_views[idx].view.as_mut();
- view.paint(
- &ctx,
- layers,
- area,
- palette,
- &ui_font,
- &title_font,
- &section_font,
- cursor_on,
- )?;
- view.next_frame_time()
- } else {
- None
+ let (next_frame, previews) = {
+ let gl_state = self.render_state.as_ref().unwrap();
+ let ctx = DrawContext::new(gl_state, dimensions, &render_metrics);
+ if let Some(idx) = active_content_view_idx {
+ let view = self.content_views[idx].view.as_mut();
+ view.paint_surface_background(&ctx, layers, surface, palette)?;
+ view.paint(
+ &ctx,
+ layers,
+ area,
+ palette,
+ &ui_font,
+ &title_font,
+ &section_font,
+ cursor_on,
+ )?;
+ (view.next_frame_time(), view.terminal_previews())
+ } else {
+ (None, Vec::new())
+ }
};
+ self.paint_terminal_previews(layers, &previews)?;
+ {
+ let gl_state = self.render_state.as_ref().unwrap();
+ let ctx = DrawContext::new(gl_state, dimensions, &render_metrics);
+ if let Some(idx) = active_content_view_idx {
+ self.content_views[idx].view.paint_after_terminal_previews(
+ &ctx,
+ layers,
+ area,
+ palette,
+ &ui_font,
+ &title_font,
+ &section_font,
+ )?;
+ }
+ }
self.update_next_frame_time(next_frame);
Ok(())
}
+ /// Render live, read-only terminal thumbnails requested by a ContentView.
+ /// This reuses the normal screen-line renderer at a smaller font scale;
+ /// panes are never resized and no input or focus is sent to them.
+ fn paint_terminal_previews(
+ &mut self,
+ layers: &mut TripleLayerQuadAllocator<'_>,
+ previews: &[TerminalPreviewRequest],
+ ) -> anyhow::Result<()> {
+ for preview in previews {
+ self.paint_terminal_preview(layers, preview)?;
+ }
+ Ok(())
+ }
+
+ fn paint_terminal_preview(
+ &mut self,
+ layers: &mut TripleLayerQuadAllocator<'_>,
+ preview: &TerminalPreviewRequest,
+ ) -> anyhow::Result<()> {
+ let mut heap = HeapQuadAllocator::default();
+ {
+ let mut clipped_layers = TripleLayerQuadAllocator::Heap(&mut heap);
+ self.paint_terminal_preview_unclipped(&mut clipped_layers, preview)?;
+ }
+ heap.apply_to_clipped(
+ layers,
+ preview.clip,
+ self.dimensions.pixel_width as f32,
+ self.dimensions.pixel_height as f32,
+ )
+ }
+
+ fn paint_terminal_preview_unclipped(
+ &mut self,
+ layers: &mut TripleLayerQuadAllocator<'_>,
+ preview: &TerminalPreviewRequest,
+ ) -> anyhow::Result<()> {
+ let snapshot = &preview.snapshot;
+ let tab_size = snapshot.tab_size;
+ if tab_size.cols == 0 || tab_size.rows == 0 {
+ return Ok(());
+ }
+ if snapshot.panes.is_empty() {
+ return Ok(());
+ }
+
+ // A thumbnail represents the whole terminal surface, not just the
+ // shrunken PTY grid. Fill any aspect-ratio remainder with the active
+ // terminal's own background so the card never looks letterboxed.
+ let preview_background = snapshot
+ .panes
+ .iter()
+ .find(|pane| pane.is_active)
+ .or_else(|| snapshot.panes.first())
+ .map(|pane| pane.palette.resolve_bg(ColorAttribute::Default).to_linear())
+ .expect("checked that the tab has panes");
+ self.filled_rectangle(layers, 0, preview.clip, preview_background)?;
+
+ // Quantization bounds the number of cached FontConfigurations even
+ // when cards continuously resize. Flooring guarantees the terminal
+ // grid stays inside its preview rather than clipping the last column.
+ let bucketed_width =
+ quantized_terminal_preview_extent(preview.area.size.width, self.dimensions.dpi);
+ let bucketed_height =
+ quantized_terminal_preview_extent(preview.area.size.height, self.dimensions.dpi);
+ let width_ratio = bucketed_width
+ / (tab_size.cols as f32 * self.render_metrics.cell_size.width.max(1) as f32);
+ let height_ratio = bucketed_height
+ / (tab_size.rows as f32 * self.render_metrics.cell_size.height.max(1) as f32);
+ let global_scale = self.fonts.get_font_scale();
+ let minimum_scale = minimum_terminal_preview_scale(
+ self.config.font_size,
+ self.dimensions.dpi,
+ global_scale,
+ );
+ let maximum_scale = (global_scale * 0.84).max(minimum_scale);
+ let desired_scale = (global_scale * f64::from(width_ratio.min(height_ratio)))
+ .clamp(minimum_scale, maximum_scale);
+ let mut quantized_scale =
+ quantize_terminal_preview_scale_down(desired_scale, minimum_scale);
+ let (mut font_config, mut metrics) = self.pane_font_resources(quantized_scale)?;
+
+ // Font raster metrics are integer pixels and therefore do not scale
+ // perfectly linearly. Correct the analytical estimate once using the
+ // actual metrics; if the one-pixel raster floor is still too large, the
+ // hard quad clip below remains the final safety boundary.
+ let rendered_width = tab_size.cols as f32 * metrics.cell_size.width.max(1) as f32;
+ let rendered_height = tab_size.rows as f32 * metrics.cell_size.height.max(1) as f32;
+ let correction = (bucketed_width / rendered_width)
+ .min(bucketed_height / rendered_height)
+ .min(1.0);
+ if correction < 1.0 {
+ let corrected_scale = quantize_terminal_preview_scale_down(
+ quantized_scale * f64::from(correction) * 0.999,
+ minimum_scale,
+ );
+ if corrected_scale < quantized_scale {
+ quantized_scale = corrected_scale;
+ (font_config, metrics) = self.pane_font_resources(quantized_scale)?;
+ }
+ }
+
+ let still_too_wide =
+ tab_size.cols as f32 * metrics.cell_size.width.max(1) as f32 > bucketed_width;
+ let still_too_tall =
+ tab_size.rows as f32 * metrics.cell_size.height.max(1) as f32 > bucketed_height;
+ if (still_too_wide || still_too_tall) && quantized_scale > minimum_scale {
+ quantized_scale = minimum_scale;
+ (font_config, metrics) = self.pane_font_resources(quantized_scale)?;
+ }
+ let cell_width = metrics.cell_size.width.max(1) as f32;
+ let cell_height = metrics.cell_size.height.max(1) as f32;
+ // Terminal content begins at the same top-left origin as the real
+ // terminal. Any remainder stays on the right/bottom and is visually
+ // continuous with the background painted above.
+ let origin_x = preview.area.origin.x;
+ let origin_y = preview.area.origin.y;
+
+ let gl_state = self.render_state.as_ref().unwrap();
+ let white_space = gl_state.util_sprites.white_space.texture_coords();
+ let filled_box = gl_state.util_sprites.filled_box.texture_coords();
+ let mut hidden_cursor = StableCursorPosition::default();
+ hidden_cursor.y = isize::MIN;
+
+ for pane in &snapshot.panes {
+ let palette = &pane.palette;
+ let pane_x = origin_x + pane.left as f32 * cell_width;
+ let pane_y = origin_y + pane.top as f32 * cell_height;
+ let pane_width = pane.width as f32 * cell_width;
+ let pane_height = pane.height as f32 * cell_height;
+ let pane_rect = euclid::rect(pane_x, pane_y, pane_width, pane_height);
+ if let Some(visible) = pane_rect.intersection(&preview.clip) {
+ self.filled_rectangle(
+ layers,
+ 0,
+ visible,
+ palette.resolve_bg(ColorAttribute::Default).to_linear(),
+ )?;
+ }
+
+ let source_dims = pane.dimensions;
+ let rows = pane.rows;
+ let cols = pane.cols;
+ if rows == 0 || cols == 0 {
+ continue;
+ }
+
+ let mut render_dims = source_dims;
+ render_dims.cols = cols;
+ render_dims.viewport_rows = rows;
+ render_dims.pixel_width = (cols as f32 * cell_width).round() as usize;
+ render_dims.pixel_height = (rows as f32 * cell_height).round() as usize;
+ let rendered_y = pane_y + pane.height.saturating_sub(rows) as f32 * cell_height;
+ let foreground = palette.foreground.to_linear();
+ let default_bg = palette.background.to_linear();
+ // LineToElementShape caches resolved colors as well as glyph
+ // geometry. Include the pane palette so two terminals with the
+ // same text/ANSI indexes cannot reuse each other's resolved color
+ // values inside the overview.
+ let mut palette_hasher = DefaultHasher::new();
+ palette.colors.0.hash(&mut palette_hasher);
+ palette.foreground.hash(&mut palette_hasher);
+ palette.background.hash(&mut palette_hasher);
+ palette.cursor_fg.hash(&mut palette_hasher);
+ palette.cursor_bg.hash(&mut palette_hasher);
+ palette.cursor_border.hash(&mut palette_hasher);
+ palette.selection_fg.hash(&mut palette_hasher);
+ palette.selection_bg.hash(&mut palette_hasher);
+ let palette_identity = palette_hasher.finish();
+ let font_identity = quantized_scale.to_bits()
+ ^ palette_identity.rotate_left(17)
+ ^ 0x4c49_5645_5052_4556;
+
+ for (line_idx, line) in pane.lines.iter().enumerate() {
+ let y = rendered_y + line_idx as f32 * cell_height;
+ if y + cell_height <= preview.clip.min_y() || y >= preview.clip.max_y() {
+ continue;
+ }
+ let shape_hash = self.shape_hash_for_line(line);
+ self.render_screen_line(
+ RenderScreenLineParams {
+ top_pixel_y: y,
+ left_pixel_x: pane_x,
+ pixel_width: cols as f32 * cell_width,
+ stable_line_idx: Some(pane.resolved_top + line_idx as isize),
+ line,
+ selection: 0..0,
+ cursor: &hidden_cursor,
+ palette,
+ dims: &render_dims,
+ config: &self.config,
+ pane: None,
+ white_space,
+ filled_box,
+ cursor_border_color: palette.cursor_border.to_linear(),
+ foreground,
+ is_active: true,
+ selection_fg: palette.selection_fg.to_linear(),
+ selection_bg: palette.selection_bg.to_linear(),
+ cursor_fg: palette.cursor_fg.to_linear(),
+ cursor_bg: palette.cursor_bg.to_linear(),
+ cursor_is_default_color: true,
+ window_is_transparent: false,
+ default_bg,
+ font: None,
+ style: None,
+ use_pixel_positioning: false,
+ render_metrics: metrics,
+ font_config: Some(font_config.clone()),
+ font_identity,
+ shape_key: Some(LineToEleShapeCacheKey {
+ shape_hash,
+ composing: None,
+ shape_generation: self.shape_generation,
+ font_identity,
+ }),
+ password_input: false,
+ allow_images: false,
+ },
+ layers,
+ )?;
+ }
+
+ // Draw a non-blinking cursor for the active split. The regular
+ // renderer intentionally receives a hidden cursor above, so this
+ // thumbnail cannot start the foreground cursor animation timer.
+ if pane.is_active {
+ let cursor = pane.cursor;
+ let cursor_row = cursor.y.saturating_sub(pane.resolved_top);
+ if cursor.visibility == termwiz::surface::CursorVisibility::Visible
+ && cursor_row >= 0
+ && (cursor_row as usize) < rows
+ && cursor.x < cols
+ {
+ let cursor_rect = euclid::rect(
+ pane_x + cursor.x as f32 * cell_width,
+ rendered_y + cursor_row as f32 * cell_height,
+ cell_width,
+ cell_height,
+ );
+ if let Some(cursor_rect) = cursor_rect.intersection(&preview.clip) {
+ let color = palette.cursor_border.to_linear().mul_alpha(0.72);
+ let stroke = 1.0_f32.min(cursor_rect.size.width / 2.0);
+ self.filled_rectangle(
+ layers,
+ 2,
+ euclid::rect(
+ cursor_rect.origin.x,
+ cursor_rect.origin.y,
+ cursor_rect.size.width,
+ stroke,
+ ),
+ color,
+ )?;
+ self.filled_rectangle(
+ layers,
+ 2,
+ euclid::rect(
+ cursor_rect.origin.x,
+ cursor_rect.max_y() - stroke,
+ cursor_rect.size.width,
+ stroke,
+ ),
+ color,
+ )?;
+ }
+ }
+ }
+ }
+
+ // Preserve split topology in the thumbnail. PositionedSplit is part
+ // of the immutable snapshot, so this pass also performs no mux reads.
+ let split_color = snapshot
+ .panes
+ .iter()
+ .find(|pane| pane.is_active)
+ .or_else(|| snapshot.panes.first())
+ .map(|pane| pane.palette.split.to_linear())
+ .unwrap_or(preview_background);
+ let split_stroke = (metrics.underline_height as f32 * 0.7).max(1.0);
+ for split in &snapshot.splits {
+ let rect = if split.direction == SplitDirection::Horizontal {
+ euclid::rect(
+ origin_x + (split.left as f32 + 0.5) * cell_width,
+ origin_y + (split.top as f32 - 0.5) * cell_height,
+ split_stroke,
+ (1.0 + split.size as f32) * cell_height,
+ )
+ } else {
+ euclid::rect(
+ origin_x + (split.left as f32 - 0.5) * cell_width,
+ origin_y + (split.top as f32 + 0.5) * cell_height,
+ (1.0 + split.size as f32) * cell_width,
+ split_stroke,
+ )
+ };
+ if let Some(visible) = rect.intersection(&preview.clip) {
+ self.filled_rectangle(layers, 2, visible, split_color)?;
+ }
+ }
+ Ok(())
+ }
+
pub fn paint_modal(&mut self) -> anyhow::Result<()> {
if let Some(modal) = self.get_modal() {
for computed in modal.computed_element(self)?.iter() {
@@ -938,13 +1350,23 @@ impl crate::TermWindow {
.context("paint_content_view")?;
}
- self.paint_workspace_sidebar(&mut layers)
- .context("paint_workspace_sidebar")?;
- self.paint_right_sidebar(&mut layers)
- .context("paint_right_sidebar")?;
+ // A full-window ContentView owns all ThinkTerm chrome below the native
+ // title bar. This is presentation-only: sidebar widths/collapse state
+ // and terminal geometry stay unchanged behind the view.
+ if self.content_view_is_full_window() {
+ let mut chrome_items = self
+ .paint_full_window_chrome(&mut layers)
+ .context("paint full-window client chrome")?;
+ self.ui_items.append(&mut chrome_items);
+ } else {
+ self.paint_workspace_sidebar(&mut layers)
+ .context("paint_workspace_sidebar")?;
+ self.paint_right_sidebar(&mut layers)
+ .context("paint_right_sidebar")?;
- if self.show_tab_bar {
- self.paint_tab_bar(&mut layers).context("paint_tab_bar")?;
+ if self.show_tab_bar {
+ self.paint_tab_bar(&mut layers).context("paint_tab_bar")?;
+ }
}
self.paint_window_borders(&mut layers)
diff --git a/wezterm-gui/src/termwindow/render/pane.rs b/wezterm-gui/src/termwindow/render/pane.rs
index 47cf7be7..5a3bf7fa 100644
--- a/wezterm-gui/src/termwindow/render/pane.rs
+++ b/wezterm-gui/src/termwindow/render/pane.rs
@@ -1622,6 +1622,7 @@ impl crate::TermWindow {
font_identity: self.font_identity,
shape_key: Some(shape_key),
password_input,
+ allow_images: true,
},
&mut TripleLayerQuadAllocator::Heap(&mut buf),
)
diff --git a/wezterm-gui/src/termwindow/render/screen_line.rs b/wezterm-gui/src/termwindow/render/screen_line.rs
index 8221ee5d..eecc9941 100644
--- a/wezterm-gui/src/termwindow/render/screen_line.rs
+++ b/wezterm-gui/src/termwindow/render/screen_line.rs
@@ -440,7 +440,11 @@ impl crate::TermWindow {
for item in shaped.iter() {
let cluster = &item.cluster;
let glyph_info = &item.glyph_info;
- let images = cluster.attrs.images().unwrap_or_else(|| vec![]);
+ let images = if params.allow_images {
+ cluster.attrs.images().unwrap_or_else(|| vec![])
+ } else {
+ vec![]
+ };
let valign_adjust = match cluster.attrs.vertical_align() {
termwiz::cell::VerticalAlign::BaseLine => 0.,
termwiz::cell::VerticalAlign::SuperScript => {
diff --git a/wezterm-gui/src/termwindow/render/tab_bar.rs b/wezterm-gui/src/termwindow/render/tab_bar.rs
index eab6dda7..9ebb7014 100644
--- a/wezterm-gui/src/termwindow/render/tab_bar.rs
+++ b/wezterm-gui/src/termwindow/render/tab_bar.rs
@@ -147,6 +147,7 @@ impl crate::TermWindow {
font_identity: self.fonts.get_font_scale().to_bits(),
shape_key: None,
password_input: false,
+ allow_images: true,
},
layers,
)?;
diff --git a/wezterm-gui/src/termwindow/resize.rs b/wezterm-gui/src/termwindow/resize.rs
index 860f1f1b..3b860f35 100644
--- a/wezterm-gui/src/termwindow/resize.rs
+++ b/wezterm-gui/src/termwindow/resize.rs
@@ -2098,9 +2098,15 @@ impl super::TermWindow {
log::trace!("new dimensions are zero: NOP!");
return;
}
+ let content_view_resize_state_changed = self
+ .active_content_view_mut()
+ .is_some_and(|view| view.set_live_resizing(live_resizing));
if self.dimensions == dimensions && self.window_state == window_state {
// It didn't really change
log::trace!("dimensions didn't change NOP!");
+ if content_view_resize_state_changed {
+ window.invalidate();
+ }
return;
}
super::gpu_debug(format!(
@@ -2244,6 +2250,7 @@ impl super::TermWindow {
self.terminal_size = size;
if terminal_size_changed {
if self.content_view_foreground() {
+ self.content_view_deferred_mux_resize = true;
log::trace!("content view foreground; deferring mux tab resize");
} else {
self.resize_mux_tabs_to_current_terminal_size();
diff --git a/wezterm-gui/src/termwindow/ui/icons.rs b/wezterm-gui/src/termwindow/ui/icons.rs
index fc2df3ea..65a78595 100644
--- a/wezterm-gui/src/termwindow/ui/icons.rs
+++ b/wezterm-gui/src/termwindow/ui/icons.rs
@@ -28,6 +28,7 @@ pub enum SvgIcon {
FolderPlus,
FolderTree,
Globe,
+ Grid2x2,
House,
Info,
Keyboard,
@@ -129,6 +130,7 @@ impl SvgIcon {
include_bytes!("../../../../third_party/lucide/icons/folder-tree.svg")
}
Self::Globe => include_bytes!("../../../../third_party/lucide/icons/globe.svg"),
+ Self::Grid2x2 => include_bytes!("../../../../third_party/lucide/icons/grid-2x2.svg"),
Self::House => include_bytes!("../../../../third_party/lucide/icons/house.svg"),
Self::Info => include_bytes!("../../../../third_party/lucide/icons/info.svg"),
Self::Keyboard => include_bytes!("../../../../third_party/lucide/icons/keyboard.svg"),
diff --git a/wezterm-gui/src/termwindow/ui/platform_chrome.rs b/wezterm-gui/src/termwindow/ui/platform_chrome.rs
index 53a3a386..dca1d168 100644
--- a/wezterm-gui/src/termwindow/ui/platform_chrome.rs
+++ b/wezterm-gui/src/termwindow/ui/platform_chrome.rs
@@ -78,6 +78,19 @@ pub fn uses_integrated_window_buttons(
&& !window_state.contains(WindowState::SERVER_DECORATED)
}
+/// A full-window content view hides ThinkTerm's tab strip, but still needs a
+/// top client-chrome row when native controls share the client surface or when
+/// ThinkTerm owns the window buttons. Server-decorated and fullscreen windows
+/// already provide (or intentionally hide) that chrome elsewhere.
+pub fn full_window_needs_client_chrome(
+ decorations: WindowDecorations,
+ window_state: WindowState,
+ native_macos_surface: bool,
+) -> bool {
+ !window_state.contains(WindowState::FULL_SCREEN)
+ && (native_macos_surface || uses_integrated_window_buttons(decorations, window_state))
+}
+
impl WindowTabChromeParams {
fn px(self, value: usize) -> usize {
scale_ui_usize(value, self.dpi)
@@ -229,6 +242,31 @@ mod tests {
));
}
+ #[test]
+ fn full_window_client_chrome_matches_platform_ownership() {
+ let integrated = WindowDecorations::INTEGRATED_BUTTONS | WindowDecorations::RESIZE;
+ assert!(full_window_needs_client_chrome(
+ integrated,
+ WindowState::default(),
+ false
+ ));
+ assert!(!full_window_needs_client_chrome(
+ integrated,
+ WindowState::SERVER_DECORATED,
+ false
+ ));
+ assert!(!full_window_needs_client_chrome(
+ integrated,
+ WindowState::FULL_SCREEN,
+ false
+ ));
+ assert!(full_window_needs_client_chrome(
+ WindowDecorations::RESIZE,
+ WindowState::default(),
+ true
+ ));
+ }
+
fn test_params(
workspace_sidebar_width: usize,
window_state: WindowState,
diff --git a/wezterm-gui/src/termwindow/ui/sidebar.rs b/wezterm-gui/src/termwindow/ui/sidebar.rs
index ceca52d1..9333796f 100644
--- a/wezterm-gui/src/termwindow/ui/sidebar.rs
+++ b/wezterm-gui/src/termwindow/ui/sidebar.rs
@@ -2305,17 +2305,27 @@ impl crate::TermWindow {
.saturating_add(settings_row_width)
.saturating_sub(settings_action_size);
let settings_action_y = settings_row_y;
- // SSH hosts (link-2) button sits just left of the view-options button.
+ // SSH hosts sits left of view options; Live Overview sits left of
+ // SSH so the settings label remains the primary footer action.
let ssh_action_x = settings_action_x
.saturating_sub(settings_action_size + self.ui_px(SIDEBAR_INSET) / 2);
let ssh_action_y = settings_row_y;
+ let overview_action_x =
+ ssh_action_x.saturating_sub(settings_action_size + self.ui_px(SIDEBAR_INSET) / 2);
+ let overview_action_y = settings_row_y;
let ssh_action_hovered = self.is_pointer_over_ui_rect(
ssh_action_x,
ssh_action_y,
settings_action_size,
settings_action_size,
);
- let settings_body_width = ssh_action_x
+ let overview_action_hovered = self.is_pointer_over_ui_rect(
+ overview_action_x,
+ overview_action_y,
+ settings_action_size,
+ settings_action_size,
+ );
+ let settings_body_width = overview_action_x
.saturating_sub(settings_row_x)
.saturating_sub(self.ui_px(SIDEBAR_INSET) / 2);
let settings_hovered = self.is_pointer_over_ui_rect(
@@ -2411,6 +2421,45 @@ impl crate::TermWindow {
},
)?;
}
+ if overview_action_hovered {
+ self.fill_rounded_rectangle(
+ layers,
+ 2,
+ euclid::rect(
+ overview_action_x as f32,
+ overview_action_y as f32,
+ settings_action_size as f32,
+ settings_action_size as f32,
+ ),
+ chrome.sidebar_button_hover_bg,
+ self.ui_f32(SIDEBAR_ROW_RADIUS + 4.0),
+ )
+ .context("sidebar live overview hover")?;
+ }
+ self.ui_items.push(UIItem {
+ x: overview_action_x,
+ y: overview_action_y,
+ width: settings_action_size,
+ height: settings_action_size,
+ item_type: UIItemType::WorkspaceSidebarLiveOverview,
+ });
+ {
+ let overview_icon_size = icon_size.min(settings_row_height.saturating_sub(8));
+ self.paint_sidebar_icon(
+ layers,
+ SvgIcon::Grid2x2,
+ overview_action_x
+ + ((settings_action_size.saturating_sub(overview_icon_size)) / 2),
+ overview_action_y
+ + ((settings_action_size.saturating_sub(overview_icon_size)) / 2),
+ overview_icon_size,
+ if overview_action_hovered {
+ foreground
+ } else {
+ muted_fg
+ },
+ )?;
+ }
let settings_icon_size = icon_size.min(settings_row_height.saturating_sub(8));
let settings_icon_x = settings_row_x + self.ui_px(SIDEBAR_SETTINGS_ICON_EXTRA_INSET);
let settings_icon_y =
@@ -2434,7 +2483,9 @@ impl crate::TermWindow {
&crate::i18n::tr("sidebar-settings"),
settings_text_x,
settings_text_y,
- settings_action_x.saturating_sub(settings_text_x + self.ui_px(SIDEBAR_INSET)),
+ settings_body_width
+ .saturating_sub(settings_text_x.saturating_sub(settings_row_x))
+ .saturating_sub(self.ui_px(SIDEBAR_INSET)),
foreground,
)?;
let settings_action_icon_size = settings_icon_size;
diff --git a/wezterm-gui/src/ui/draw.rs b/wezterm-gui/src/ui/draw.rs
index 2a924faf..a4b0e542 100644
--- a/wezterm-gui/src/ui/draw.rs
+++ b/wezterm-gui/src/ui/draw.rs
@@ -9,11 +9,16 @@
//! becomes the borrowed `self.render_state` field.
use crate::customglyph::{BlockKey, Poly};
-use crate::quad::{QuadTrait, TripleLayerQuadAllocator, TripleLayerQuadAllocatorTrait};
+use crate::quad::{
+ HeapQuadAllocator, QuadTrait, TripleLayerQuadAllocator, TripleLayerQuadAllocatorTrait,
+};
use crate::renderstate::RenderState;
use crate::termwindow::render::corners::{
- BOTTOM_LEFT_ROUNDED_CORNER, BOTTOM_RIGHT_ROUNDED_CORNER, TOP_LEFT_ROUNDED_CORNER,
- TOP_RIGHT_ROUNDED_CORNER,
+ BOTTOM_LEFT_ROUNDED_CORNER, BOTTOM_LEFT_ROUNDED_CORNER_MASK,
+ BOTTOM_LEFT_ROUNDED_CORNER_OUTLINE, BOTTOM_RIGHT_ROUNDED_CORNER,
+ BOTTOM_RIGHT_ROUNDED_CORNER_MASK, BOTTOM_RIGHT_ROUNDED_CORNER_OUTLINE, TOP_LEFT_ROUNDED_CORNER,
+ TOP_LEFT_ROUNDED_CORNER_MASK, TOP_LEFT_ROUNDED_CORNER_OUTLINE, TOP_RIGHT_ROUNDED_CORNER,
+ TOP_RIGHT_ROUNDED_CORNER_MASK, TOP_RIGHT_ROUNDED_CORNER_OUTLINE,
};
use crate::termwindow::ui::icons::{BrandIcon, SvgIcon};
use crate::utilsprites::RenderMetrics;
@@ -21,7 +26,7 @@ use std::rc::Rc;
use wezterm_bidi::Direction;
use wezterm_font::LoadedFont;
use window::color::LinearRgba;
-use window::Dimensions;
+use window::{Dimensions, RectF};
/// Borrowed handles needed by every primitive. Cheap to build each frame.
pub(crate) struct DrawContext<'a> {
@@ -86,6 +91,225 @@ impl<'a> DrawContext<'a> {
Ok(())
}
+ /// Draw a true GPU-interpolated gradient using a single quad. This keeps
+ /// full-window native UI backgrounds smooth without uploading a texture or
+ /// exposing visible color bands on large displays.
+ pub(crate) fn draw_vertical_gradient(
+ &self,
+ layers: &mut TripleLayerQuadAllocator<'_>,
+ layer_num: usize,
+ area: RectF,
+ top: LinearRgba,
+ bottom: LinearRgba,
+ ) -> anyhow::Result<()> {
+ if area.size.width <= 0.0 || area.size.height <= 0.0 {
+ return Ok(());
+ }
+
+ let mut quad = layers.allocate(layer_num)?;
+ let left_offset = self.dimensions.pixel_width as f32 / 2.0;
+ let top_offset = self.dimensions.pixel_height as f32 / 2.0;
+ quad.set_position(
+ area.origin.x - left_offset,
+ area.origin.y - top_offset,
+ area.max_x() - left_offset,
+ area.max_y() - top_offset,
+ );
+ quad.set_texture(self.render_state.util_sprites.filled_box.texture_coords());
+ quad.set_is_background();
+ quad.set_vertical_gradient(top, bottom);
+ quad.set_alt_color_and_mix_value(top, 0.0);
+ quad.set_hsv(None);
+ Ok(())
+ }
+
+ /// Draw a smoothly interpolated four-corner gradient with one GPU quad.
+ /// This is intended for restrained native surfaces where a flat vertical
+ /// blend is visually too uniform but a texture or blur would be wasteful.
+ pub(crate) fn draw_corner_gradient(
+ &self,
+ layers: &mut TripleLayerQuadAllocator<'_>,
+ layer_num: usize,
+ area: RectF,
+ top_left: LinearRgba,
+ top_right: LinearRgba,
+ bottom_left: LinearRgba,
+ bottom_right: LinearRgba,
+ ) -> anyhow::Result<()> {
+ if area.size.width <= 0.0 || area.size.height <= 0.0 {
+ return Ok(());
+ }
+
+ let mut quad = layers.allocate(layer_num)?;
+ let left_offset = self.dimensions.pixel_width as f32 / 2.0;
+ let top_offset = self.dimensions.pixel_height as f32 / 2.0;
+ quad.set_position(
+ area.origin.x - left_offset,
+ area.origin.y - top_offset,
+ area.max_x() - left_offset,
+ area.max_y() - top_offset,
+ );
+ quad.set_texture(self.render_state.util_sprites.filled_box.texture_coords());
+ quad.set_is_background();
+ quad.set_corner_gradient(top_left, top_right, bottom_left, bottom_right);
+ quad.set_alt_color_and_mix_value(top_left, 0.0);
+ quad.set_hsv(None);
+ Ok(())
+ }
+
+ /// Standard elevated surface used by overview cards. Two restrained
+ /// layers provide depth without a hard concentric halo.
+ pub(crate) fn draw_elevated_surface(
+ &self,
+ layers: &mut TripleLayerQuadAllocator<'_>,
+ layer_num: usize,
+ rect: RectF,
+ fill: LinearRgba,
+ border: LinearRgba,
+ shadow: LinearRgba,
+ radius: f32,
+ ) -> anyhow::Result<()> {
+ for (spread, offset_y, alpha) in [
+ (self.px(6.0), self.px(5.0), 0.14),
+ (self.px(2.0), self.px(3.0), 0.24),
+ ] {
+ self.draw_rounded_rect(
+ layers,
+ layer_num,
+ rect.origin.x - spread,
+ rect.origin.y - spread + offset_y,
+ rect.size.width + spread * 2.0,
+ rect.size.height + spread * 2.0,
+ color_with_alpha(shadow, shadow.3 * alpha),
+ radius + spread,
+ )?;
+ }
+ self.draw_rounded_frame(
+ layers,
+ layer_num,
+ rect.origin.x,
+ rect.origin.y,
+ rect.size.width,
+ rect.size.height,
+ fill,
+ border,
+ radius,
+ )
+ }
+
+ /// Cover the four wedges outside a rounded preview after the terminal has
+ /// been painted, then redraw its thin outline. The complete chrome is
+ /// emitted into a heap buffer and clipped as quads, so a corner crossing a
+ /// scroll boundary remains rounded instead of disappearing all at once.
+ pub(crate) fn draw_rounded_preview_chrome(
+ &self,
+ layers: &mut TripleLayerQuadAllocator<'_>,
+ layer_num: usize,
+ rect: RectF,
+ clip: RectF,
+ mask: LinearRgba,
+ border: LinearRgba,
+ radius: f32,
+ ) -> anyhow::Result<()> {
+ let radius = radius
+ .min(rect.size.width / 2.0)
+ .min(rect.size.height / 2.0)
+ .round()
+ .max(0.0);
+ if radius <= 0.0 {
+ return Ok(());
+ }
+ let size = euclid::size2(radius, radius);
+
+ let corners = [
+ (
+ rect.min_x(),
+ rect.min_y(),
+ TOP_LEFT_ROUNDED_CORNER_MASK,
+ TOP_LEFT_ROUNDED_CORNER_OUTLINE,
+ ),
+ (
+ rect.max_x() - radius,
+ rect.min_y(),
+ TOP_RIGHT_ROUNDED_CORNER_MASK,
+ TOP_RIGHT_ROUNDED_CORNER_OUTLINE,
+ ),
+ (
+ rect.min_x(),
+ rect.max_y() - radius,
+ BOTTOM_LEFT_ROUNDED_CORNER_MASK,
+ BOTTOM_LEFT_ROUNDED_CORNER_OUTLINE,
+ ),
+ (
+ rect.max_x() - radius,
+ rect.max_y() - radius,
+ BOTTOM_RIGHT_ROUNDED_CORNER_MASK,
+ BOTTOM_RIGHT_ROUNDED_CORNER_OUTLINE,
+ ),
+ ];
+ let mut heap = HeapQuadAllocator::default();
+ {
+ let mut clipped_layers = TripleLayerQuadAllocator::Heap(&mut heap);
+ for (x, y, mask_poly, outline_poly) in corners {
+ self.draw_corner(&mut clipped_layers, layer_num, x, y, mask_poly, size, mask)?;
+ self.draw_corner(
+ &mut clipped_layers,
+ layer_num,
+ x,
+ y,
+ outline_poly,
+ size,
+ border,
+ )?;
+ }
+
+ let stroke = self.px(1.0).max(1.0);
+ let edges: [RectF; 4] = [
+ euclid::rect(
+ rect.min_x() + radius,
+ rect.min_y(),
+ rect.size.width - radius * 2.0,
+ stroke,
+ ),
+ euclid::rect(
+ rect.min_x() + radius,
+ rect.max_y() - stroke,
+ rect.size.width - radius * 2.0,
+ stroke,
+ ),
+ euclid::rect(
+ rect.min_x(),
+ rect.min_y() + radius,
+ stroke,
+ rect.size.height - radius * 2.0,
+ ),
+ euclid::rect(
+ rect.max_x() - stroke,
+ rect.min_y() + radius,
+ stroke,
+ rect.size.height - radius * 2.0,
+ ),
+ ];
+ for edge in edges {
+ self.draw_rect(
+ &mut clipped_layers,
+ layer_num,
+ edge.origin.x,
+ edge.origin.y,
+ edge.size.width,
+ edge.size.height,
+ border,
+ )?;
+ }
+ }
+ heap.apply_to_clipped(
+ layers,
+ clip,
+ self.dimensions.pixel_width as f32,
+ self.dimensions.pixel_height as f32,
+ )
+ }
+
pub(crate) fn draw_rounded_rect(
&self,
layers: &mut TripleLayerQuadAllocator<'_>,
@@ -461,3 +685,7 @@ impl<'a> DrawContext<'a> {
format!("{}{}", text[..boundaries[best]].trim_end(), ellipsis)
}
}
+
+fn color_with_alpha(color: LinearRgba, alpha: f32) -> LinearRgba {
+ LinearRgba(color.0, color.1, color.2, alpha.clamp(0.0, 1.0))
+}
diff --git a/wezterm-gui/src/ui/widgets.rs b/wezterm-gui/src/ui/widgets.rs
index 4913bf34..1e64b0aa 100644
--- a/wezterm-gui/src/ui/widgets.rs
+++ b/wezterm-gui/src/ui/widgets.rs
@@ -63,12 +63,43 @@ pub(crate) fn draw_button<A: Copy + PartialEq>(
widgets: &mut UiContext<A>,
palette: UiPalette,
spec: ButtonSpec<A>,
+) -> anyhow::Result<()> {
+ draw_button_with_layers(ctx, layers, font, widgets, palette, spec, 0, 1)
+}
+
+/// Draw the complete button on a single explicit layer. Full-window views use
+/// this for confirmation controls that must sit above embedded terminal glyphs
+/// while retaining the same shared geometry and interaction styling.
+pub(crate) fn draw_button_on_layer<A: Copy + PartialEq>(
+ ctx: &DrawContext,
+ layers: &mut TripleLayerQuadAllocator<'_>,
+ font: &Rc<LoadedFont>,
+ widgets: &mut UiContext<A>,
+ palette: UiPalette,
+ spec: ButtonSpec<A>,
+ layer_num: usize,
+) -> anyhow::Result<()> {
+ draw_button_with_layers(
+ ctx, layers, font, widgets, palette, spec, layer_num, layer_num,
+ )
+}
+
+#[allow(clippy::too_many_arguments)]
+fn draw_button_with_layers<A: Copy + PartialEq>(
+ ctx: &DrawContext,
+ layers: &mut TripleLayerQuadAllocator<'_>,
+ font: &Rc<LoadedFont>,
+ widgets: &mut UiContext<A>,
+ palette: UiPalette,
+ spec: ButtonSpec<A>,
+ background_layer: usize,
+ text_layer: usize,
) -> anyhow::Result<()> {
widgets.push(spec.rect, spec.kind, spec.action);
let (background, border) = spec.state.colors(palette);
ctx.draw_rounded_frame(
layers,
- 0,
+ background_layer,
spec.rect.origin.x,
spec.rect.origin.y,
spec.rect.size.width,
@@ -77,8 +108,9 @@ pub(crate) fn draw_button<A: Copy + PartialEq>(
border,
ctx.px(BUTTON_RADIUS),
)?;
- ctx.draw_text(
+ ctx.draw_text_on_layer(
layers,
+ text_layer,
font,
spec.rect.origin.x + ctx.px(BUTTON_TEXT_PAD),
control_text_y(ctx, spec.rect.origin.y, spec.rect.size.height),
@@ -102,6 +134,39 @@ pub(crate) fn draw_icon_button<A: Copy + PartialEq>(
size: f32,
icon: SvgIcon,
action: A,
+) -> anyhow::Result<()> {
+ draw_icon_button_on_layer(
+ ctx,
+ layers,
+ widgets,
+ interaction,
+ palette,
+ x,
+ y,
+ size,
+ icon,
+ action,
+ 0,
+ )
+}
+
+/// The standard icon button with its optional hover/press surface placed on a
+/// caller-selected layer. This is useful for fixed chrome that must be redrawn
+/// above a scrolling-content mask while retaining the shared sizing, padding,
+/// colors and hit target.
+#[allow(clippy::too_many_arguments)]
+pub(crate) fn draw_icon_button_on_layer<A: Copy + PartialEq>(
+ ctx: &DrawContext,
+ layers: &mut TripleLayerQuadAllocator<'_>,
+ widgets: &mut UiContext<A>,
+ interaction: &InteractionState<A>,
+ palette: UiPalette,
+ x: f32,
+ y: f32,
+ size: f32,
+ icon: SvgIcon,
+ action: A,
+ background_layer: usize,
) -> anyhow::Result<()> {
let rect = RectF::new(euclid::point2(x, y), euclid::size2(size, size));
widgets.push(rect, WidgetKind::Button, action);
@@ -115,7 +180,16 @@ pub(crate) fn draw_icon_button<A: Copy + PartialEq>(
LinearRgba::TRANSPARENT
};
if bg.3 > 0.0 {
- ctx.draw_rounded_rect(layers, 0, x, y, size, size, bg, ctx.px(ICON_BUTTON_RADIUS))?;
+ ctx.draw_rounded_rect(
+ layers,
+ background_layer,
+ x,
+ y,
+ size,
+ size,
+ bg,
+ ctx.px(ICON_BUTTON_RADIUS),
+ )?;
}
// cell_size already tracks the window DPI, so only the padding and the
// clamp bounds need converting from design pixels.
@@ -365,6 +439,21 @@ pub(crate) fn draw_scrollbar(
tokens: UiTokens,
area: RectF,
scroll: ScrollState,
+) -> anyhow::Result<()> {
+ draw_scrollbar_on_layer(ctx, layers, palette, tokens, area, scroll, 0)
+}
+
+/// Draw the shared scrollbar thumb on a caller-selected layer. Scrollable
+/// full-window views use this after their viewport masks so the thumb remains
+/// crisp at the outer window edge.
+pub(crate) fn draw_scrollbar_on_layer(
+ ctx: &DrawContext,
+ layers: &mut TripleLayerQuadAllocator<'_>,
+ palette: UiPalette,
+ tokens: UiTokens,
+ area: RectF,
+ scroll: ScrollState,
+ layer_num: usize,
) -> anyhow::Result<()> {
let spec = ScrollbarSpec::from_area(area, tokens);
if let Some((thumb_y, thumb_h)) =
@@ -372,7 +461,7 @@ pub(crate) fn draw_scrollbar(
{
ctx.draw_rounded_rect(
layers,
- 0,
+ layer_num,
spec.x,
thumb_y,
spec.width,
diff --git a/wezterm-gui/src/workspace_threads.rs b/wezterm-gui/src/workspace_threads.rs
index 2a6be7c5..b084ca6e 100644
--- a/wezterm-gui/src/workspace_threads.rs
+++ b/wezterm-gui/src/workspace_threads.rs
@@ -681,6 +681,19 @@ pub fn release_window_space(owner_id: u64) {
WINDOW_SPACES.lock().remove(&owner_id);
}
+fn window_owner_for_space_in(assignments: &HashMap<u64, SpaceId>, space_id: &str) -> Option<u64> {
+ assignments
+ .iter()
+ .find_map(|(owner_id, active_space)| (active_space == space_id).then_some(*owner_id))
+}
+
+/// Return the native-window owner currently displaying `space_id`, if any.
+/// Space ownership remains exclusive; this is a read-only lookup used by
+/// global UI such as Live Overview to focus the window that already owns it.
+pub fn window_owner_for_space(space_id: &str) -> Option<u64> {
+ window_owner_for_space_in(&WINDOW_SPACES.lock(), space_id)
+}
+
pub fn switch_window_space(owner_id: u64, space_id: &str) -> bool {
if WINDOW_SPACES
.lock()
@@ -2113,6 +2126,26 @@ pub fn ordered_project_ids(space_id: &str) -> Vec<ProjectId> {
.collect()
}
+/// Every thread in a project in its persisted render order. Unlike
+/// [`unpinned_thread_ids`], this includes pinned threads because global views
+/// such as Live Overview group by Space/Project rather than duplicating the
+/// sidebar's pinned section.
+pub fn ordered_thread_ids(project_id: &str) -> Vec<WorkspaceThreadId> {
+ let store = THREAD_STORE.lock();
+ store
+ .projects
+ .iter()
+ .find(|project| project.id == project_id)
+ .map(|project| {
+ project
+ .threads
+ .iter()
+ .map(|session| session.id.clone())
+ .collect()
+ })
+ .unwrap_or_default()
+}
+
/// The thread ids a project shows under its own row, in render order —
/// pinned threads live in the sidebar's separate top section.
pub fn unpinned_thread_ids(project_id: &str) -> Vec<WorkspaceThreadId> {
@@ -6344,6 +6377,15 @@ fn now_ts() -> i64 {
#[cfg(test)]
mod tests {
use super::*;
+
+ #[test]
+ fn window_owner_lookup_tracks_claims_without_changing_them() {
+ let assignments = HashMap::from([(11, "space-a".to_string()), (22, "space-b".to_string())]);
+ assert_eq!(window_owner_for_space_in(&assignments, "space-a"), Some(11));
+ assert_eq!(window_owner_for_space_in(&assignments, "space-b"), Some(22));
+ assert_eq!(window_owner_for_space_in(&assignments, "space-c"), None);
+ assert_eq!(assignments.len(), 2);
+ }
use tempfile::tempdir;
fn test_store() -> WorkspaceThreadStore {