A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.
Rust agentagent-orchestrationaiai-agentsclaude-codecodexcoding-agentlinuxmacosmultiplayermultiplexerrustterminalterminal-emulatorterminal-multiplexertmuxtuiweztermwindows
Add developer mode, memory diagnostics, and UI tweaks
RoversX96a84ece3241
diff --git a/wezterm-gui/src/glyphcache.rs b/wezterm-gui/src/glyphcache.rsindex 7538462e..7542910a 100644--- a/wezterm-gui/src/glyphcache.rs+++ b/wezterm-gui/src/glyphcache.rs@@ -78,6 +78,13 @@ pub struct SizedSvgIconKey {pub size: u16,}+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]+pub struct SizedRotatedSvgIconKey {+ pub icon: SvgIcon,+ pub size: u16,+ pub frame: u8,+}+#[derive(Debug, Clone, PartialEq, Eq, Hash)]pub struct GlyphKey {pub font_idx: usize,@@ -575,6 +582,7 @@ pub struct GlyphCache {pub svg_icons: HashMap<SizedSvgIconKey, Sprite>,pub cursor_glyphs: HashMap<(Option<CursorShape>, u8), Sprite>,pub color: HashMap<(RgbColor, NotNan<f32>), Sprite>,+ pub rotated_svg_icons: HashMap<SizedRotatedSvgIconKey, Sprite>,min_frame_duration: Duration,}@@ -597,6 +605,7 @@ impl GlyphCache {line_glyphs: HashMap::new(),block_glyphs: HashMap::new(),svg_icons: HashMap::new(),+ rotated_svg_icons: HashMap::new(),cursor_glyphs: HashMap::new(),color: HashMap::new(),min_frame_duration: Duration::from_millis(1000 / fonts.config().max_fps as u64),@@ -627,6 +636,7 @@ impl GlyphCache {line_glyphs: HashMap::new(),block_glyphs: HashMap::new(),svg_icons: HashMap::new(),+ rotated_svg_icons: HashMap::new(),cursor_glyphs: HashMap::new(),color: HashMap::new(),min_frame_duration: Duration::from_millis(1000 / fonts.config().max_fps as u64),@@ -1161,6 +1171,33 @@ impl GlyphCache {Ok(sprite)}+ pub fn cached_rotated_svg_icon(+ &mut self,+ icon: SvgIcon,+ size: usize,+ frame: u8,+ frame_count: u8,+ ) -> anyhow::Result<Sprite> {+ let size = size.max(1).min(u16::MAX as usize);+ let frame_count = frame_count.max(1);+ let frame = frame % frame_count;+ let key = SizedRotatedSvgIconKey {+ icon,+ size: size as u16,+ frame,+ };++ if let Some(sprite) = self.rotated_svg_icons.get(&key) {+ return Ok(sprite.clone());+ }++ let degrees = 360.0 * frame as f32 / frame_count as f32;+ let image = icon.rasterize_with_rotation(size, degrees)?;+ let sprite = self.atlas.allocate(&image)?;+ self.rotated_svg_icons.insert(key, sprite.clone());+ Ok(sprite)+ }+pub fn cached_block(&mut self,block: BlockKey,diff --git a/wezterm-gui/src/native_settings.rs b/wezterm-gui/src/native_settings.rsindex 511c4b73..4552acbd 100644--- a/wezterm-gui/src/native_settings.rs+++ b/wezterm-gui/src/native_settings.rs@@ -69,10 +69,31 @@ pub(crate) struct NativeChromeSettings {pub(crate) settings_font_size: Option<f64>,pub(crate) settings_font_weight: Option<u16>,pub(crate) sidebar_font_size: Option<f64>,+ pub(crate) workspace_sidebar_width: Option<usize>,pub(crate) tab_font_size: Option<f64>,pub(crate) pane_header_font_size: Option<f64>,}+#[derive(Debug, Clone, Default, Deserialize, Serialize)]+#[serde(default)]+pub(crate) struct NativeDeveloperSettings {+ pub(crate) developer_mode: bool,+}++#[derive(Debug, Clone, Deserialize, Serialize)]+#[serde(default)]+pub(crate) struct NativeWindowSettings {+ pub(crate) restore_main_window_frame: bool,+}++impl Default for NativeWindowSettings {+ fn default() -> Self {+ Self {+ restore_main_window_frame: true,+ }+ }+}+#[derive(Debug, Clone, Deserialize, Serialize)]#[serde(default)]pub(crate) struct ThinkTermNativeSettings {@@ -80,6 +101,8 @@ pub(crate) struct ThinkTermNativeSettings {pub(crate) appearance: NativeAppearanceSettings,pub(crate) terminal: NativeTerminalSettings,pub(crate) chrome: NativeChromeSettings,+ pub(crate) developer: NativeDeveloperSettings,+ pub(crate) window: NativeWindowSettings,}impl Default for ThinkTermNativeSettings {@@ -89,6 +112,8 @@ impl Default for ThinkTermNativeSettings {appearance: NativeAppearanceSettings::default(),terminal: NativeTerminalSettings::default(),chrome: NativeChromeSettings::default(),+ developer: NativeDeveloperSettings::default(),+ window: NativeWindowSettings::default(),}}}@@ -180,6 +205,16 @@ pub(crate) fn sidebar_font_size() -> f64 {.clamp(10.0, 28.0)}+pub(crate) fn workspace_sidebar_width() -> Option<usize> {+ load().chrome.workspace_sidebar_width+}++pub(crate) fn save_workspace_sidebar_width(width: usize) -> anyhow::Result<()> {+ let mut settings = load();+ settings.chrome.workspace_sidebar_width = Some(width);+ save(&settings)+}+pub(crate) fn tab_font_size() -> f64 {load().chromediff --git a/wezterm-gui/src/project_sessions.rs b/wezterm-gui/src/project_sessions.rsindex 026ad6c6..dc06dfec 100644--- a/wezterm-gui/src/project_sessions.rs+++ b/wezterm-gui/src/project_sessions.rs@@ -532,7 +532,10 @@ impl SessionStore {project,Some(active_project_id),live_workspaces,- ),+ )+ .into_iter()+ .filter(|session| !session.is_pinned)+ .collect(),}).collect();ProjectSessionView {diff --git a/wezterm-gui/src/settings_window.rs b/wezterm-gui/src/settings_window.rsindex 281c2691..dd643a17 100644--- a/wezterm-gui/src/settings_window.rs+++ b/wezterm-gui/src/settings_window.rs@@ -18,7 +18,7 @@ use config::{configuration, Dimension, GeometryOrigin};use std::cell::RefCell;use std::path::PathBuf;use std::rc::Rc;-use std::time::Instant;+use std::time::{Duration, Instant};use wezterm_bidi::Direction;use wezterm_font::{FontConfiguration, LoadedFont};use window::bitmaps::atlas::OutOfTextureSpace;@@ -64,10 +64,12 @@ enum SettingsSection {Keymap,Compatibility,Developer,+ UiKit,+ Memory,About,}-const SECTIONS: &[SettingsSection] = &[+const BASE_SECTIONS: &[SettingsSection] = &[SettingsSection::General,SettingsSection::Appearance,SettingsSection::Terminal,@@ -78,6 +80,8 @@ const SECTIONS: &[SettingsSection] = &[SettingsSection::About,];+const DEVELOPER_SECTIONS: &[SettingsSection] = &[SettingsSection::UiKit, SettingsSection::Memory];+impl SettingsSection {fn label(self) -> &'static str {match self {@@ -88,6 +92,8 @@ impl SettingsSection {Self::Keymap => "Keymap",Self::Compatibility => "Compatibility",Self::Developer => "Developer",+ Self::UiKit => "UI Kit",+ Self::Memory => "Memory",Self::About => "About",}}@@ -101,6 +107,8 @@ impl SettingsSection {Self::Keymap => SettingsIcon::Keymap,Self::Compatibility => SettingsIcon::Sync,Self::Developer => SettingsIcon::Developer,+ Self::UiKit => SettingsIcon::UiKit,+ Self::Memory => SettingsIcon::Memory,Self::About => SettingsIcon::About,}}@@ -112,6 +120,9 @@ impl SettingsSection {"ThinkTerm Native Settings","Theme Mode","Native Settings",+ "Restore Main Window Frame",+ "Window Size",+ "Window Position","Configuration",],Self::Appearance => &[@@ -146,6 +157,13 @@ impl SettingsSection {"Import",],Self::Developer => &[+ "Developer Mode",+ "Diagnostics",+ "Debug Pages",+ "Memory Diagnostics",+ "UI Kit",+ ],+ Self::UiKit => &["Search Field","Sidebar Rows","Buttons and Controls",@@ -156,6 +174,19 @@ impl SettingsSection {"Component Preview","Component Styles",],+ Self::Memory => &[+ "Memory",+ "Diagnostics",+ "Manual Sampling",+ "Copy",+ "Refresh",+ "Physical Footprint",+ "RSS",+ "vmmap",+ "IOAccelerator",+ "IOSurface",+ "Graphics",+ ],Self::About => &["About", "Version", "ThinkTerm"],}}@@ -166,6 +197,11 @@ enum SettingsAction {Select(SettingsSection),OpenConfigFile,ShowCompatibilityStatus,+ ToggleMainWindowFrameRestore,+ ToggleDeveloperMode,+ ToggleMemoryMonitoring,+ RefreshMemorySnapshot,+ CopyMemorySnapshot,ToggleThemeModeMenu,SetThemeMode(NativeThemeMode),SearchInput,@@ -195,6 +231,67 @@ enum SettingsDropdown {ThemeMode,}+#[derive(Debug, Clone)]+struct MemorySnapshot {+ captured_at: Instant,+ pid: u32,+ resident_size: Option<u64>,+ physical_footprint: Option<u64>,+ peak_physical_footprint: Option<u64>,+ error: Option<String>,+}++impl MemorySnapshot {+ fn log_line(&self) -> String {+ format!(+ "pid={} rss={} physical_footprint={} peak_physical_footprint={}{}",+ self.pid,+ self.resident_size+ .map(format_bytes)+ .unwrap_or_else(|| "unavailable".to_string()),+ self.physical_footprint+ .map(format_bytes)+ .unwrap_or_else(|| "unavailable".to_string()),+ self.peak_physical_footprint+ .map(format_bytes)+ .unwrap_or_else(|| "unavailable".to_string()),+ self.error+ .as_ref()+ .map(|error| format!(" error={error}"))+ .unwrap_or_default()+ )+ }++ fn summary_for_clipboard(&self) -> String {+ let mut lines = vec![+ "ThinkTerm Memory Snapshot".to_string(),+ format!("pid: {}", self.pid),+ format!(+ "rss: {}",+ self.resident_size+ .map(format_bytes)+ .unwrap_or_else(|| "unavailable".to_string())+ ),+ format!(+ "physical_footprint: {}",+ self.physical_footprint+ .map(format_bytes)+ .unwrap_or_else(|| "unavailable".to_string())+ ),+ format!(+ "peak_physical_footprint: {}",+ self.peak_physical_footprint+ .map(format_bytes)+ .unwrap_or_else(|| "unavailable".to_string())+ ),+ ];+ if let Some(error) = &self.error {+ lines.push(format!("error: {error}"));+ }+ lines.join("\n")+ }+}+#[derive(Debug, Clone, Copy, PartialEq, Eq)]enum ChromeFontArea {Settings,@@ -244,6 +341,10 @@ struct SettingsUiState {interaction: InteractionState<SettingsAction>,drag: Option<SettingsDrag>,open_dropdown: Option<SettingsDropdown>,+ memory_monitoring: bool,+ memory_monitor_generation: u64,+ memory_snapshot: Option<MemorySnapshot>,+ memory_snapshot_copied_until: Option<Instant>,sidebar_scrollbar_visible_until: Option<Instant>,content_scrollbar_visible_until: Option<Instant>,}@@ -266,12 +367,133 @@ impl SettingsUiState {interaction: InteractionState::default(),drag: None,open_dropdown: None,+ memory_monitoring: false,+ memory_monitor_generation: 0,+ memory_snapshot: None,+ memory_snapshot_copied_until: None,sidebar_scrollbar_visible_until: None,content_scrollbar_visible_until: None,}}}+fn format_bytes(bytes: u64) -> String {+ let mib = bytes as f64 / 1024.0 / 1024.0;+ if mib >= 1024.0 {+ format!("{:.2} GB", mib / 1024.0)+ } else {+ format!("{mib:.1} MB")+ }+}++fn capture_memory_snapshot() -> MemorySnapshot {+ let pid = std::process::id();+ let mut snapshot = MemorySnapshot {+ captured_at: Instant::now(),+ pid,+ resident_size: None,+ physical_footprint: None,+ peak_physical_footprint: None,+ error: None,+ };++ match capture_process_memory_info(pid) {+ Ok(info) => {+ snapshot.resident_size = Some(info.resident_size);+ snapshot.physical_footprint = Some(info.physical_footprint);+ snapshot.peak_physical_footprint = Some(info.peak_physical_footprint);+ }+ Err(err) => {+ snapshot.error = Some(err);+ }+ }++ snapshot+}++#[derive(Debug, Clone, Copy)]+struct ProcessMemoryInfo {+ resident_size: u64,+ physical_footprint: u64,+ peak_physical_footprint: u64,+}++#[cfg(target_os = "macos")]+fn capture_process_memory_info(pid: u32) -> Result<ProcessMemoryInfo, String> {+ const RUSAGE_INFO_V4: libc::c_int = 4;++ #[repr(C)]+ #[derive(Clone, Copy)]+ struct RUsageInfoV4 {+ ri_uuid: [u8; 16],+ ri_user_time: u64,+ ri_system_time: u64,+ ri_pkg_idle_wkups: u64,+ ri_interrupt_wkups: u64,+ ri_pageins: u64,+ ri_wired_size: u64,+ ri_resident_size: u64,+ ri_phys_footprint: u64,+ ri_proc_start_abstime: u64,+ ri_proc_exit_abstime: u64,+ ri_child_user_time: u64,+ ri_child_system_time: u64,+ ri_child_pkg_idle_wkups: u64,+ ri_child_interrupt_wkups: u64,+ ri_child_pageins: u64,+ ri_child_elapsed_abstime: u64,+ ri_diskio_bytesread: u64,+ ri_diskio_byteswritten: u64,+ ri_cpu_time_qos_default: u64,+ ri_cpu_time_qos_maintenance: u64,+ ri_cpu_time_qos_background: u64,+ ri_cpu_time_qos_utility: u64,+ ri_cpu_time_qos_legacy: u64,+ ri_cpu_time_qos_user_initiated: u64,+ ri_cpu_time_qos_user_interactive: u64,+ ri_billed_system_time: u64,+ ri_serviced_system_time: u64,+ ri_logical_writes: u64,+ ri_lifetime_max_phys_footprint: u64,+ ri_instructions: u64,+ ri_cycles: u64,+ ri_billed_energy: u64,+ ri_serviced_energy: u64,+ }++ unsafe extern "C" {+ fn proc_pid_rusage(+ pid: libc::c_int,+ flavor: libc::c_int,+ buffer: *mut libc::c_void,+ ) -> libc::c_int;+ }++ let mut info = std::mem::MaybeUninit::<RUsageInfoV4>::zeroed();+ let result = unsafe {+ proc_pid_rusage(+ pid as libc::c_int,+ RUSAGE_INFO_V4,+ info.as_mut_ptr().cast::<libc::c_void>(),+ )+ };+ if result != 0 {+ return Err(std::io::Error::last_os_error().to_string());+ }++ let info = unsafe { info.assume_init() };+ Ok(ProcessMemoryInfo {+ resident_size: info.ri_resident_size,+ physical_footprint: info.ri_phys_footprint,+ peak_physical_footprint: info.ri_lifetime_max_phys_footprint,+ })+}++#[cfg(not(target_os = "macos"))]+fn capture_process_memory_info(_pid: u32) -> Result<ProcessMemoryInfo, String> {+ Err("memory diagnostics are only wired on macOS for now".to_string())+}+struct StyleToken<'a> {name: &'a str,value: &'a str,@@ -403,6 +625,7 @@ impl SettingsWindow {height: Dimension::Pixels(DEFAULT_HEIGHT as f32),x: None,y: None,+ macos_frame_autosave_name: None,origin: GeometryOrigin::default(),};@@ -559,7 +782,7 @@ impl SettingsWindow {self.ui.drag = None;self.ui.interaction.hovered = action;if pressed.is_some() && pressed == action {- self.perform_action(action.unwrap());+ self.perform_action(action.unwrap(), window);}window.invalidate();}@@ -625,6 +848,52 @@ impl SettingsWindow {.detach();}+ fn schedule_memory_monitor_tick(&self, window: &Window, generation: u64) {+ let window = window.clone();+ promise::spawn::spawn_into_main_thread(async move {+ smol::Timer::after(Duration::from_millis(1500)).await;+ SETTINGS_WINDOW.with(|slot| {+ let Some(settings) = slot.borrow().as_ref().cloned() else {+ return;+ };+ let mut settings = settings.borrow_mut();+ if !settings.ui.memory_monitoring+ || settings.ui.memory_monitor_generation != generation+ {+ return;+ }+ let snapshot = capture_memory_snapshot();+ log::info!("settings memory diagnostics: {}", snapshot.log_line());+ settings.ui.memory_snapshot = Some(snapshot);+ window.invalidate();+ settings.schedule_memory_monitor_tick(&window, generation);+ });+ })+ .detach();+ }++ fn schedule_copied_state_clear(&self, window: &Window) {+ let window = window.clone();+ promise::spawn::spawn_into_main_thread(async move {+ smol::Timer::after(Duration::from_millis(1450)).await;+ SETTINGS_WINDOW.with(|slot| {+ let Some(settings) = slot.borrow().as_ref().cloned() else {+ return;+ };+ let mut settings = settings.borrow_mut();+ if settings+ .ui+ .memory_snapshot_copied_until+ .is_some_and(|until| Instant::now() >= until)+ {+ settings.ui.memory_snapshot_copied_until = None;+ window.invalidate();+ }+ });+ })+ .detach();+ }+fn key_event(&mut self, event: KeyEvent, window: &Window) -> bool {if !event.key_is_down {return false;@@ -1041,6 +1310,25 @@ impl SettingsWindow {(bottom_y + 65.0).max(self.content_bottom())}+ fn developer_mode_enabled(&self) -> bool {+ self.native_settings.developer.developer_mode+ }++ fn visible_sections(&self) -> Vec<SettingsSection> {+ let mut sections = Vec::with_capacity(BASE_SECTIONS.len() + DEVELOPER_SECTIONS.len());+ for section in BASE_SECTIONS {+ if *section == SettingsSection::About && self.developer_mode_enabled() {+ sections.extend_from_slice(DEVELOPER_SECTIONS);+ }+ sections.push(*section);+ }+ sections+ }++ fn section_is_visible(&self, section: SettingsSection) -> bool {+ self.visible_sections().contains(§ion)+ }+fn clamp_sidebar_to_window(&mut self) {let dynamic_max = (self.dimensions.pixel_width as f32 * 0.38).max(self.ui.sidebar.min_width)@@ -1050,7 +1338,7 @@ impl SettingsWindow {}}- fn perform_action(&mut self, action: SettingsAction) {+ fn perform_action(&mut self, action: SettingsAction, window: &Window) {match action {SettingsAction::Select(section) => {self.selected = section;@@ -1078,6 +1366,80 @@ impl SettingsWindow {}};}+ SettingsAction::ToggleMainWindowFrameRestore => {+ self.ui.open_dropdown = None;+ self.native_settings.window.restore_main_window_frame =+ !self.native_settings.window.restore_main_window_frame;+ match crate::native_settings::save(&self.native_settings) {+ Ok(()) => {+ self.status = if self.native_settings.window.restore_main_window_frame {+ "Main window frame restore enabled for new macOS windows.".to_string()+ } else {+ "Main window frame restore disabled for new macOS windows.".to_string()+ };+ }+ Err(err) => {+ self.status = format!("Unable to save window restore setting: {err:#}");+ }+ }+ }+ SettingsAction::ToggleDeveloperMode => {+ self.ui.open_dropdown = None;+ self.native_settings.developer.developer_mode =+ !self.native_settings.developer.developer_mode;+ if !self.developer_mode_enabled() && !self.section_is_visible(self.selected) {+ self.selected = SettingsSection::Developer;+ self.ui.content_scroll.reset();+ }+ match crate::native_settings::save(&self.native_settings) {+ Ok(()) => {+ self.status = if self.developer_mode_enabled() {+ "Developer mode enabled. Extra diagnostics tabs are now visible."+ .to_string()+ } else {+ "Developer mode disabled. Diagnostics tabs are hidden.".to_string()+ };+ }+ Err(err) => {+ self.status = format!("Unable to save developer mode: {err:#}");+ }+ }+ }+ SettingsAction::ToggleMemoryMonitoring => {+ self.ui.open_dropdown = None;+ self.ui.memory_monitoring = !self.ui.memory_monitoring;+ self.ui.memory_monitor_generation =+ self.ui.memory_monitor_generation.wrapping_add(1);+ if self.ui.memory_monitoring {+ let snapshot = capture_memory_snapshot();+ log::info!("settings memory diagnostics: {}", snapshot.log_line());+ self.ui.memory_snapshot = Some(snapshot);+ self.status = "Memory diagnostics are running manually.".to_string();+ self.schedule_memory_monitor_tick(window, self.ui.memory_monitor_generation);+ } else {+ self.status = "Memory diagnostics stopped.".to_string();+ }+ }+ SettingsAction::RefreshMemorySnapshot => {+ self.ui.open_dropdown = None;+ let snapshot = capture_memory_snapshot();+ log::info!("settings memory diagnostics: {}", snapshot.log_line());+ self.ui.memory_snapshot = Some(snapshot);+ self.status = "Memory snapshot refreshed.".to_string();+ }+ SettingsAction::CopyMemorySnapshot => {+ self.ui.open_dropdown = None;+ if self.ui.memory_snapshot.is_none() {+ self.ui.memory_snapshot = Some(capture_memory_snapshot());+ }+ if let Some(snapshot) = &self.ui.memory_snapshot {+ window.set_clipboard(Clipboard::Clipboard, snapshot.summary_for_clipboard());+ self.ui.memory_snapshot_copied_until =+ Some(Instant::now() + Duration::from_millis(1400));+ self.status = "Memory snapshot copied.".to_string();+ self.schedule_copied_state_clear(window);+ }+ }SettingsAction::ToggleThemeModeMenu => {self.ui.open_dropdown =if self.ui.open_dropdown == Some(SettingsDropdown::ThemeMode) {@@ -1544,6 +1906,8 @@ impl SettingsWindow {max_width,)?,SettingsSection::Developer => self.paint_developer(layers, x, max_width)?,+ SettingsSection::UiKit => self.paint_ui_kit(layers, x, max_width)?,+ SettingsSection::Memory => self.paint_memory_diagnostics(layers, x, max_width)?,SettingsSection::About => self.paint_placeholder(layers,&ui_font,@@ -1574,8 +1938,8 @@ impl SettingsWindow {let scroll = self.ui.content_scroll.offset;let row_step = self.settings_row_step();let section_y = CONTENT_SECTION_Y - scroll;- let (card_y, first_row_y) = self.settings_card_geometry(section_y, 3);- let card_height = self.settings_card_height(3);+ let (card_y, first_row_y) = self.settings_card_geometry(section_y, 4);+ let card_height = self.settings_card_height(4);self.ui.content_scroll.set_extents(self.content_bottom(),self.settings_content_extent(card_y + scroll + card_height),@@ -1635,6 +1999,17 @@ impl SettingsWindow {"Small ThinkTerm-native state; compatible terminal config stays in wezterm.lua.",true,)?;+ self.paint_toggle_setting_row(+ layers,+ row_x,+ first_row_y + row_step * 3.0,+ row_width,+ "Restore Main Window Frame",+ "macOS restores the last main terminal window size and position.",+ self.native_settings.window.restore_main_window_frame,+ SettingsAction::ToggleMainWindowFrameRestore,+ true,+ )?;Ok(())}@@ -1860,6 +2235,90 @@ impl SettingsWindow {layers: &mut TripleLayerQuadAllocator<'_>,x: f32,max_width: f32,+ ) -> anyhow::Result<()> {+ let palette = self.palette();+ let ui_font = Rc::clone(&self.ui_font);+ let scroll = self.ui.content_scroll.offset;+ let row_step = self.settings_row_step();+ let section_y = CONTENT_SECTION_Y - scroll;+ let (card_y, first_row_y) = self.settings_card_geometry(section_y, 2);+ let card_height = self.settings_card_height(2);+ let button_y = card_y + card_height + self.settings_section_card_gap();+ self.ui.content_scroll.set_extents(+ self.content_bottom(),+ self.settings_content_extent(button_y + scroll + CONTROL_HEIGHT),+ );++ self.draw_text(+ layers,+ &ui_font,+ x,+ section_y,+ "Keep normal Settings clean. Enable developer mode to reveal internal pages. Memory sampling still has to be started manually.",+ palette.secondary_text,+ max_width,+ )?;++ let card_padding = 36.0;+ let row_x = x + card_padding;+ let row_width = max_width - card_padding * 2.0;+ self.paint_group_card(layers, x, card_y, max_width, card_height)?;+ self.paint_setting_row(+ layers,+ row_x,+ first_row_y,+ row_width,+ "Developer Mode",+ "Shows internal Settings pages for UI tuning and memory diagnostics.",+ if self.developer_mode_enabled() {+ "On"+ } else {+ "Off"+ },+ false,+ )?;+ self.paint_setting_row(+ layers,+ row_x,+ first_row_y + row_step,+ row_width,+ "Visible Developer Tabs",+ "UI Kit and Memory tabs are shown here; diagnostics do not run automatically.",+ if self.developer_mode_enabled() {+ "UI Kit, Memory"+ } else {+ "Hidden"+ },+ true,+ )?;+ self.draw_button(+ layers,+ x,+ button_y,+ self.button_width_for_label(+ if self.developer_mode_enabled() {+ "Disable Developer Mode"+ } else {+ "Enable Developer Mode"+ },+ 300.0,+ ),+ if self.developer_mode_enabled() {+ "Disable Developer Mode"+ } else {+ "Enable Developer Mode"+ },+ SettingsAction::ToggleDeveloperMode,+ )?;++ Ok(())+ }++ fn paint_ui_kit(+ &mut self,+ layers: &mut TripleLayerQuadAllocator<'_>,+ x: f32,+ max_width: f32,) -> anyhow::Result<()> {let palette = self.palette();let ui_font = Rc::clone(&self.ui_font);@@ -2097,6 +2556,156 @@ impl SettingsWindow {Ok(())}+ fn paint_memory_diagnostics(+ &mut self,+ layers: &mut TripleLayerQuadAllocator<'_>,+ x: f32,+ max_width: f32,+ ) -> anyhow::Result<()> {+ let palette = self.palette();+ let ui_font = Rc::clone(&self.ui_font);+ let scroll = self.ui.content_scroll.offset;+ let row_step = self.settings_row_step();+ let section_y = CONTENT_SECTION_Y - scroll;+ let (card_y, first_row_y) = self.settings_card_geometry(section_y, 5);+ let card_height = self.settings_card_height(5);+ let button_y = card_y + card_height + self.settings_section_card_gap();+ self.ui.content_scroll.set_extents(+ self.content_bottom(),+ self.settings_content_extent(button_y + scroll + CONTROL_HEIGHT),+ );++ self.draw_text(+ layers,+ &ui_font,+ x,+ section_y,+ "Memory diagnostics are manual. Developer mode only reveals this page; sampling starts when you enable it here.",+ palette.secondary_text,+ max_width,+ )?;++ let snapshot = self+ .ui+ .memory_snapshot+ .clone()+ .unwrap_or_else(capture_memory_snapshot);+ if self.ui.memory_snapshot.is_none() {+ self.ui.memory_snapshot = Some(snapshot.clone());+ }+ let age_label = format!("{:.1}s ago", snapshot.captured_at.elapsed().as_secs_f32());+ let footprint = snapshot+ .physical_footprint+ .map(format_bytes)+ .unwrap_or_else(|| "Unavailable".to_string());+ let rss = snapshot+ .resident_size+ .map(format_bytes)+ .unwrap_or_else(|| "Unavailable".to_string());+ let peak = snapshot+ .peak_physical_footprint+ .map(format_bytes)+ .unwrap_or_else(|| "Unavailable".to_string());+ let monitor_state = if self.ui.memory_monitoring {+ "Running"+ } else {+ "Off"+ };++ let card_padding = 36.0;+ let row_x = x + card_padding;+ let row_width = max_width - card_padding * 2.0;+ self.paint_group_card(layers, x, card_y, max_width, card_height)?;+ self.paint_setting_row(+ layers,+ row_x,+ first_row_y,+ row_width,+ "Manual Sampling",+ "Keeps refreshing this page until you turn it off.",+ monitor_state,+ false,+ )?;+ self.paint_setting_row(+ layers,+ row_x,+ first_row_y + row_step,+ row_width,+ "Physical Footprint",+ "Matches the macOS memory pressure number more closely than RSS.",+ &footprint,+ true,+ )?;+ self.paint_setting_row(+ layers,+ row_x,+ first_row_y + row_step * 2.0,+ row_width,+ "Resident Size",+ "Current resident process memory from proc_pid_rusage.",+ &rss,+ true,+ )?;+ self.paint_setting_row(+ layers,+ row_x,+ first_row_y + row_step * 3.0,+ row_width,+ "Peak Physical Footprint",+ "Highest physical footprint reported for this process lifetime.",+ &peak,+ true,+ )?;+ self.paint_setting_row(+ layers,+ row_x,+ first_row_y + row_step * 4.0,+ row_width,+ "Last Snapshot",+ "Manual refresh and copy use this latest captured value.",+ &age_label,+ true,+ )?;+ let primary_label = if self.ui.memory_monitoring {+ "Stop Memory Sampling"+ } else {+ "Start Memory Sampling"+ };+ self.draw_button(+ layers,+ x,+ button_y,+ self.button_width_for_label(primary_label, 300.0),+ primary_label,+ SettingsAction::ToggleMemoryMonitoring,+ )?;+ let refresh_x = x + self.button_width_for_label(primary_label, 300.0) + 16.0;+ self.draw_button(+ layers,+ refresh_x,+ button_y,+ self.button_width_for_label("Refresh Now", 210.0),+ "Refresh Now",+ SettingsAction::RefreshMemorySnapshot,+ )?;+ let copied = self+ .ui+ .memory_snapshot_copied_until+ .is_some_and(|until| Instant::now() < until);+ let copy_label = if copied { "Copied" } else { "Copy" };+ let copy_x = refresh_x + self.button_width_for_label("Refresh Now", 210.0) + 16.0;+ self.draw_button(+ layers,+ copy_x,+ button_y,+ self.button_width_for_label(copy_label, 150.0),+ copy_label,+ SettingsAction::CopyMemorySnapshot,+ )?;++ Ok(())+ }+fn paint_preview_search(&self,layers: &mut TripleLayerQuadAllocator<'_>,@@ -2511,6 +3120,83 @@ impl SettingsWindow {Ok(())}+ fn paint_toggle_setting_row(+ &mut self,+ layers: &mut TripleLayerQuadAllocator<'_>,+ x: f32,+ y: f32,+ width: f32,+ label: &str,+ description: &str,+ enabled: bool,+ action: SettingsAction,+ draw_top_rule: bool,+ ) -> anyhow::Result<()> {+ let palette = self.palette();+ let ui_font = Rc::clone(&self.ui_font);+ if draw_top_rule {+ self.paint_separator(layers, x, y - 28.0, width)?;+ }+ let control_width = if width >= 680.0 {+ 280.0_f32.min(width * 0.36)+ } else {+ 220.0_f32.min(width * 0.44)+ };+ let control_x = x + width - control_width;+ let control_y = y + 4.0;+ let text_width = (control_x - x - 24.0).max(width * 0.45);+ let control_rect = rect(control_x, control_y, control_width, CONTROL_HEIGHT);+ self.ui_context+ .push(control_rect, WidgetKind::Button, action);++ let hovered = self.ui.interaction.hovered == Some(action);+ let pressed = self.ui.interaction.pressed == Some(action);+ let bg = if pressed {+ palette.control_pressed_bg+ } else if hovered {+ palette.control_hover_bg+ } else {+ palette.control_bg+ };+ let border = if hovered || pressed {+ palette.separator+ } else {+ palette.control_border+ };++ self.draw_text(layers, &ui_font, x, y, label, palette.text, text_width)?;+ self.draw_text(+ layers,+ &ui_font,+ x,+ self.settings_row_description_y(y),+ description,+ palette.secondary_text,+ text_width,+ )?;+ self.draw_rounded_frame(+ layers,+ 0,+ control_x,+ control_y,+ control_width,+ CONTROL_HEIGHT,+ bg,+ border,+ CONTROL_RADIUS,+ )?;+ self.draw_text(+ layers,+ &ui_font,+ control_x + 14.0,+ self.control_text_y(control_y, CONTROL_HEIGHT),+ if enabled { "On" } else { "Off" },+ palette.text,+ control_width - 26.0,+ )?;+ Ok(())+ }+fn paint_group_card(&self,layers: &mut TripleLayerQuadAllocator<'_>,@@ -3028,12 +3714,12 @@ impl SettingsWindow {fn filtered_sections(&self) -> Vec<SettingsSection> {let query = self.ui.search.text.trim().to_lowercase();+ let sections = self.visible_sections();if query.is_empty() {- return SECTIONS.to_vec();+ return sections;}- SECTIONS- .iter()- .copied()+ sections+ .into_iter().filter(|section| {section.label().to_lowercase().contains(&query)|| sectiondiff --git a/wezterm-gui/src/tabbar.rs b/wezterm-gui/src/tabbar.rsindex 22d1e859..ba006412 100644--- a/wezterm-gui/src/tabbar.rs+++ b/wezterm-gui/src/tabbar.rs@@ -1,3 +1,4 @@+use crate::termwindow::ui::status_icon::UiStatusKind;use crate::termwindow::ui::terminal_title_for_display;use crate::termwindow::{PaneInformation, TabInformation, UIItem, UIItemType};use config::{ConfigHandle, TabBarColors};@@ -35,6 +36,7 @@ pub enum TabBarItem {pub struct TabEntry {pub item: TabBarItem,pub title: Line,+ pub status: Option<UiStatusKind>,x: usize,width: usize,}@@ -133,6 +135,32 @@ fn pct_to_glyph(pct: u8) -> char {}}+fn leading_legacy_progress_marker(line: &Line) -> bool {+ for cell in line.visible_cells() {+ let value = cell.str();+ if value.trim().is_empty() {+ continue;+ }+ return is_legacy_progress_marker(value);+ }+ false+}++fn is_legacy_progress_marker(value: &str) -> bool {+ let mut chars = value.chars();+ let Some(ch) = chars.next() else {+ return false;+ };+ if chars.next().is_some() {+ return false;+ }++ matches!(+ ch as u32,+ 0x2800..=0x28ff | 0xf0130 | 0xf0a9e..=0xf0aa5 | 0xee00..=0xee0b+ )+}+fn compute_tab_title(tab: &TabInformation,tab_info: &[TabInformation],@@ -177,22 +205,24 @@ fn compute_tab_title(title = format!("{}{classic_spacing}", title);}- match pane.progress {- Progress::None => {}- Progress::Percentage(pct) | Progress::Error(pct) => {- let graphic = format!("{} ", pct_to_glyph(pct));- len += unicode_column_width(&graphic, None);- let color = if matches!(pane.progress, Progress::Percentage(_)) {- FormatItem::Foreground(FormatColor::AnsiColor(AnsiColor::Green))- } else {- FormatItem::Foreground(FormatColor::AnsiColor(AnsiColor::Red))- };- items.push(color);- items.push(FormatItem::Text(graphic));- items.push(FormatItem::Foreground(FormatColor::Default));- }- Progress::Indeterminate => {- // TODO: Decide what to do here to indicate this+ if !config.use_fancy_tab_bar {+ match pane.progress {+ Progress::None => {}+ Progress::Percentage(pct) | Progress::Error(pct) => {+ let graphic = format!("{} ", pct_to_glyph(pct));+ len += unicode_column_width(&graphic, None);+ let color = if matches!(pane.progress, Progress::Percentage(_)) {+ FormatItem::Foreground(FormatColor::AnsiColor(AnsiColor::Green))+ } else {+ FormatItem::Foreground(FormatColor::AnsiColor(AnsiColor::Red))+ };+ items.push(color);+ items.push(FormatItem::Text(graphic));+ items.push(FormatItem::Foreground(FormatColor::Default));+ }+ Progress::Indeterminate => {+ // Classic tab titles keep the historical textual behavior.+ }}}@@ -281,6 +311,7 @@ impl TabBarState {items: vec![TabEntry {item: TabBarItem::None,title: Line::from_text(" ", &CellAttributes::blank(), 1, None),+ status: None,x: 1,width: 1,}],@@ -374,6 +405,7 @@ impl TabBarState {items.push(TabEntry {item: TabBarItem::WindowButton(*button),title: title.to_owned(),+ status: None,x: *x,width,});@@ -511,6 +543,7 @@ impl TabBarState {items.push(TabEntry {item: TabBarItem::LeftStatus,title: left_status_line.clone(),+ status: None,x,width: left_status_line.len(),});@@ -559,6 +592,17 @@ impl TabBarState {);let title = tab_line.clone();+ let status = if config.use_fancy_tab_bar {+ tab_info[tab_idx]+ .active_pane+ .as_ref()+ .and_then(|pane| UiStatusKind::from_progress(&pane.progress))+ .or_else(|| {+ leading_legacy_progress_marker(&tab_line).then_some(UiStatusKind::Running)+ })+ } else {+ None+ };if tab_line.len() > tab_width_max {tab_line.resize(tab_width_max, SEQ_ZERO);}@@ -568,6 +612,7 @@ impl TabBarState {items.push(TabEntry {item: TabBarItem::Tab { tab_idx, active },title,+ status,x: tab_start_idx,width,});@@ -590,6 +635,7 @@ impl TabBarState {items.push(TabEntry {item: TabBarItem::NewTabButton,title: new_tab_button.clone(),+ status: None,x: button_start,width,});@@ -652,6 +698,7 @@ impl TabBarState {items.push(TabEntry {item: TabBarItem::RightStatus,title: right_status_line.clone(),+ status: None,x,width: status_space_available,});diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rsindex c820110f..a13d9337 100644--- a/wezterm-gui/src/termwindow/mod.rs+++ b/wezterm-gui/src/termwindow/mod.rs@@ -219,6 +219,7 @@ pub enum UIItemType {WorkspaceSidebarBackground,WorkspaceSidebarResize,WorkspaceSidebarSettings,+ WorkspaceSidebarViewOptions,AboveScrollThumb,ScrollThumb,BelowScrollThumb,@@ -1093,6 +1094,15 @@ impl TermWindow {height: Dimension::Pixels(dimensions.pixel_height as f32),x,y,+ macos_frame_autosave_name: if cfg!(target_os = "macos")+ && crate::native_settings::load()+ .window+ .restore_main_window_frame+ {+ Some("ThinkTerm.MainWindow".to_string())+ } else {+ None+ },origin,};log::trace!("{:?}", geometry);diff --git a/wezterm-gui/src/termwindow/mouseevent.rs b/wezterm-gui/src/termwindow/mouseevent.rsindex 5b3c755a..6ef6344e 100644--- a/wezterm-gui/src/termwindow/mouseevent.rs+++ b/wezterm-gui/src/termwindow/mouseevent.rs@@ -576,6 +576,7 @@ impl super::TermWindow {| UIItemType::WorkspaceSidebarBackground| UIItemType::WorkspaceSidebarResize| UIItemType::WorkspaceSidebarSettings+ | UIItemType::WorkspaceSidebarViewOptions| UIItemType::AboveScrollThumb| UIItemType::BelowScrollThumb| UIItemType::ScrollThumb@@ -601,6 +602,7 @@ impl super::TermWindow {| UIItemType::WorkspaceSidebarBackground| UIItemType::WorkspaceSidebarResize| UIItemType::WorkspaceSidebarSettings+ | UIItemType::WorkspaceSidebarViewOptions| UIItemType::AboveScrollThumb| UIItemType::BelowScrollThumb| UIItemType::ScrollThumb@@ -749,9 +751,17 @@ impl super::TermWindow {// Completed a window dragreturn;}- if press == &MousePress::Left && self.dragging.take().is_some() {- // Completed a drag- return;+ if press == &MousePress::Left {+ let completed_drag = self.dragging.take();+ if completed_drag.as_ref().is_some_and(|(item, _)| {+ item.item_type == UIItemType::WorkspaceSidebarResize+ }) {+ self.persist_workspace_sidebar_width();+ }+ if completed_drag.is_some() {+ // Completed a drag+ return;+ }}}@@ -1107,6 +1117,9 @@ impl super::TermWindow {UIItemType::WorkspaceSidebarSettings => {self.mouse_event_workspace_sidebar_settings(event, context);}+ UIItemType::WorkspaceSidebarViewOptions => {+ self.mouse_event_workspace_sidebar_view_options(item, event, context);+ }}}@@ -1153,6 +1166,22 @@ impl super::TermWindow {}}+ pub fn mouse_event_workspace_sidebar_view_options(+ &mut self,+ item: UIItem,+ event: MouseEvent,+ context: &dyn WindowOps,+ ) {+ context.set_cursor(Some(MouseCursor::Hand));+ if event.kind == WMEK::Press(MousePress::Left) {+ let coords = window::Point::new(+ item.x.saturating_add(item.width) as isize,+ item.y.saturating_add(item.height / 2) as isize,+ );+ context.show_context_menu(coords, self.workspace_sidebar_view_options_menu_items());+ }+ }+pub fn mouse_event_workspace_sidebar_scroll_thumb(&mut self,item: UIItem,@@ -1347,6 +1376,52 @@ impl super::TermWindow {]}+ fn workspace_sidebar_view_options_menu_items(&self) -> Vec<ContextMenuItem> {+ use config::keyassignment::KeyAssignment;++ vec![+ ContextMenuItem::item("Group by", KeyAssignment::Nop).disabled(),+ ContextMenuItem::item_with_icon("Workspace", "folder", KeyAssignment::Nop)+ .checked(true)+ .disabled(),+ ContextMenuItem::Separator,+ ContextMenuItem::item("Show", KeyAssignment::Nop).disabled(),+ ContextMenuItem::submenu(+ "Status",+ vec![+ ContextMenuItem::item_with_icon(+ "Running",+ "arrow.triangle.2.circlepath",+ KeyAssignment::Nop,+ )+ .checked(true)+ .disabled(),+ ContextMenuItem::item_with_icon(+ "Needs Attention",+ "exclamationmark.circle",+ KeyAssignment::Nop,+ )+ .checked(true)+ .disabled(),+ ContextMenuItem::item_with_icon("Done", "checkmark.circle", KeyAssignment::Nop)+ .checked(true)+ .disabled(),+ ],+ ),+ ContextMenuItem::item_with_icon("Unread", "envelope.badge", KeyAssignment::Nop)+ .checked(true)+ .disabled(),+ ContextMenuItem::item_with_icon("Archived", "archivebox", KeyAssignment::Nop)+ .disabled(),+ ContextMenuItem::item_with_icon("Pinned", "pin", KeyAssignment::Nop)+ .checked(true)+ .disabled(),+ ContextMenuItem::Separator,+ ContextMenuItem::item("Collapse All", KeyAssignment::Nop).disabled(),+ ContextMenuItem::item("Mark All Read", KeyAssignment::Nop).disabled(),+ ]+ }+fn project_session_context_menu_items(&self, session_id: &str) -> Vec<ContextMenuItem> {let session_id = session_id.to_string();let is_pinned = crate::project_sessions::session_is_pinned(&session_id);diff --git a/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs b/wezterm-gui/src/termwindow/render/fancy_tab_bar.rsindex 5eea5f37..f8c760c2 100644--- a/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs+++ b/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs@@ -466,7 +466,15 @@ impl crate::TermWindow {)?;}- let text_x = icon_x + icon_size + WINDOW_TAB_ICON_GAP;+ let mut text_x = icon_x + icon_size + WINDOW_TAB_ICON_GAP;+ if let Some(status) = item.status {+ let status_x = text_x;+ if status_x >= viewport_left && status_x.saturating_add(icon_size) <= viewport_right {+ self.paint_status_icon(layers, 2, status, status_x, icon_y, icon_size, foreground)+ .context("window tab status icon")?;+ }+ text_x = status_x + icon_size + WINDOW_TAB_ICON_GAP;+ }let text_right = if close_slot_reserved {close_x.saturating_sub(WINDOW_TAB_ICON_GAP)} else {@@ -499,6 +507,7 @@ impl crate::TermWindow {layers,font,&item.title,+ item.status.is_some(),text_x,text_y,text_width,@@ -570,6 +579,7 @@ impl crate::TermWindow {layers: &mut TripleLayerQuadAllocator,font: &Rc<LoadedFont>,title: &Line,+ strip_leading_progress: bool,x: usize,y: usize,width: usize,@@ -583,8 +593,19 @@ impl crate::TermWindow {}let mut text = String::new();+ let mut trimming_legacy_progress = strip_leading_progress;for cell in title.visible_cells() {- text.push_str(cell.str());+ let value = cell.str();+ if trimming_legacy_progress {+ if is_legacy_progress_marker(value) {+ continue;+ }+ if text.is_empty() && value.trim().is_empty() {+ continue;+ }+ trimming_legacy_progress = false;+ }+ text.push_str(value);}self.paint_ui_title_text(layers, font, &metrics, &text, x, y, width, foreground)}@@ -739,3 +760,18 @@ fn fancy_tab_icon_size(metrics: &RenderMetrics, tab_bar_height: f32) -> f32 {let from_font = metrics.cell_size.height as f32 * 0.95;from_bar.min(from_font).clamp(18.0, 24.0).floor()}++fn is_legacy_progress_marker(value: &str) -> bool {+ let mut chars = value.chars();+ let Some(ch) = chars.next() else {+ return false;+ };+ if chars.next().is_some() {+ return false;+ }++ matches!(+ ch as u32,+ 0x2800..=0x28ff | 0xf0130 | 0xf0a9e..=0xf0aa5 | 0xee00..=0xee0b+ )+}diff --git a/wezterm-gui/src/termwindow/ui/icons.rs b/wezterm-gui/src/termwindow/ui/icons.rsindex 68757b78..4b03e96c 100644--- a/wezterm-gui/src/termwindow/ui/icons.rs+++ b/wezterm-gui/src/termwindow/ui/icons.rs@@ -15,6 +15,9 @@ pub enum SvgIcon {Globe,Info,Keyboard,+ Loader,+ LoaderCircle,+ MemoryStick,Minus,Palette,PanelLeft,@@ -29,6 +32,9 @@ pub enum SvgIcon {Search,Settings,SlidersHorizontal,+ SlidersVertical,+ CircleAlert,+ CircleCheck,SquareTerminal,SplitHorizontal,SplitVertical,@@ -61,6 +67,13 @@ impl SvgIcon {Self::Globe => include_bytes!("../../../../third_party/lucide/icons/globe.svg"),Self::Info => include_bytes!("../../../../third_party/lucide/icons/info.svg"),Self::Keyboard => include_bytes!("../../../../third_party/lucide/icons/keyboard.svg"),+ Self::Loader => include_bytes!("../../../../third_party/lucide/icons/loader.svg"),+ Self::LoaderCircle => {+ include_bytes!("../../../../third_party/lucide/icons/loader-circle.svg")+ }+ Self::MemoryStick => {+ include_bytes!("../../../../third_party/lucide/icons/memory-stick.svg")+ }Self::Minus => include_bytes!("../../../../third_party/lucide/icons/minus.svg"),Self::Palette => include_bytes!("../../../../third_party/lucide/icons/palette.svg"),Self::PanelLeft => {@@ -89,6 +102,15 @@ impl SvgIcon {Self::SlidersHorizontal => {include_bytes!("../../../../third_party/lucide/icons/sliders-horizontal.svg")}+ Self::SlidersVertical => {+ include_bytes!("../../../../third_party/lucide/icons/sliders-vertical.svg")+ }+ Self::CircleAlert => {+ include_bytes!("../../../../third_party/lucide/icons/circle-alert.svg")+ }+ Self::CircleCheck => {+ include_bytes!("../../../../third_party/lucide/icons/circle-check.svg")+ }Self::SquareTerminal => {include_bytes!("../../../../third_party/lucide/icons/square-terminal.svg")}@@ -105,6 +127,10 @@ impl SvgIcon {}pub fn rasterize(self, size: usize) -> Result<Image> {+ self.rasterize_with_rotation(size, 0.0)+ }++ pub fn rasterize_with_rotation(self, size: usize, degrees: f32) -> Result<Image> {let size = size.max(1);let svg = std::str::from_utf8(self.bytes()).context("SVG asset is not UTF-8")?;let svg = svg.replace("currentColor", "#ffffff");@@ -114,8 +140,11 @@ impl SvgIcon {let scale = (size as f32 / svg_size.width()).min(size as f32 / svg_size.height());let translate_x = (size as f32 - svg_size.width() * scale) / 2.0;let translate_y = (size as f32 - svg_size.height() * scale) / 2.0;- let transform = resvg::tiny_skia::Transform::from_translate(translate_x, translate_y)+ let mut transform = resvg::tiny_skia::Transform::from_translate(translate_x, translate_y).pre_scale(scale, scale);+ if degrees != 0.0 {+ transform = transform.pre_rotate_at(degrees, size as f32 / 2.0, size as f32 / 2.0);+ }let mut pixmap = resvg::tiny_skia::Pixmap::new(size as u32, size as u32).with_context(|| format!("allocating {size}px SVG icon pixmap"))?;@@ -143,6 +172,8 @@ mod tests {SvgIcon::Globe,SvgIcon::Info,SvgIcon::Keyboard,+ SvgIcon::Loader,+ SvgIcon::LoaderCircle,SvgIcon::Minus,SvgIcon::Palette,SvgIcon::PanelLeft,@@ -157,6 +188,9 @@ mod tests {SvgIcon::Search,SvgIcon::Settings,SvgIcon::SlidersHorizontal,+ SvgIcon::SlidersVertical,+ SvgIcon::CircleAlert,+ SvgIcon::CircleCheck,SvgIcon::SquareTerminal,SvgIcon::SplitHorizontal,SvgIcon::SplitVertical,diff --git a/wezterm-gui/src/termwindow/ui/mod.rs b/wezterm-gui/src/termwindow/ui/mod.rsindex ce697336..b9f6df87 100644--- a/wezterm-gui/src/termwindow/ui/mod.rs+++ b/wezterm-gui/src/termwindow/ui/mod.rs@@ -1,5 +1,6 @@pub mod icons;pub mod sidebar;+pub mod status_icon;pub mod tokens;use crate::utilsprites::RenderMetrics;diff --git a/wezterm-gui/src/termwindow/ui/sidebar.rs b/wezterm-gui/src/termwindow/ui/sidebar.rsindex 7d181282..e74459e8 100644--- a/wezterm-gui/src/termwindow/ui/sidebar.rs+++ b/wezterm-gui/src/termwindow/ui/sidebar.rs@@ -28,6 +28,21 @@ use window::{MouseEventKind as WMEK, RectF, WindowOps, WindowState};const SIDEBAR_SCROLLBAR_VISIBLE_MS: u64 = 900;const SIDEBAR_SETTINGS_FOOTER_HEIGHT: usize = 72;const SIDEBAR_SETTINGS_FADE_HEIGHT: usize = 52;+const SIDEBAR_LIST_BOTTOM_PADDING: usize = 65;+const SIDEBAR_SETTINGS_ROW_TOP_PADDING: usize = 4;+const SIDEBAR_SETTINGS_ROW_BOTTOM_PADDING: usize = 12;+const SIDEBAR_SETTINGS_ROW_SIDE_PADDING: usize = 16;+const SIDEBAR_SETTINGS_ICON_EXTRA_INSET: usize = 18;+const SIDEBAR_SETTINGS_ROW_LIFT: usize = 18;+const SIDEBAR_TOP_FADE_HEIGHT: usize = 32;+const WORKSPACE_GROUP_EXTRA_GAP: usize = 8;+const WORKSPACE_SECTION_LABEL_GAP: usize = 12;+const SESSION_ROW_MIN_HEIGHT: usize = 62;+const SESSION_ROW_SIDE_PADDING: usize = 8;+const SESSION_ACTION_MIN_SIZE: usize = 48;+const SESSION_ACTION_MAX_SIZE: usize = 52;+const SESSION_ACTION_ICON_INSET: usize = 12;+const SESSION_STATUS_DOT_SIZE: usize = 10;#[derive(Debug, Clone, Copy)]pub struct WorkspaceSidebarRect {@@ -49,7 +64,11 @@ pub struct WorkspaceSidebarScrollGeometry {}pub fn workspace_sidebar_width_for_metrics(render_metrics: &RenderMetrics) -> usize {- (render_metrics.cell_size.width as usize * SIDEBAR_WIDTH_CELLS).max(SIDEBAR_MIN_WIDTH)+ let default_width =+ (render_metrics.cell_size.width as usize * SIDEBAR_WIDTH_CELLS).max(SIDEBAR_MIN_WIDTH);+ crate::native_settings::workspace_sidebar_width()+ .unwrap_or(default_width)+ .clamp(SIDEBAR_MIN_WIDTH, SIDEBAR_MAX_WIDTH)}impl crate::TermWindow {@@ -71,6 +90,15 @@ impl crate::TermWindow {width.clamp(SIDEBAR_MIN_WIDTH, self.workspace_sidebar_max_width());}+ pub fn persist_workspace_sidebar_width(&self) {+ let width = self+ .workspace_sidebar_width+ .clamp(SIDEBAR_MIN_WIDTH, SIDEBAR_MAX_WIDTH);+ if let Err(err) = crate::native_settings::save_workspace_sidebar_width(width) {+ log::warn!("failed to save workspace sidebar width: {err:#}");+ }+ }+pub fn toggle_workspace_sidebar(&mut self) {self.workspace_sidebar_collapsed = !self.workspace_sidebar_collapsed;}@@ -138,6 +166,12 @@ impl crate::TermWindow {.saturating_mul(row_height + row_gap),);}+ if !view.projects.is_empty() {+ if !view.pinned_sessions.is_empty() {+ height = height.saturating_add(WORKSPACE_SECTION_LABEL_GAP);+ }+ height = height.saturating_add(row_height + row_gap);+ }for project in &view.projects {height = height.saturating_add(row_height + row_gap);if !project.sessions_collapsed {@@ -145,9 +179,29 @@ impl crate::TermWindow {.saturating_add(project.sessions.len().saturating_mul(row_height + row_gap));}}+ height = height.saturating_add(+ view.projects+ .len()+ .saturating_sub(1)+ .saturating_mul(WORKSPACE_GROUP_EXTRA_GAP),+ );height.saturating_sub(row_gap)}+ fn workspace_sidebar_scroll_height(+ view: &project_sessions::ProjectSessionView,+ row_height: usize,+ row_gap: usize,+ viewport_height: usize,+ ) -> usize {+ let height = Self::workspace_sidebar_list_height(view, row_height, row_gap);+ if height > viewport_height {+ height.saturating_add(SIDEBAR_LIST_BOTTOM_PADDING)+ } else {+ height+ }+ }+fn workspace_sidebar_content_top(&self, panel_y: usize) -> usize {let base_top = panel_y + SIDEBAR_INSET;if cfg!(target_os = "macos") && !self.window_state.contains(WindowState::FULL_SCREEN) {@@ -184,7 +238,14 @@ impl crate::TermWindow {.saturating_sub(SIDEBAR_SETTINGS_FOOTER_HEIGHT);let content_bottom = (panel_y + panel_height.saturating_sub(SIDEBAR_INSET)).min(settings_footer_top.max(panel_y));- let list_top = self.workspace_sidebar_content_top(panel_y) + ui_cell_height + SIDEBAR_INSET;+ let mut list_top = self.workspace_sidebar_content_top(panel_y);+ if self.window_state.contains(WindowState::FULL_SCREEN) {+ list_top += WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_SIZE + SIDEBAR_INSET;+ }+ let row_height =+ (ui_cell_height.max(icon_size) + SIDEBAR_INSET).max(SESSION_ROW_MIN_HEIGHT);+ let top_action_height = row_height.min(48).max(ui_cell_height + SIDEBAR_INSET);+ list_top += top_action_height + SIDEBAR_INSET;let viewport_height = content_bottom.saturating_sub(list_top);if viewport_height == 0 {return 0.0;@@ -194,9 +255,9 @@ impl crate::TermWindow {let active_workspace = mux.active_workspace();let workspaces = mux.iter_workspaces();let view = project_sessions::view_for_current_project(&active_workspace, &workspaces);- let row_height = (ui_cell_height.max(icon_size) + SIDEBAR_INSET).max(52);let row_gap = SIDEBAR_ROW_GAP;- let total_height = Self::workspace_sidebar_list_height(&view, row_height, row_gap);+ let total_height =+ Self::workspace_sidebar_scroll_height(&view, row_height, row_gap, viewport_height);total_height.saturating_sub(viewport_height) as f32}@@ -226,7 +287,14 @@ impl crate::TermWindow {.saturating_sub(SIDEBAR_SETTINGS_FOOTER_HEIGHT);let content_bottom = (panel_y + panel_height.saturating_sub(SIDEBAR_INSET)).min(settings_footer_top.max(panel_y));- let list_top = self.workspace_sidebar_content_top(panel_y) + ui_cell_height + SIDEBAR_INSET;+ let mut list_top = self.workspace_sidebar_content_top(panel_y);+ if self.window_state.contains(WindowState::FULL_SCREEN) {+ list_top += WINDOW_TAB_FULLSCREEN_SIDEBAR_BUTTON_SIZE + SIDEBAR_INSET;+ }+ let row_height =+ (ui_cell_height.max(icon_size) + SIDEBAR_INSET).max(SESSION_ROW_MIN_HEIGHT);+ let top_action_height = row_height.min(48).max(ui_cell_height + SIDEBAR_INSET);+ list_top += top_action_height + SIDEBAR_INSET;let viewport_height = content_bottom.saturating_sub(list_top);if viewport_height == 0 {return None;@@ -236,9 +304,9 @@ impl crate::TermWindow {let active_workspace = mux.active_workspace();let workspaces = mux.iter_workspaces();let view = project_sessions::view_for_current_project(&active_workspace, &workspaces);- let row_height = (ui_cell_height.max(icon_size) + SIDEBAR_INSET).max(52);let row_gap = SIDEBAR_ROW_GAP;- let total_height = Self::workspace_sidebar_list_height(&view, row_height, row_gap);+ let total_height =+ Self::workspace_sidebar_scroll_height(&view, row_height, row_gap, viewport_height);let max_scroll = total_height.saturating_sub(viewport_height) as f32;if max_scroll <= 0.0 || total_height == 0 {return None;@@ -326,7 +394,8 @@ impl crate::TermWindow {item_type: UIItemType::WorkspaceSidebarBackground,});- let session_row_height = (ui_cell_height.max(icon_size) + SIDEBAR_INSET).max(52);+ let session_row_height =+ (ui_cell_height.max(icon_size) + SIDEBAR_INSET).max(SESSION_ROW_MIN_HEIGHT);let item_x = panel_x + SIDEBAR_INSET;let item_width = panel_width.saturating_sub(SIDEBAR_INSET * 2 + 1);self.ui_items.push(UIItem {@@ -403,56 +472,89 @@ impl crate::TermWindow {.saturating_add(panel_height).saturating_sub(settings_footer_height);content_bottom = content_bottom.min(settings_footer_y.max(panel_y));- let section_button_x = item_x- .saturating_add(item_width)- .saturating_sub(section_button_size + SIDEBAR_INSET);- let section_button_y = y.saturating_sub(6);- self.paint_sidebar_text(- layers,- &ui_font,- ui_metrics,- "Workspaces",- item_x + SIDEBAR_INSET,- y,- section_button_x.saturating_sub(item_x + SIDEBAR_INSET * 2),- muted_fg,- )?;+ let active_project_id = view+ .projects+ .iter()+ .find(|project| project.is_active)+ .map(|project| project.id.clone());+ let top_action_x = item_x + SIDEBAR_SETTINGS_ROW_SIDE_PADDING;+ let top_action_y = y;+ let top_action_width = item_width.saturating_sub(SIDEBAR_SETTINGS_ROW_SIDE_PADDING * 2);+ let top_action_height = session_row_height+ .min(48)+ .max(ui_cell_height + SIDEBAR_INSET);+ let top_action_hovered = active_project_id.is_some()+ && self.is_pointer_over_ui_rect(+ top_action_x,+ top_action_y,+ top_action_width,+ top_action_height,+ );self.fill_rounded_rectangle(layers,1,euclid::rect(- section_button_x as f32,- section_button_y as f32,- section_button_size as f32,- section_button_size as f32,+ top_action_x as f32,+ top_action_y as f32,+ top_action_width as f32,+ top_action_height as f32,),- foreground.mul_alpha(0.08),- SIDEBAR_ROW_RADIUS,+ foreground.mul_alpha(if top_action_hovered { 0.14 } else { 0.08 }),+ SIDEBAR_ROW_RADIUS + 4.0,)- .context("sidebar new project button")?;- self.ui_items.push(UIItem {- x: section_button_x,- y: section_button_y,- width: section_button_size,- height: section_button_size,- item_type: UIItemType::ProjectNew,- });- let section_icon_size = header_icon_size.min(section_button_size.saturating_sub(10));+ .context("sidebar add session button")?;+ if let Some(project_id) = active_project_id.clone() {+ self.ui_items.push(UIItem {+ x: top_action_x,+ y: top_action_y,+ width: top_action_width,+ height: top_action_height,+ item_type: UIItemType::ProjectSessionNew(project_id),+ });+ }+ let top_action_icon_size = header_icon_size.min(top_action_height.saturating_sub(14));+ let top_action_icon_x = top_action_x + SIDEBAR_SETTINGS_ICON_EXTRA_INSET;+ let top_action_icon_y =+ top_action_y + ((top_action_height.saturating_sub(top_action_icon_size)) / 2);+ let top_action_text_x = top_action_icon_x + top_action_icon_size + SIDEBAR_ICON_GAP + 8;+ let top_action_text_y =+ top_action_y + ((top_action_height.saturating_sub(ui_cell_height)) / 2);+ let top_action_fg = if active_project_id.is_some() {+ foreground+ } else {+ muted_fg+ };self.paint_sidebar_icon(layers,- SvgIcon::FolderPlus,- section_button_x + ((section_button_size.saturating_sub(section_icon_size)) / 2),- section_button_y + ((section_button_size.saturating_sub(section_icon_size)) / 2),- section_icon_size,- foreground,+ SvgIcon::Plus,+ top_action_icon_x,+ top_action_icon_y,+ top_action_icon_size,+ top_action_fg,+ )?;+ self.paint_sidebar_text(+ layers,+ &ui_font,+ ui_metrics,+ "Add New Session",+ top_action_text_x,+ top_action_text_y,+ top_action_x+ .saturating_add(top_action_width)+ .saturating_sub(top_action_text_x + SIDEBAR_INSET),+ top_action_fg,)?;- y += ui_cell_height + SIDEBAR_INSET;+ y += top_action_height + SIDEBAR_INSET;let list_top = y;let row_gap = SIDEBAR_ROW_GAP;let max_scroll = {let viewport_height = content_bottom.saturating_sub(list_top);- let total_height =- Self::workspace_sidebar_list_height(&view, session_row_height, row_gap);+ let total_height = Self::workspace_sidebar_scroll_height(+ &view,+ session_row_height,+ row_gap,+ viewport_height,+ );total_height.saturating_sub(viewport_height) as f32};self.workspace_sidebar_scroll_offset =@@ -561,9 +663,9 @@ impl crate::TermWindow {}let text_y = y + ((session_row_height.saturating_sub(ui_cell_height)) / 2);- let action_size = section_button_size- .min(session_row_height.saturating_sub(12))- .max(24);+ let action_size = session_row_height+ .saturating_sub(8)+ .clamp(SESSION_ACTION_MIN_SIZE, SESSION_ACTION_MAX_SIZE);let delete_x = pinned_x.saturating_add(pinned_width).saturating_sub(SIDEBAR_INSET + action_size);@@ -593,7 +695,7 @@ impl crate::TermWindow {)?;if is_hovered && !is_renaming_session {- for (x, item_type, icon, context_name) in [+ for (x, item_type, icon, _context_name) in [(pin_x,UIItemType::ProjectSessionPin(session.id.clone()),@@ -609,19 +711,6 @@ impl crate::TermWindow {] {let hovered =self.is_pointer_over_ui_rect(x, action_y, action_size, action_size);- self.fill_rounded_rectangle(- layers,- 1,- euclid::rect(- x as f32,- action_y as f32,- action_size as f32,- action_size as f32,- ),- foreground.mul_alpha(if hovered { 0.14 } else { 0.08 }),- SIDEBAR_ROW_RADIUS,- )- .context(context_name)?;self.ui_items.push(UIItem {x,y: action_y,@@ -629,15 +718,20 @@ impl crate::TermWindow {height: action_size,item_type,});- let action_icon_size =- header_icon_size.min(action_size.saturating_sub(10));+ let action_icon_size = action_size+ .saturating_sub(SESSION_ACTION_ICON_INSET)+ .max(header_icon_size);self.paint_sidebar_icon(layers,icon,x + ((action_size.saturating_sub(action_icon_size)) / 2),action_y + ((action_size.saturating_sub(action_icon_size)) / 2),action_icon_size,- if hovered { foreground } else { muted_fg },+ if hovered {+ foreground+ } else {+ muted_fg.mul_alpha(0.88)+ },)?;}}@@ -647,7 +741,72 @@ impl crate::TermWindow {}}- for project in &view.projects {+ if !view.projects.is_empty() {+ if !view.pinned_sessions.is_empty() {+ virtual_y += WORKSPACE_SECTION_LABEL_GAP;+ }+ let label_top = list_top_f + virtual_y as f32 - scroll_offset;+ let label_bottom = label_top + session_row_height as f32;+ let label_is_visible = label_bottom > list_top_f && label_top < content_bottom_f;+ if label_is_visible {+ let label_y = label_top.floor().max(0.0) as usize;+ let button_y =+ label_y + ((session_row_height.saturating_sub(section_button_size)) / 2);+ let button_x = item_x+ .saturating_add(item_width)+ .saturating_sub(section_button_size + SIDEBAR_INSET);+ let button_hovered = !suppress_hover+ && self.is_pointer_over_ui_rect(+ button_x,+ button_y,+ section_button_size,+ section_button_size,+ );+ self.paint_sidebar_text(+ layers,+ &ui_font,+ ui_metrics,+ "Workspaces",+ item_x + SIDEBAR_INSET,+ label_y + ((session_row_height.saturating_sub(ui_cell_height)) / 2),+ button_x.saturating_sub(item_x + SIDEBAR_INSET * 2),+ muted_fg,+ )?;+ self.fill_rounded_rectangle(+ layers,+ 1,+ euclid::rect(+ button_x as f32,+ button_y as f32,+ section_button_size as f32,+ section_button_size as f32,+ ),+ foreground.mul_alpha(if button_hovered { 0.14 } else { 0.08 }),+ SIDEBAR_ROW_RADIUS,+ )+ .context("sidebar new project button")?;+ self.ui_items.push(UIItem {+ x: button_x,+ y: button_y,+ width: section_button_size,+ height: section_button_size,+ item_type: UIItemType::ProjectNew,+ });+ let section_icon_size =+ header_icon_size.min(section_button_size.saturating_sub(10));+ self.paint_sidebar_icon(+ layers,+ SvgIcon::FolderPlus,+ button_x + ((section_button_size.saturating_sub(section_icon_size)) / 2),+ button_y + ((section_button_size.saturating_sub(section_icon_size)) / 2),+ section_icon_size,+ if button_hovered { foreground } else { muted_fg },+ )?;+ }+ virtual_y += session_row_height + row_gap;+ }++ for (project_idx, project) in view.projects.iter().enumerate() {let row_top = list_top_f + virtual_y as f32 - scroll_offset;let row_bottom = row_top + session_row_height as f32;let row_is_visible = row_bottom > list_top_f && row_top < content_bottom_f;@@ -767,15 +926,11 @@ impl crate::TermWindow {virtual_y += session_row_height + row_gap;if !project.sessions_collapsed {- let session_x = item_x + SIDEBAR_INSET * 3;- let session_width = item_width.saturating_sub(SIDEBAR_INSET * 3);- let session_icon_x = project_icon_x + SIDEBAR_INSET;- let session_text_x = session_icon_x + icon_size + SIDEBAR_ICON_GAP;- let guide_x = disclosure_x + disclosure_size / 2;- let guide_top =- (list_top_f + virtual_y as f32 - scroll_offset).max(list_top_f) as usize;- let session_start_virtual_y = virtual_y;- let mut guide_bottom = guide_top;+ let session_x = item_x + SIDEBAR_INSET * 3 + SESSION_ROW_SIDE_PADDING;+ let session_width =+ item_width.saturating_sub(SIDEBAR_INSET * 3 + SESSION_ROW_SIDE_PADDING * 2);+ let session_dot_x = session_x + SIDEBAR_INSET + 2;+ let session_text_x = session_dot_x + SESSION_STATUS_DOT_SIZE + SIDEBAR_ICON_GAP + 8;for session in &project.sessions {let row_top = list_top_f + virtual_y as f32 - scroll_offset;@@ -786,7 +941,6 @@ impl crate::TermWindow {let hit_bottom =row_bottom.min(content_bottom_f).ceil().max(hit_y as f32) as usize;let hit_height = hit_bottom.saturating_sub(hit_y).max(1);- guide_bottom = y.saturating_add(session_row_height);if row_is_visible && session.is_active {self.fill_rounded_rectangle_with_border(@@ -806,13 +960,9 @@ impl crate::TermWindow {.context("sidebar selected session")?;}- let icon_y = y + ((session_row_height.saturating_sub(icon_size)) / 2);let text_y = y + ((session_row_height.saturating_sub(ui_cell_height)) / 2);- let status_size = 8usize;- let status_x = session_x- .saturating_add(session_width)- .saturating_sub(SIDEBAR_INSET + status_size);- let status_y = y + ((session_row_height.saturating_sub(status_size)) / 2);+ let dot_y =+ y + ((session_row_height.saturating_sub(SESSION_STATUS_DOT_SIZE)) / 2);if row_is_visible {self.ui_items.push(UIItem {x: session_x,@@ -829,9 +979,9 @@ impl crate::TermWindow {session_row_height,);let is_renaming_session = self.is_renaming_sidebar_session(&session.id);- let action_size = section_button_size- .min(session_row_height.saturating_sub(12))- .max(24);+ let action_size = session_row_height+ .saturating_sub(8)+ .clamp(SESSION_ACTION_MIN_SIZE, SESSION_ACTION_MAX_SIZE);let delete_x = session_x.saturating_add(session_width).saturating_sub(SIDEBAR_INSET + action_size);@@ -840,7 +990,9 @@ impl crate::TermWindow {let text_right = if is_hovered && !is_renaming_session {pin_x} else {- status_x+ session_x+ .saturating_add(session_width)+ .saturating_sub(SIDEBAR_INSET)};let text_width = text_right.saturating_sub(session_text_x + SIDEBAR_INSET);if is_hovered && !session.is_active && !is_renaming_session {@@ -858,18 +1010,29 @@ impl crate::TermWindow {).context("sidebar hovered session")?;}- self.paint_sidebar_icon(+ self.fill_rounded_rectangle(layers,- SvgIcon::SquareTerminal,- session_icon_x,- icon_y,- icon_size,+ 1,+ euclid::rect(+ session_dot_x as f32,+ dot_y as f32,+ SESSION_STATUS_DOT_SIZE as f32,+ SESSION_STATUS_DOT_SIZE as f32,+ ),if session.is_active {- active_fg+ LinearRgba::with_components(0.20, 0.78, 0.36, 1.0)+ } else if session.is_unread {+ chrome.selected_bg+ } else if session.is_pinned {+ foreground.mul_alpha(0.68)+ } else if session.is_materialized {+ foreground.mul_alpha(0.45)} else {- muted_fg+ foreground.mul_alpha(0.16)},- )?;+ SESSION_STATUS_DOT_SIZE as f32 / 2.0,+ )+ .context("sidebar session status dot")?;let session_title = self.sidebar_session_title(&session.id, &session.name);self.paint_sidebar_text(layers,@@ -891,7 +1054,7 @@ impl crate::TermWindow {} else {SvgIcon::Pin};- for (x, item_type, icon, context_name) in [+ for (x, item_type, icon, _context_name) in [(pin_x,UIItemType::ProjectSessionPin(session.id.clone()),@@ -911,19 +1074,6 @@ impl crate::TermWindow {action_size,action_size,);- self.fill_rounded_rectangle(- layers,- 1,- euclid::rect(- x as f32,- action_y as f32,- action_size as f32,- action_size as f32,- ),- foreground.mul_alpha(if hovered { 0.14 } else { 0.08 }),- SIDEBAR_ROW_RADIUS,- )- .context(context_name)?;self.ui_items.push(UIItem {x,y: action_y,@@ -931,64 +1081,31 @@ impl crate::TermWindow {height: action_size,item_type,});- let action_icon_size =- header_icon_size.min(action_size.saturating_sub(10));+ let action_icon_size = action_size+ .saturating_sub(SESSION_ACTION_ICON_INSET)+ .max(header_icon_size);self.paint_sidebar_icon(layers,icon,x + ((action_size.saturating_sub(action_icon_size)) / 2),action_y + ((action_size.saturating_sub(action_icon_size)) / 2),action_icon_size,- if hovered { foreground } else { muted_fg },+ if hovered {+ foreground+ } else {+ muted_fg.mul_alpha(0.88)+ },)?;}- } else {- self.fill_rounded_rectangle(- layers,- 1,- euclid::rect(- status_x as f32,- status_y as f32,- status_size as f32,- status_size as f32,- ),- if session.is_active {- LinearRgba::with_components(0.20, 0.78, 0.36, 1.0)- } else if session.is_unread {- chrome.selected_bg- } else if session.is_pinned {- foreground.mul_alpha(0.68)- } else if session.is_materialized {- foreground.mul_alpha(0.45)- } else {- foreground.mul_alpha(0.16)- },- status_size as f32 / 2.0,- )- .context("sidebar session status")?;}}virtual_y += session_row_height + row_gap;}+ }- if virtual_y > session_start_virtual_y && guide_bottom > guide_top {- self.filled_rectangle(- layers,- 0,- euclid::rect(- guide_x as f32,- guide_top as f32,- 1.0,- guide_bottom- .min(content_bottom)- .saturating_sub(guide_top + row_gap)- as f32,- ),- foreground.mul_alpha(0.16),- )- .context("sidebar session guide")?;- }+ if project_idx + 1 < view.projects.len() {+ virtual_y += WORKSPACE_GROUP_EXTRA_GAP;}}@@ -1006,16 +1123,6 @@ impl crate::TermWindow {sidebar_bg,).context("sidebar header scroll mask")?;- self.paint_sidebar_text(- layers,- &ui_font,- ui_metrics,- "Workspaces",- item_x + SIDEBAR_INSET,- y.saturating_sub(ui_cell_height + SIDEBAR_INSET),- section_button_x.saturating_sub(item_x + SIDEBAR_INSET * 2),- muted_fg,- )?;if show_sidebar_toolbar {let toggle_hovered = self.is_pointer_over_ui_rect(sidebar_toggle_x,@@ -1047,27 +1154,71 @@ impl crate::TermWindow {if toggle_hovered { foreground } else { muted_fg },)?;}+ let top_action_hovered = active_project_id.is_some()+ && self.is_pointer_over_ui_rect(+ top_action_x,+ top_action_y,+ top_action_width,+ top_action_height,+ );self.fill_rounded_rectangle(layers,2,euclid::rect(- section_button_x as f32,- section_button_y as f32,- section_button_size as f32,- section_button_size as f32,+ top_action_x as f32,+ top_action_y as f32,+ top_action_width as f32,+ top_action_height as f32,),- foreground.mul_alpha(0.08),- SIDEBAR_ROW_RADIUS,+ foreground.mul_alpha(if top_action_hovered { 0.14 } else { 0.08 }),+ SIDEBAR_ROW_RADIUS + 4.0,)- .context("sidebar new project button repaint")?;+ .context("sidebar add session button repaint")?;+ let top_action_fg = if active_project_id.is_some() {+ foreground+ } else {+ muted_fg+ };self.paint_sidebar_icon(layers,- SvgIcon::FolderPlus,- section_button_x + ((section_button_size.saturating_sub(section_icon_size)) / 2),- section_button_y + ((section_button_size.saturating_sub(section_icon_size)) / 2),- section_icon_size,- foreground,+ SvgIcon::Plus,+ top_action_icon_x,+ top_action_icon_y,+ top_action_icon_size,+ top_action_fg,)?;+ self.paint_sidebar_text(+ layers,+ &ui_font,+ ui_metrics,+ "Add New Session",+ top_action_text_x,+ top_action_text_y,+ top_action_x+ .saturating_add(top_action_width)+ .saturating_sub(top_action_text_x + SIDEBAR_INSET),+ top_action_fg,+ )?;+ }++ if max_scroll > 0.0 && scroll_offset > 0.0 {+ let fade_height = SIDEBAR_TOP_FADE_HEIGHT.min(content_bottom.saturating_sub(list_top));+ for step in 0..fade_height {+ let progress = step as f32 / fade_height as f32;+ let alpha = 1.0 - progress * progress * (3.0 - 2.0 * progress);+ self.filled_rectangle(+ layers,+ 2,+ euclid::rect(+ panel_x as f32,+ (list_top + step) as f32,+ panel_width as f32,+ 1.0,+ ),+ sidebar_bg.mul_alpha(alpha),+ )+ .context("sidebar top scroll fade")?;+ }}let bottom_mask_height = panel_y@@ -1123,18 +1274,36 @@ impl crate::TermWindow {).context("sidebar settings footer background")?;- let settings_row_x = item_x + SIDEBAR_INSET;- let settings_row_y = settings_footer_y + 8;- let settings_row_width = item_width.saturating_sub(SIDEBAR_INSET * 2);- let settings_row_height = 48usize- .min(settings_footer_height.saturating_sub(SIDEBAR_INSET))+ let settings_row_x = item_x + SIDEBAR_SETTINGS_ROW_SIDE_PADDING;+ let settings_row_y = (settings_footer_y + SIDEBAR_SETTINGS_ROW_TOP_PADDING)+ .saturating_sub(SIDEBAR_SETTINGS_ROW_LIFT);+ let settings_row_width =+ item_width.saturating_sub(SIDEBAR_SETTINGS_ROW_SIDE_PADDING * 2);+ let settings_row_height = settings_footer_height+ .saturating_sub(+ SIDEBAR_SETTINGS_ROW_TOP_PADDING + SIDEBAR_SETTINGS_ROW_BOTTOM_PADDING,+ ).max(1);+ let settings_action_size = settings_row_height.max(1);+ let settings_action_x = settings_row_x+ .saturating_add(settings_row_width)+ .saturating_sub(settings_action_size);+ let settings_action_y = settings_row_y;+ let settings_body_width = settings_action_x+ .saturating_sub(settings_row_x)+ .saturating_sub(SIDEBAR_INSET / 2);let settings_hovered = self.is_pointer_over_ui_rect(settings_row_x,settings_row_y,- settings_row_width,+ settings_body_width,settings_row_height,);+ let settings_options_hovered = self.is_pointer_over_ui_rect(+ settings_action_x,+ settings_action_y,+ settings_action_size,+ settings_action_size,+ );if settings_hovered {self.fill_rounded_rectangle(layers,@@ -1142,7 +1311,7 @@ impl crate::TermWindow {euclid::rect(settings_row_x as f32,settings_row_y as f32,- settings_row_width as f32,+ settings_body_width as f32,settings_row_height as f32,),foreground.mul_alpha(0.10),@@ -1153,15 +1322,37 @@ impl crate::TermWindow {self.ui_items.push(UIItem {x: settings_row_x,y: settings_row_y,- width: settings_row_width,+ width: settings_body_width,height: settings_row_height,item_type: UIItemType::WorkspaceSidebarSettings,});+ if settings_options_hovered {+ self.fill_rounded_rectangle(+ layers,+ 2,+ euclid::rect(+ settings_action_x as f32,+ settings_action_y as f32,+ settings_action_size as f32,+ settings_action_size as f32,+ ),+ foreground.mul_alpha(0.12),+ SIDEBAR_ROW_RADIUS + 4.0,+ )+ .context("sidebar settings view options hover")?;+ }+ self.ui_items.push(UIItem {+ x: settings_action_x,+ y: settings_action_y,+ width: settings_action_size,+ height: settings_action_size,+ item_type: UIItemType::WorkspaceSidebarViewOptions,+ });let settings_icon_size = icon_size.min(settings_row_height.saturating_sub(8));- let settings_icon_x = settings_row_x + SIDEBAR_INSET + 2;+ let settings_icon_x = settings_row_x + SIDEBAR_SETTINGS_ICON_EXTRA_INSET;let settings_icon_y =settings_row_y + ((settings_row_height.saturating_sub(settings_icon_size)) / 2);- let settings_text_x = settings_icon_x + settings_icon_size + SIDEBAR_ICON_GAP + 4;+ let settings_text_x = settings_icon_x + settings_icon_size + SIDEBAR_ICON_GAP + 8;let settings_text_y =settings_row_y + ((settings_row_height.saturating_sub(ui_cell_height)) / 2);self.paint_sidebar_icon(@@ -1179,11 +1370,24 @@ impl crate::TermWindow {"Settings",settings_text_x,settings_text_y,- settings_row_x- .saturating_add(settings_row_width)- .saturating_sub(settings_text_x + SIDEBAR_INSET),+ settings_action_x.saturating_sub(settings_text_x + SIDEBAR_INSET),foreground,)?;+ let settings_action_icon_size = settings_icon_size;+ self.paint_sidebar_icon(+ layers,+ SvgIcon::SlidersVertical,+ settings_action_x+ + ((settings_action_size.saturating_sub(settings_action_icon_size)) / 2),+ settings_action_y+ + ((settings_action_size.saturating_sub(settings_action_icon_size)) / 2),+ settings_action_icon_size,+ if settings_options_hovered {+ foreground+ } else {+ muted_fg+ },+ )?;}if self.workspace_sidebar_scrollbar_visible() {diff --git a/wezterm-gui/src/termwindow/ui/status_icon.rs b/wezterm-gui/src/termwindow/ui/status_icon.rsnew file mode 100644index 00000000..459baa1f--- /dev/null+++ b/wezterm-gui/src/termwindow/ui/status_icon.rs@@ -0,0 +1,138 @@+use crate::quad::{QuadTrait, TripleLayerQuadAllocator, TripleLayerQuadAllocatorTrait};+use crate::termwindow::ui::icons::SvgIcon;+use crate::termwindow::TermWindow;+use anyhow::Context;+use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};+use wezterm_term::Progress;+use window::color::LinearRgba;++const SPINNER_FRAME_COUNT: u8 = 12;+const SPINNER_FRAME_MS: u64 = 80;++#[allow(dead_code)]+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub enum UiStatusKind {+ Running,+ NeedsAttention,+ Done,+}++impl UiStatusKind {+ pub fn from_progress(progress: &Progress) -> Option<Self> {+ match progress {+ Progress::None => None,+ Progress::Percentage(_) | Progress::Indeterminate => Some(Self::Running),+ Progress::Error(_) => Some(Self::NeedsAttention),+ }+ }++ pub fn icon(self) -> SvgIcon {+ match self {+ Self::Running => SvgIcon::LoaderCircle,+ Self::NeedsAttention => SvgIcon::CircleAlert,+ Self::Done => SvgIcon::CircleCheck,+ }+ }++ pub fn is_spinning(self) -> bool {+ matches!(self, Self::Running)+ }+}++impl TermWindow {+ pub(crate) fn paint_ui_icon(+ &self,+ layers: &mut TripleLayerQuadAllocator,+ layer: usize,+ icon: SvgIcon,+ x: usize,+ y: usize,+ size: usize,+ color: LinearRgba,+ ) -> anyhow::Result<()> {+ self.paint_ui_icon_impl(layers, layer, icon, x, y, size, color, None)+ }++ pub(crate) fn paint_spinning_ui_icon(+ &self,+ layers: &mut TripleLayerQuadAllocator,+ layer: usize,+ icon: SvgIcon,+ x: usize,+ y: usize,+ size: usize,+ color: LinearRgba,+ ) -> anyhow::Result<()> {+ let now = SystemTime::now()+ .duration_since(UNIX_EPOCH)+ .unwrap_or_default();+ let frame =+ ((now.as_millis() / SPINNER_FRAME_MS as u128) % SPINNER_FRAME_COUNT as u128) as u8;+ self.update_next_frame_time(Some(+ Instant::now() + Duration::from_millis(SPINNER_FRAME_MS),+ ));+ self.paint_ui_icon_impl(layers, layer, icon, x, y, size, color, Some(frame))+ }++ pub(crate) fn paint_status_icon(+ &self,+ layers: &mut TripleLayerQuadAllocator,+ layer: usize,+ status: UiStatusKind,+ x: usize,+ y: usize,+ size: usize,+ color: LinearRgba,+ ) -> anyhow::Result<()> {+ if status.is_spinning() {+ self.paint_spinning_ui_icon(layers, layer, status.icon(), x, y, size, color)+ } else {+ self.paint_ui_icon(layers, layer, status.icon(), x, y, size, color)+ }+ }++ fn paint_ui_icon_impl(+ &self,+ layers: &mut TripleLayerQuadAllocator,+ layer: usize,+ icon: SvgIcon,+ x: usize,+ y: usize,+ size: usize,+ color: LinearRgba,+ rotation_frame: Option<u8>,+ ) -> anyhow::Result<()> {+ let left_offset = self.dimensions.pixel_width as f32 / 2.0;+ let top_offset = self.dimensions.pixel_height as f32 / 2.0;+ let gl_state = self.render_state.as_ref().unwrap();+ let sprite = if let Some(frame) = rotation_frame {+ gl_state.glyph_cache.borrow_mut().cached_rotated_svg_icon(+ icon,+ size,+ frame,+ SPINNER_FRAME_COUNT,+ )?+ } else {+ gl_state+ .glyph_cache+ .borrow_mut()+ .cached_svg_icon(icon, size)?+ }+ .texture_coords();++ let mut quad = layers.allocate(layer).context("allocate ui icon quad")?;+ quad.set_position(+ x as f32 - left_offset,+ y as f32 - top_offset,+ x as f32 + size as f32 - left_offset,+ y as f32 + size as f32 - top_offset,+ );+ quad.set_texture(sprite);+ quad.set_fg_color(color);+ quad.set_alt_color_and_mix_value(color, 0.0);+ quad.set_hsv(None);+ quad.set_grayscale();++ Ok(())+ }+}diff --git a/wezterm-gui/src/termwindow/ui/tokens.rs b/wezterm-gui/src/termwindow/ui/tokens.rsindex 8e4af534..ec4be365 100644--- a/wezterm-gui/src/termwindow/ui/tokens.rs+++ b/wezterm-gui/src/termwindow/ui/tokens.rs@@ -1,5 +1,5 @@pub const SIDEBAR_WIDTH_CELLS: usize = 26;-pub const SIDEBAR_MIN_WIDTH: usize = 224;+pub const SIDEBAR_MIN_WIDTH: usize = 254;pub const SIDEBAR_MAX_WIDTH: usize = 520;pub const SIDEBAR_INSET: usize = 10;pub const SIDEBAR_ICON_GAP: usize = 10;diff --git a/wezterm-gui/src/ui/icons.rs b/wezterm-gui/src/ui/icons.rsindex e3486931..5a688e65 100644--- a/wezterm-gui/src/ui/icons.rs+++ b/wezterm-gui/src/ui/icons.rs@@ -9,6 +9,8 @@ pub(crate) enum SettingsIcon {Keymap,Sync,Developer,+ UiKit,+ Memory,About,Search,Clear,@@ -25,6 +27,8 @@ impl SettingsIcon {Self::Keymap => SvgIcon::Keyboard,Self::Sync => SvgIcon::Cloud,Self::Developer => SvgIcon::Settings,+ Self::UiKit => SvgIcon::SlidersVertical,+ Self::Memory => SvgIcon::MemoryStick,Self::About => SvgIcon::Info,Self::Search => SvgIcon::Search,Self::Clear => SvgIcon::X,diff --git a/window/src/lib.rs b/window/src/lib.rsindex 86513333..871ee3ad 100644--- a/window/src/lib.rs+++ b/window/src/lib.rs@@ -63,6 +63,9 @@ pub enum ContextMenuItem {label: String,icon: Option<String>,action: config::keyassignment::KeyAssignment,+ checked: bool,+ enabled: bool,+ submenu: Vec<ContextMenuItem>,},Separator,}@@ -73,6 +76,9 @@ impl ContextMenuItem {label: label.into(),icon: None,action,+ checked: false,+ enabled: true,+ submenu: vec![],}}@@ -85,6 +91,34 @@ impl ContextMenuItem {label: label.into(),icon: Some(icon.into()),action,+ checked: false,+ enabled: true,+ submenu: vec![],+ }+ }++ pub fn disabled(mut self) -> Self {+ if let Self::Item { enabled, .. } = &mut self {+ *enabled = false;+ }+ self+ }++ pub fn checked(mut self, checked_value: bool) -> Self {+ if let Self::Item { checked, .. } = &mut self {+ *checked = checked_value;+ }+ self+ }++ pub fn submenu(label: impl Into<String>, items: Vec<ContextMenuItem>) -> Self {+ Self::Item {+ label: label.into(),+ icon: None,+ action: config::keyassignment::KeyAssignment::Nop,+ checked: false,+ enabled: true,+ submenu: items,}}}@@ -402,6 +436,7 @@ pub struct RequestedWindowGeometry {pub height: Dimension,pub x: Option<Dimension>,pub y: Option<Dimension>,+ pub macos_frame_autosave_name: Option<String>,/// Specifies basis for evaluating x/y coords./// Also applies to width/height when computing % based dimensionspub origin: GeometryOrigin,diff --git a/window/src/os/macos/menu.rs b/window/src/os/macos/menu.rsindex fa9e0725..04e67652 100644--- a/window/src/os/macos/menu.rs+++ b/window/src/os/macos/menu.rs@@ -306,6 +306,20 @@ impl MenuItem {}}+ pub fn set_enabled(&self, enabled: bool) {+ unsafe {+ let enabled: BOOL = if enabled { YES } else { NO };+ let () = msg_send![*self.item, setEnabled: enabled];+ }+ }++ pub fn set_checked(&self, checked: bool) {+ unsafe {+ let state: NSInteger = if checked { 1 } else { 0 };+ let () = msg_send![*self.item, setState: state];+ }+ }+pub fn set_sub_menu(&self, menu: &Menu) {unsafe {self.item.setSubmenu_(*menu.menu);diff --git a/window/src/os/macos/window.rs b/window/src/os/macos/window.rsindex bf5712d7..e77f6654 100644--- a/window/src/os/macos/window.rs+++ b/window/src/os/macos/window.rs@@ -562,6 +562,7 @@ impl Window {};let conn = Connection::get().expect("new_window called on gui thread");+ let macos_frame_autosave_name = geometry.macos_frame_autosave_name.clone();let ResolvedGeometry {width,height,@@ -638,7 +639,15 @@ impl Window {// Prevent Cocoa native tabs from being usedlet _: () = msg_send![*window, setTabbingMode:2 /* NSWindowTabbingModeDisallowed */];- let _: () = msg_send![*window, setRestorable: NO];+ let restored_from_frame_autosave =+ if let Some(name) = macos_frame_autosave_name.as_deref() {+ let restored: BOOL = msg_send![*window, setFrameAutosaveName: *nsstring(name)];+ let _: () = msg_send![*window, setRestorable: YES];+ restored == YES+ } else {+ let _: () = msg_send![*window, setRestorable: NO];+ false+ };window.setReleasedWhenClosed_(NO);window.setBackgroundColor_(cocoa::appkit::NSColor::clearColor(nil));@@ -677,6 +686,9 @@ impl Window {}LAST_POSITION.with(|last_pos| {+ if restored_from_frame_autosave {+ return;+ }if let Some(pos) = initial_pos {// Put it where they asked it to be, without influencing// future positioning info@@ -1432,34 +1444,60 @@ impl WindowInner {return;}- let menu = Menu::new_with_title("");- let mut has_items = false;-- for item in items {- match item {- ContextMenuItem::Item {- label,- icon,- action,- } => {- let menu_item =- MenuItem::new_with(&label, Some(sel!(weztermPerformKeyAssignment:)), "");- if let Some(icon) = icon {- menu_item.set_system_symbol_image(&icon);+ fn add_context_menu_items(menu: &Menu, view: id, items: Vec<ContextMenuItem>) -> bool {+ let mut has_items = false;+ for item in items {+ match item {+ ContextMenuItem::Item {+ label,+ icon,+ action,+ checked,+ enabled,+ submenu,+ } => {+ let has_submenu = !submenu.is_empty();+ let menu_item = MenuItem::new_with(+ &label,+ if has_submenu {+ None+ } else {+ Some(sel!(weztermPerformKeyAssignment:))+ },+ "",+ );+ if let Some(icon) = icon {+ menu_item.set_system_symbol_image(&icon);+ }+ menu_item.set_checked(checked);+ menu_item.set_enabled(enabled);+ if has_submenu {+ let child_menu = Menu::new_with_title(&label);+ if add_context_menu_items(&child_menu, view, submenu) {+ menu_item.set_sub_menu(&child_menu);+ menu.add_item(&menu_item);+ has_items = true;+ }+ } else {+ menu_item.set_target(view);+ menu_item.set_represented_item(RepresentedItem::KeyAssignment(action));+ menu.add_item(&menu_item);+ has_items = true;+ }}- menu_item.set_target(*self.view);- menu_item.set_represented_item(RepresentedItem::KeyAssignment(action));- menu.add_item(&menu_item);- has_items = true;- }- ContextMenuItem::Separator => {- if has_items {- menu.add_item(&MenuItem::new_separator());+ ContextMenuItem::Separator => {+ if has_items {+ menu.add_item(&MenuItem::new_separator());+ }}}}+ has_items}+ let menu = Menu::new_with_title("");+ let has_items = add_context_menu_items(&menu, *self.view, items);+if !has_items {return;}