A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.
Rust agentagent-orchestrationaiai-agentsclaude-codecodexcoding-agentlinuxmacosmultiplayermultiplexerrustterminalterminal-emulatorterminal-multiplexertmuxtuiweztermwindows
feat(gui): pick an icon for each remote host
RoversXf9c88b30a450
diff --git a/thinkterm-core/src/ssh_hosts.rs b/thinkterm-core/src/ssh_hosts.rsindex d540c5f6..7deaee6d 100644--- a/thinkterm-core/src/ssh_hosts.rs+++ b/thinkterm-core/src/ssh_hosts.rs@@ -32,6 +32,72 @@ impl SshNetwork {}}+/// The picture a host is shown by where servers are listed, such as the+/// Space menu: what kind of machine it is, picked by the person.+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]+pub enum HostIcon {+ Server,+ Cloud,+ Globe,+ Laptop,+ MacMini,+ Desktop,+ /// A small board: a Raspberry Pi and the like.+ Chip,+ Container,+}++impl HostIcon {+ /// Every icon, in the order the picker offers them.+ pub const ALL: [HostIcon; 8] = [+ Self::Server,+ Self::Cloud,+ Self::Globe,+ Self::Laptop,+ Self::MacMini,+ Self::Desktop,+ Self::Chip,+ Self::Container,+ ];++ pub fn as_str(self) -> &'static str {+ match self {+ Self::Server => "server",+ Self::Cloud => "cloud",+ Self::Globe => "globe",+ Self::Laptop => "laptop",+ Self::MacMini => "mac_mini",+ Self::Desktop => "desktop",+ Self::Chip => "chip",+ Self::Container => "container",+ }+ }++ pub fn from_name(name: &str) -> Option<Self> {+ Self::ALL.into_iter().find(|icon| icon.as_str() == name)+ }+}++/// `SshHostSpec::icon` as written: by name, so that one a newer version+/// added reads back as no icon rather than failing the whole host list.+mod host_icon_serde {+ use super::HostIcon;+ use serde::{Deserialize, Deserializer, Serializer};++ pub fn serialize<S: Serializer>(icon: &Option<HostIcon>, s: S) -> Result<S::Ok, S::Error> {+ match icon {+ Some(icon) => s.serialize_some(icon.as_str()),+ None => s.serialize_none(),+ }+ }++ pub fn deserialize<'de, D: Deserializer<'de>>(d: D) -> Result<Option<HostIcon>, D::Error> {+ Ok(Option::<String>::deserialize(d)?+ .as_deref()+ .and_then(HostIcon::from_name))+ }+}+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]pub struct SshHostSpec {pub label: String,@@ -90,6 +156,13 @@ pub struct SshHostSpec {/// Connect.#[serde(default)]pub files_auto_connect: bool,+ /// The kind of machine it is, as picked; none shows the plain server.+ #[serde(+ default,+ with = "host_icon_serde",+ skip_serializing_if = "Option::is_none"+ )]+ pub icon: Option<HostIcon>,}/// Why setting a host's shell integration up failed.@@ -229,6 +302,7 @@ pub fn parse_system_ssh_config(content: &str) -> Vec<SshHostEntry> {shell_integration_unsupported: None,shell_integration_failure: None,files_auto_connect: false,+ icon: None,},});}@@ -478,6 +552,25 @@ mod tests {);}+ #[test]+ fn host_icon_round_trips_and_an_unknown_one_reads_as_none() {+ let mut spec: SshHostSpec =+ serde_json::from_str(r#"{"label":"server-a","host":"example.test"}"#).unwrap();+ assert_eq!(spec.icon, None);+ assert!(!serde_json::to_string(&spec).unwrap().contains("icon"));++ spec.icon = Some(HostIcon::MacMini);+ let saved = serde_json::to_string(&spec).unwrap();+ assert!(saved.contains(r#""icon":"mac_mini""#), "{}", saved);+ assert_eq!(+ serde_json::from_str::<SshHostSpec>(&saved).unwrap().icon,+ Some(HostIcon::MacMini)+ );++ let newer = r#"{"label":"server-a","host":"example.test","icon":"toaster"}"#;+ assert_eq!(serde_json::from_str::<SshHostSpec>(newer).unwrap().icon, None);+ }+#[test]fn explicit_default_port_keeps_the_legacy_domain_name() {let spec = SshHostSpec {@@ -501,6 +594,7 @@ mod tests {shell_integration_unsupported: None,shell_integration_failure: None,files_auto_connect: false,+ icon: None,};assert_eq!(ssh_domain_name(&spec), "ssh:[email protected]");assert_eq!(build_ssh_domain(&spec).remote_address, "example.test:22");diff --git a/thinkterm-i18n/i18n/de-DE.ftl b/thinkterm-i18n/i18n/de-DE.ftlindex 71b9c8ff..c58f5d91 100644--- a/thinkterm-i18n/i18n/de-DE.ftl+++ b/thinkterm-i18n/i18n/de-DE.ftl@@ -630,6 +630,15 @@ ssh-field-name = Namessh-field-network = Netzwerkssh-network-system = Systemssh-network-tailnet = Internes Tailnet+ssh-field-icon = Symbol+ssh-icon-server = Server+ssh-icon-cloud = Cloud+ssh-icon-globe = Globus+ssh-icon-laptop = Laptop+ssh-icon-mac-mini = Mac mini+ssh-icon-desktop = Desktop-PC+ssh-icon-chip = Einplatinencomputer+ssh-icon-container = Containerssh-network-tailnet-off = Schalten Sie auf dieser Seite Tailscale ein, um das interne Tailnet zu verwenden.ssh-network-tailnet-unavailable = Das interne Tailnet ist auf diesem System nicht verfügbar.ssh-error-tailnet-mosh = Mosh verwendet das Systemnetzwerk. Wählen Sie SSH oder ThinkTerm Connect, bevor Sie das interne Tailnet auswählen.diff --git a/thinkterm-i18n/i18n/en-US.ftl b/thinkterm-i18n/i18n/en-US.ftlindex f734f46e..1d490fc7 100644--- a/thinkterm-i18n/i18n/en-US.ftl+++ b/thinkterm-i18n/i18n/en-US.ftl@@ -630,6 +630,15 @@ ssh-field-name = Namessh-field-network = Networkssh-network-system = Systemssh-network-tailnet = Built-in Tailnet+ssh-field-icon = Icon+ssh-icon-server = Server+ssh-icon-cloud = Cloud+ssh-icon-globe = Globe+ssh-icon-laptop = Laptop+ssh-icon-mac-mini = Mac mini+ssh-icon-desktop = Desktop+ssh-icon-chip = Single-Board Computer+ssh-icon-container = Containerssh-network-tailnet-off = Turn on Tailscale on this page to use the built-in Tailnet.ssh-network-tailnet-unavailable = The built-in Tailnet isn't available on this system.ssh-error-tailnet-mosh = Mosh uses the system network. Choose SSH or ThinkTerm Connect before selecting the built-in Tailnet.diff --git a/thinkterm-i18n/i18n/fr-FR.ftl b/thinkterm-i18n/i18n/fr-FR.ftlindex 0f816eb7..96c518af 100644--- a/thinkterm-i18n/i18n/fr-FR.ftl+++ b/thinkterm-i18n/i18n/fr-FR.ftl@@ -630,6 +630,15 @@ ssh-field-name = Nomssh-field-network = Réseaussh-network-system = Systèmessh-network-tailnet = Tailnet intégré+ssh-field-icon = Icône+ssh-icon-server = Serveur+ssh-icon-cloud = Cloud+ssh-icon-globe = Globe+ssh-icon-laptop = Ordinateur portable+ssh-icon-mac-mini = Mac mini+ssh-icon-desktop = Ordinateur de bureau+ssh-icon-chip = Ordinateur monocarte+ssh-icon-container = Conteneurssh-network-tailnet-off = Activez Tailscale sur cette page pour utiliser le Tailnet intégré.ssh-network-tailnet-unavailable = Le Tailnet intégré n'est pas disponible sur ce système.ssh-error-tailnet-mosh = Mosh utilise le réseau du système. Choisissez SSH ou ThinkTerm Connect avant de sélectionner le Tailnet intégré.diff --git a/thinkterm-i18n/i18n/ja-JP.ftl b/thinkterm-i18n/i18n/ja-JP.ftlindex 74efbeb7..82b6096d 100644--- a/thinkterm-i18n/i18n/ja-JP.ftl+++ b/thinkterm-i18n/i18n/ja-JP.ftl@@ -615,6 +615,15 @@ ssh-field-name = 名前ssh-field-network = ネットワークssh-network-system = システムssh-network-tailnet = 内蔵 Tailnet+ssh-field-icon = アイコン+ssh-icon-server = サーバ+ssh-icon-cloud = クラウド+ssh-icon-globe = 地球+ssh-icon-laptop = ノートパソコン+ssh-icon-mac-mini = Mac mini+ssh-icon-desktop = デスクトップ+ssh-icon-chip = シングルボードコンピュータ+ssh-icon-container = コンテナssh-network-tailnet-off = 内蔵 Tailnet を使うには、このページで Tailscale をオンにしてください。ssh-network-tailnet-unavailable = このシステムでは内蔵 Tailnet を使用できません。ssh-error-tailnet-mosh = Mosh はシステムのネットワークを使用します。内蔵 Tailnet を選ぶ前に、接続方法を SSH か ThinkTerm Connect にしてください。diff --git a/thinkterm-i18n/i18n/ru-RU.ftl b/thinkterm-i18n/i18n/ru-RU.ftlindex fc8929ed..f110b993 100644--- a/thinkterm-i18n/i18n/ru-RU.ftl+++ b/thinkterm-i18n/i18n/ru-RU.ftl@@ -613,6 +613,15 @@ ssh-field-name = Названиеssh-field-network = Сетьssh-network-system = Системнаяssh-network-tailnet = Встроенная Tailnet+ssh-field-icon = Значок+ssh-icon-server = Сервер+ssh-icon-cloud = Облако+ssh-icon-globe = Глобус+ssh-icon-laptop = Ноутбук+ssh-icon-mac-mini = Mac mini+ssh-icon-desktop = Настольный компьютер+ssh-icon-chip = Одноплатный компьютер+ssh-icon-container = Контейнерssh-network-tailnet-off = Включите Tailscale на этой странице для использования встроенной Tailnet.ssh-network-tailnet-unavailable = Встроенная Tailnet недоступна в этой системе.ssh-error-tailnet-mosh = Mosh использует системную сеть. Выберите SSH или ThinkTerm Connect перед выбором встроенной Tailnet.diff --git a/thinkterm-i18n/i18n/zh-CN.ftl b/thinkterm-i18n/i18n/zh-CN.ftlindex aa90da3f..d2311adf 100644--- a/thinkterm-i18n/i18n/zh-CN.ftl+++ b/thinkterm-i18n/i18n/zh-CN.ftl@@ -615,6 +615,15 @@ ssh-field-name = 名称ssh-field-network = 网络ssh-network-system = 系统ssh-network-tailnet = 内置 Tailnet+ssh-field-icon = 图标+ssh-icon-server = 服务器+ssh-icon-cloud = 云+ssh-icon-globe = 地球+ssh-icon-laptop = 笔记本电脑+ssh-icon-mac-mini = Mac mini+ssh-icon-desktop = 台式机+ssh-icon-chip = 单板机+ssh-icon-container = 容器ssh-network-tailnet-off = 在本页打开 Tailscale 后才能使用内置 Tailnet。ssh-network-tailnet-unavailable = 这个系统上不支持内置 Tailnet。ssh-error-tailnet-mosh = Mosh 使用系统网络。选择内置 Tailnet 前,请先把连接方式换成 SSH 或 ThinkTerm Connect。diff --git a/wezterm-gui/src/ssh_hosts.rs b/wezterm-gui/src/ssh_hosts.rsindex aa63fb57..c0af03c4 100644--- a/wezterm-gui/src/ssh_hosts.rs+++ b/wezterm-gui/src/ssh_hosts.rs@@ -23,8 +23,8 @@ use std::sync::Arc;use wezterm_ssh::{Session, SessionEvent};pub use thinkterm_core::ssh_hosts::{- default_mosh_server_command, parse_other_addresses, ShellIntegrationFailure, SshHostEntry,- SshHostId, SshHostSource, SshHostSpec, SshNetwork, DEFAULT_MOSH_SERVER_COMMAND,+ default_mosh_server_command, parse_other_addresses, HostIcon, ShellIntegrationFailure,+ SshHostEntry, SshHostId, SshHostSource, SshHostSpec, SshNetwork, DEFAULT_MOSH_SERVER_COMMAND,};#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]@@ -782,6 +782,50 @@ pub fn machine_label(domain_name: &str) -> String {connect_domain_label(domain_name)}+/// The icon picked for the host a ThinkTerm Connect domain belongs to,+/// matched as `host_for_connect_domain` matches it. Only a host saved here+/// has one.+pub fn connect_domain_icon(domain_name: &str) -> Option<HostIcon> {+ let store = host_store().ok()?;+ let hosts = &store.hosts;+ hosts+ .iter()+ .find(|record| connect_domain_name(&record.spec) == domain_name)+ .or_else(|| hosts.iter().find(|record| record.id == domain_name))+ .or_else(|| hosts.iter().find(|record| record.spec.label == domain_name))+ .and_then(|record| record.spec.icon)+}++/// How a host with `icon` is drawn in a menu: the plain server when none+/// was picked.+pub fn host_menu_icon(icon: Option<HostIcon>) -> window::ContextMenuIcon {+ use window::ContextMenuIcon;+ match icon {+ None | Some(HostIcon::Server) => ContextMenuIcon::Server,+ Some(HostIcon::Cloud) => ContextMenuIcon::Cloud,+ Some(HostIcon::Globe) => ContextMenuIcon::Globe,+ Some(HostIcon::Laptop) => ContextMenuIcon::Laptop,+ Some(HostIcon::MacMini) => ContextMenuIcon::MacMini,+ Some(HostIcon::Desktop) => ContextMenuIcon::Desktop,+ Some(HostIcon::Chip) => ContextMenuIcon::Chip,+ Some(HostIcon::Container) => ContextMenuIcon::Container,+ }+}++/// What `icon` is called where it is picked.+pub fn host_icon_name(icon: HostIcon) -> String {+ crate::i18n::tr(match icon {+ HostIcon::Server => "ssh-icon-server",+ HostIcon::Cloud => "ssh-icon-cloud",+ HostIcon::Globe => "ssh-icon-globe",+ HostIcon::Laptop => "ssh-icon-laptop",+ HostIcon::MacMini => "ssh-icon-mac-mini",+ HostIcon::Desktop => "ssh-icon-desktop",+ HostIcon::Chip => "ssh-icon-chip",+ HostIcon::Container => "ssh-icon-container",+ })+}+fn label_for_connect_domain<'a>(mut specs: impl Iterator<Item = &'a SshHostSpec>,domain_name: &str,@@ -1075,6 +1119,7 @@ fn parse_system_ssh_config_str(content: &str) -> Vec<SshHostEntry> {shell_integration_unsupported: None,shell_integration_failure: None,files_auto_connect: false,+ icon: None,};out.push(SshHostEntry {id: system_host_id(&alias),@@ -1558,6 +1603,7 @@ Host prod *.internalshell_integration_unsupported: None,shell_integration_failure: None,files_auto_connect: false,+ icon: None,}}diff --git a/wezterm-gui/src/termwindow/content_view.rs b/wezterm-gui/src/termwindow/content_view.rsindex 143ae6bd..d7a4242c 100644--- a/wezterm-gui/src/termwindow/content_view.rs+++ b/wezterm-gui/src/termwindow/content_view.rs@@ -598,6 +598,9 @@ pub(crate) enum RemoteHostCommand {Edit,Duplicate,Delete,+ /// The icon picked in the form's icon menu, for the host the form edits+ /// (an empty id: the new one it is making).+ SetIcon(crate::ssh_hosts::HostIcon),}pub(crate) trait ContentView {diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rsindex f38dedb3..5ae70f1a 100644--- a/wezterm-gui/src/termwindow/mod.rs+++ b/wezterm-gui/src/termwindow/mod.rs@@ -9287,6 +9287,42 @@ impl TermWindow {self.show_term_context_menu(&window, euclid::point2(x as isize, y as isize), items);}+ /// The icon menu of the Remote Hosts form, at `x`, `y`: every kind of+ /// machine a host can be shown as, `current` ticked. `host_id` is the+ /// host the form edits, empty for a new one.+ pub(crate) fn show_remote_host_icon_menu(+ &mut self,+ host_id: String,+ current: Option<crate::ssh_hosts::HostIcon>,+ x: f32,+ y: f32,+ ) {+ use crate::ssh_hosts::HostIcon;+ use crate::termwindow::content_view::RemoteHostCommand;+ let Some(window) = self.window.as_ref().cloned() else {+ return;+ };+ self.begin_context_menu_application_actions();+ let current = current.unwrap_or(HostIcon::Server);+ let items = HostIcon::ALL+ .iter()+ .copied()+ .map(|icon| {+ self.context_menu_application_item_with_icon(+ crate::ssh_hosts::host_icon_name(icon),+ crate::ssh_hosts::host_menu_icon(Some(icon)),+ ContextMenuApplicationAction::RemoteHost {+ host_id: host_id.clone(),+ command: RemoteHostCommand::SetIcon(icon),+ },+ true,+ )+ .checked(icon == current)+ })+ .collect();+ self.show_term_context_menu(&window, euclid::point2(x as isize, y as isize), items);+ }+/// Open the SSH hosts page on a blank host form. Unlike/// `toggle_ssh_hosts_view` this never closes an open page: it is reached/// from a menu entry worded as an action, and an action that sometimesdiff --git a/wezterm-gui/src/termwindow/mouseevent.rs b/wezterm-gui/src/termwindow/mouseevent.rsindex 39dc82df..3dd7db97 100644--- a/wezterm-gui/src/termwindow/mouseevent.rs+++ b/wezterm-gui/src/termwindow/mouseevent.rs@@ -176,16 +176,17 @@ pub(crate) fn space_destructive_menu_items(/// A server's row in the one-row-per-server Space menu: a server with one/// Space switches to it from the row itself; one with several opens them,-/// and a new one, in a submenu.+/// and a new one, in a submenu. `icon` is the one picked for the host.fn server_menu_row(label: String,domain: &str,+ icon: ContextMenuIcon,spaces: &[&crate::workspace_threads::SpaceView],) -> ContextMenuItem {if let [space] = spaces {let item = ContextMenuItem::item_with_icon(label,- ContextMenuIcon::Server,+ icon,KeyAssignment::SwitchSpace(space.id.to_string()),);return if space.is_occupied_by_other_window {@@ -219,21 +220,21 @@ fn server_menu_row(ContextMenuIcon::New,KeyAssignment::CreateSpaceOnDomain(domain.to_string()),));- ContextMenuItem::submenu_with_icon(label, ContextMenuIcon::Server, children)+ ContextMenuItem::submenu_with_icon(label, icon, children)}-/// "New Space on Server": one row per server, (label, mux domain), each-/// making a Space there.-fn new_space_on_server_menu(servers: Vec<(String, String)>) -> ContextMenuItem {+/// "New Space on Server": one row per server, (label, mux domain, icon),+/// each making a Space there.+fn new_space_on_server_menu(servers: Vec<(String, String, ContextMenuIcon)>) -> ContextMenuItem {ContextMenuItem::submenu_with_icon(crate::i18n::tr("menu-new-space-on-server"),ContextMenuIcon::Server,servers.into_iter()- .map(|(label, domain)| {+ .map(|(label, domain, icon)| {ContextMenuItem::item_with_icon(label,- ContextMenuIcon::Server,+ icon,KeyAssignment::CreateSpaceOnDomain(domain),)})@@ -241,6 +242,16 @@ fn new_space_on_server_menu(servers: Vec<(String, String)>) -> ContextMenuItem {)}+/// Servers folded to one row each, connected ones first, then those on+/// their way, then the rest; in their own order within each.+fn order_servers_by_connection<T>(servers: &mut [(T, SpaceConnectionState)]) {+ servers.sort_by_key(|(_, state)| match state {+ SpaceConnectionState::Connected => 0,+ SpaceConnectionState::Connecting | SpaceConnectionState::Reconnecting => 1,+ SpaceConnectionState::Disconnected => 2,+ });+}+fn note_drag_scroll_delta(pointer_y: f32,top: f32,@@ -6448,7 +6459,7 @@ impl super::TermWindow {self.begin_context_menu_application_actions();let spaces = crate::workspace_threads::spaces_for_window(self.space_owner_id);- let space_item = |space: &crate::workspace_threads::SpaceView| {+ let space_item = |space: &crate::workspace_threads::SpaceView, icon: Option<ContextMenuIcon>| {let label = if space.is_occupied_by_other_window {tr_with_name("menu-space-occupied", &space.name)} else {@@ -6459,7 +6470,7 @@ impl super::TermWindow {if space.is_default {ContextMenuIcon::Home} else {- ContextMenuIcon::Stack+ icon.unwrap_or(ContextMenuIcon::Stack)},KeyAssignment::SwitchSpace(space.id.to_string()),)@@ -6472,7 +6483,7 @@ impl super::TermWindow {let mut items = vec![];for space in spaces.iter().filter(|space| space.domain.is_none()) {- items.push(space_item(space));+ items.push(space_item(space, None));}// While servers show as folders their Spaces are not listed: they// live in a local Space's sidebar. One opened from its folder stays@@ -6485,31 +6496,39 @@ impl super::TermWindow {items.push(ContextMenuItem::item_with_icon(space.name.clone(),- ContextMenuIcon::Server,+ crate::ssh_hosts::host_menu_icon(+ space+ .domain+ .as_deref()+ .and_then(crate::ssh_hosts::connect_domain_icon),+ ),KeyAssignment::SwitchSpace(space.id.to_string()),).checked(true),);}- // Keep the servers in the order their Spaces appear rather than- // sorting: that order is the user's.- let mut domains: Vec<&str> = vec![];- for domain in spaces- .iter()- .filter(|space| !space.shown_as_folders)- .filter_map(|space| space.domain.as_deref())- {- if !domains.contains(&domain) {- domains.push(domain);+ // Keep the servers in the order their Spaces appear: that order is+ // the user's.+ let mut domains: Vec<(&str, SpaceConnectionState)> = vec![];+ for space in spaces.iter().filter(|space| !space.shown_as_folders) {+ let Some(domain) = space.domain.as_deref() else {+ continue;+ };+ if !domains.iter().any(|(known, _)| *known == domain) {+ domains.push((domain, self.space_connection_state(&space.id)));}}// Folded to one row each, servers sit together; the one the window// is on stays spelled out, so moving between its Spaces is one click.+ // Those connected come first there: they are the ones in use.let one_row = crate::native_settings::space_menu_one_row_per_server();+ if one_row {+ order_servers_by_connection(&mut domains);+ }let mut last_was_row = false;- for domain in domains.iter().copied() {+ for (domain, state) in domains.iter().copied() {let here: Vec<&crate::workspace_threads::SpaceView> = spaces.iter().filter(|space| space.domain.as_deref() == Some(domain))@@ -6519,11 +6538,8 @@ impl super::TermWindow {items.push(ContextMenuItem::Separator);}last_was_row = collapsed;- let state = spaces- .iter()- .find(|space| space.domain.as_deref() == Some(domain))- .map(|space| self.space_connection_state(&space.id))- .unwrap_or(SpaceConnectionState::Connected);+ let icon =+ crate::ssh_hosts::host_menu_icon(crate::ssh_hosts::connect_domain_icon(domain));// The host's own name: one on the embedded tailnet is connected// under its address.let name = crate::ssh_hosts::connect_domain_label(domain);@@ -6543,7 +6559,7 @@ impl super::TermWindow {}};if collapsed {- items.push(server_menu_row(header, domain, &here));+ items.push(server_menu_row(header, domain, icon, &here));continue;}// A server is a heading, not something to switch to. Saying that@@ -6551,11 +6567,9 @@ impl super::TermWindow {// *look* like a heading: the platform styles it as a caption and// never highlights it under the pointer.items.push(ContextMenuItem::section_header(header));- for space in spaces- .iter()- .filter(|space| space.domain.as_deref() == Some(domain))- {- items.push(space_item(space));+ // A heading has no icon, so the server's Spaces carry it.+ for space in here.iter().copied() {+ items.push(space_item(space, Some(icon)));}items.push(ContextMenuItem::item_with_icon(crate::i18n::tr("menu-new-space-here"),@@ -6587,10 +6601,13 @@ impl super::TermWindow {items.push(new_space_on_server_menu(domains.iter()- .map(|domain| {+ .map(|(domain, _)| {(crate::ssh_hosts::connect_domain_label(domain),domain.to_string(),+ crate::ssh_hosts::host_menu_icon(+ crate::ssh_hosts::connect_domain_icon(domain),+ ),)}).collect(),@@ -10637,9 +10654,11 @@ mod sidebar_drag_tests {#[cfg(test)]mod space_menu_tests {use super::space_destructive_menu_items;+ use crate::termwindow::ui::sidebar::SpaceConnectionState;use crate::workspace_threads::SpaceView;use config::keyassignment::KeyAssignment;use window::ContextMenuAction;+ use window::ContextMenuIcon;use window::ContextMenuItem;fn space(is_remote: bool) -> SpaceView {@@ -10711,7 +10730,7 @@ mod space_menu_tests {#[test]fn a_server_with_one_space_switches_from_its_row() {let only = server_space("s1", false);- let row = super::server_menu_row("devbox".to_string(), "devbox", &[&only]);+ let row = super::server_menu_row("devbox".to_string(), "devbox", ContextMenuIcon::Server, &[&only]);assert!(submenu_of(&row).is_empty());assert_eq!(action(&row), KeyAssignment::SwitchSpace("s1".to_string()));}@@ -10720,7 +10739,7 @@ mod space_menu_tests {#[test]fn a_server_with_several_spaces_opens_them_from_its_row() {let (first, second) = (server_space("s1", false), server_space("s2", false));- let row = super::server_menu_row("devbox".to_string(), "devbox", &[&first, &second]);+ let row = super::server_menu_row("devbox".to_string(), "devbox", ContextMenuIcon::Server, &[&first, &second]);let children = submenu_of(&row);assert_eq!(children.len(), 4);assert!(matches!(children[2], ContextMenuItem::Separator));@@ -10739,15 +10758,23 @@ mod space_menu_tests {#[test]fn a_server_whose_only_space_is_open_elsewhere_is_greyed() {let only = server_space("s1", true);- let row = super::server_menu_row("devbox".to_string(), "devbox", &[&only]);+ let row = super::server_menu_row("devbox".to_string(), "devbox", ContextMenuIcon::Server, &[&only]);assert!(matches!(row, ContextMenuItem::Item { enabled: false, .. }));}#[test]fn new_space_on_server_offers_every_server() {let menu = super::new_space_on_server_menu(vec![- ("devbox".to_string(), "devbox".to_string()),- ("server-b".to_string(), "server-b".to_string()),+ (+ "devbox".to_string(),+ "devbox".to_string(),+ ContextMenuIcon::Server,+ ),+ (+ "server-b".to_string(),+ "server-b".to_string(),+ ContextMenuIcon::Cloud,+ ),]);assert_eq!(actions(submenu_of(&menu)),@@ -10758,6 +10785,26 @@ mod space_menu_tests {);}+ /// Connected servers come first, then those on their way, then the+ /// rest, each keeping the order it had.+ #[test]+ fn servers_folded_to_rows_put_connected_ones_first() {+ use SpaceConnectionState::*;+ let mut servers = vec![+ ("a", Disconnected),+ ("b", Connected),+ ("c", Reconnecting),+ ("d", Disconnected),+ ("e", Connected),+ ("f", Connecting),+ ];+ super::order_servers_by_connection(&mut servers);+ assert_eq!(+ servers.iter().map(|(name, _)| *name).collect::<Vec<_>>(),+ ["b", "e", "c", "f", "a", "d"]+ );+ }+/// The four lines that prompted this: one parent row carrying the name,/// with the actions underneath.#[test]diff --git a/wezterm-gui/src/termwindow/ssh_hosts_view.rs b/wezterm-gui/src/termwindow/ssh_hosts_view.rsindex 1d2a3b38..f27fec13 100644--- a/wezterm-gui/src/termwindow/ssh_hosts_view.rs+++ b/wezterm-gui/src/termwindow/ssh_hosts_view.rs@@ -8,7 +8,7 @@use crate::quad::{HeapQuadAllocator, QuadClipRect, TripleLayerQuadAllocator};use crate::ssh_hosts::{- self, ShellIntegrationFailure, SshHostEntry, SshHostSource, SshHostSpec, SshNetwork,+ self, HostIcon, ShellIntegrationFailure, SshHostEntry, SshHostSource, SshHostSpec, SshNetwork,};use crate::tailnet::{Device, Machine as TailnetMachine, State as TailnetState, View as TailnetView,@@ -212,6 +212,8 @@ enum SshViewAction {/// Connect to the host the inspector is showing.Connect,FocusField(usize),+ /// The icon button: a menu of the kinds of machine to show the host as.+ PickIcon,SetNetwork(SshNetwork),ToggleDetect,/// One of the three ways to reach the host.@@ -277,6 +279,7 @@ impl HostMode {/// `SshHostsView::save_choice`). What is typed waits for Save.#[derive(Debug, Clone, Copy, PartialEq, Eq)]enum HostChoice {+ Icon(Option<HostIcon>),Network(SshNetwork),Mode(HostMode),DetectOs(bool),@@ -288,6 +291,7 @@ impl HostChoice {/// Makes the choice on `spec`, as Save makes it from the form.fn apply_to(self, spec: &mut SshHostSpec) {match self {+ Self::Icon(icon) => spec.icon = icon,Self::Network(network) => spec.network = network,Self::Mode(mode) => {// Mosh and ThinkTerm Connect are alternative transports;@@ -308,6 +312,7 @@ impl HostChoice {/// could not be saved shows instead.fn show_saved(self, saved: &SshHostSpec, form: &mut HostForm) {match self {+ Self::Icon(_) => form.icon = saved.icon,Self::Network(_) => form.network = saved.network,Self::Mode(_) => {form.use_mosh = saved.use_mosh;@@ -457,6 +462,7 @@ struct HostForm {/// the user is still typing.options: Vec<(TextInputState, TextInputState)>,advanced_open: bool,+ icon: Option<HostIcon>,network: SshNetwork,detect_os: bool,use_mosh: bool,@@ -515,6 +521,8 @@ pub(crate) struct SshHostsView {form_content_h: f32,/// Bounds of the form column, remembered for wheel hit-testing.form_area: RectF,+ /// The icon button as last painted: where its menu opens.+ icon_button: RectF,widgets: UiContext<SshViewAction>,interaction: InteractionState<SshViewAction>,scroll: ScrollState,@@ -564,6 +572,7 @@ impl SshHostsView {form_scroll: ScrollState::new(),form_content_h: 0.0,form_area: rect(0.0, 0.0, 0.0, 0.0),+ icon_button: rect(0.0, 0.0, 0.0, 0.0),widgets: UiContext::default(),interaction: InteractionState::default(),scroll: ScrollState::new(),@@ -738,6 +747,7 @@ impl SshHostsView {input.set_text_end(text);input});+ let icon = spec.icon;let network = spec.network;let detect_os = spec.detect_os;let use_mosh = spec.use_mosh;@@ -762,6 +772,7 @@ impl SshHostsView {fields,options,advanced_open,+ icon,network,detect_os,use_mosh,@@ -840,10 +851,12 @@ impl SshHostsView {shell_integration_unsupported: None,shell_integration_failure: None,files_auto_connect: false,+ icon: None,});spec.label = label;spec.host = host;spec.port = port;+ spec.icon = form.icon;spec.network = form.network;spec.other_addresses =ssh_hosts::parse_other_addresses(&form.fields[FIELD_OTHER_ADDRESSES].text());@@ -1207,6 +1220,7 @@ impl SshHostsView {self.focus = Focus::Field(n.min(count - 1));ContentViewResponse::Redraw}+ SshViewAction::PickIcon => self.icon_menu(),SshViewAction::SetNetwork(network) => {let tailnet_on = self.tailnet_on;if let Some(form) = self.form.as_mut() {@@ -1512,6 +1526,7 @@ impl SshHostsView {form.multiplexing = spec.multiplexing;form.shell_integration = spec.shell_integration;form.files_auto_connect = spec.files_auto_connect;+ form.icon = spec.icon;form.options = spec.ssh_options.iter()@@ -1539,7 +1554,38 @@ impl SshHostsView {}RemoteHostCommand::Duplicate => self.duplicate_host(host_id),RemoteHostCommand::Delete => self.delete_host(host_id),+ RemoteHostCommand::SetIcon(icon) => self.set_form_icon(host_id, icon),+ }+ }++ /// The icon button's menu, under the button. The page cannot open a+ /// menu itself, as for a card's.+ fn icon_menu(&mut self) -> ContentViewResponse {+ let Some(form) = self.form.as_ref() else {+ return ContentViewResponse::Redraw;+ };+ let host_id = form.editing.clone().unwrap_or_default();+ let current = form.icon;+ let (x, y) = (self.icon_button.origin.x, self.icon_button.max_y());+ ContentViewResponse::Run(Box::new(move |term_window| {+ term_window.show_remote_host_icon_menu(host_id, current, x, y);+ }))+ }++ /// `icon`, picked in the icon menu, on the form for `host_id` (empty+ /// for a new host) if that form is still the one open. The plain server+ /// is what no icon shows, so picking it saves none.+ fn set_form_icon(&mut self, host_id: &str, icon: HostIcon) -> ContentViewResponse {+ let Some(form) = self.form.as_mut() else {+ return ContentViewResponse::Redraw;+ };+ if form.editing.as_deref().unwrap_or("") != host_id {+ return ContentViewResponse::Redraw;}+ let icon = (icon != HostIcon::Server).then_some(icon);+ form.icon = icon;+ self.save_choice(HostChoice::Icon(icon));+ ContentViewResponse::Redraw}/// The card under the pointer, if any.@@ -3832,6 +3878,7 @@ impl SshHostsView {return Ok(());};let editing = form.editing.clone();+ let icon = form.icon;let network = form.network;let detect_os = form.detect_os;let use_mosh = form.use_mosh;@@ -4001,7 +4048,7 @@ impl SshHostsView {let conn_h = Self::inspector_card_height(ctx,section_h,- &[field_h, field_h + lock_note_h, field_h, field_h, field_h],+ &[field_h, field_h, field_h + lock_note_h, field_h, field_h, field_h],);let mut fy = Self::paint_inspector_card(ctx,@@ -4027,6 +4074,16 @@ impl SshHostsView {fy,inner,)? + gap;+ fy = self.paint_icon_row(+ ctx,+ &mut body_layers,+ font,+ palette,+ icon,+ x + pad,+ fy,+ inner,+ )? + gap;ctx.draw_text(&mut body_layers,font,@@ -4651,6 +4708,96 @@ impl SshHostsView {Ok(())}+ /// The icon row: its label, and a button showing the icon picked with+ /// its name, which opens the menu of them. Returns the y under it.+ #[allow(clippy::too_many_arguments)]+ fn paint_icon_row(+ &mut self,+ ctx: &DrawContext,+ layers: &mut TripleLayerQuadAllocator<'_>,+ font: &Rc<LoadedFont>,+ palette: UiPalette,+ icon: Option<HostIcon>,+ x: f32,+ y: f32,+ width: f32,+ ) -> anyhow::Result<f32> {+ let line_h = ctx.metrics.cell_size.height as f32;+ ctx.draw_text(+ layers,+ font,+ x,+ y,+ &crate::i18n::tr("ssh-field-icon"),+ palette.text,+ width,+ )?;+ let icon = icon.unwrap_or(HostIcon::Server);+ let glyph = match icon {+ HostIcon::Server => SvgIcon::Server,+ HostIcon::Cloud => SvgIcon::Cloud,+ HostIcon::Globe => SvgIcon::Globe,+ HostIcon::Laptop => SvgIcon::Laptop,+ HostIcon::MacMini => SvgIcon::HardDrive,+ HostIcon::Desktop => SvgIcon::Monitor,+ HostIcon::Chip => SvgIcon::Cpu,+ HostIcon::Container => SvgIcon::Package,+ };+ let label = ssh_hosts::host_icon_name(icon);+ let action = SshViewAction::PickIcon;+ let state = self.button_state(action);+ let variant = ButtonVariant::Secondary;+ let button = rect(+ x,+ y + line_h + ctx.px(LABEL_GAP),+ width,+ ctx.px(INPUT_H),+ );+ self.icon_button = button;+ draw_button(+ ctx,+ layers,+ font,+ &mut self.widgets,+ palette,+ ButtonSpec {+ label: "",+ action,+ rect: button,+ state,+ kind: WidgetKind::Button,+ variant,+ },+ )?;+ // Laid out as the system's pop-up button: the choice at the start,+ // the arrows at the end.+ let (_, _, ink) = variant.colors(state, palette);+ let size = ctx.px(16.0);+ let inset = ctx.px(14.0);+ let icon_y = button.origin.y + (button.size.height - size) / 2.0;+ ctx.draw_svg_icon(layers, glyph, button.origin.x + inset, icon_y, size, ink)?;+ let arrows_x = button.max_x() - inset - size;+ ctx.draw_svg_icon(+ layers,+ SvgIcon::ChevronsUpDown,+ arrows_x,+ icon_y,+ size,+ palette.muted_text,+ )?;+ let text_x = button.origin.x + inset + size + ctx.px(8.0);+ ctx.draw_text(+ layers,+ font,+ text_x,+ button.origin.y + ((button.size.height - line_h) / 2.0).max(0.0),+ &label,+ ink,+ (arrows_x - ctx.px(8.0) - text_x).max(0.0),+ )?;+ Ok(y + Self::field_row_height(ctx))+ }+/// Which of the three visual states a button is in. "Primary" is no/// longer one of them: that is the button's `variant`, and it is/// orthogonal to whether the pointer happens to be over it.@@ -6148,6 +6295,7 @@ mod tests {shell_integration_unsupported: None,shell_integration_failure: None,files_auto_connect: false,+ icon: None,}}@@ -6212,7 +6360,10 @@ mod tests {view.filtered = vec![SshHostEntry {id: "ssh-original".to_string(),source: SshHostSource::ThinkTerm,- spec: spec("prod-1", "10.0.0.7"),+ spec: SshHostSpec {+ icon: Some(crate::ssh_hosts::HostIcon::Cloud),+ ..spec("prod-1", "192.0.2.7")+ },}];view.password_visible = true;@@ -6236,6 +6387,7 @@ mod tests {// host it was copied from. Host is the one field left for the user.assert_eq!(form.fields[FIELD_HOST].text(), "");assert_eq!(view.focus, Focus::Field(FIELD_HOST));+ assert_eq!(form.icon, Some(crate::ssh_hosts::HostIcon::Cloud));}fn row(key: &str, value: &str) -> (super::TextInputState, super::TextInputState) {diff --git a/wezterm-gui/src/termwindow/ui/context_menu.rs b/wezterm-gui/src/termwindow/ui/context_menu.rsindex 0272e8fe..ae495d62 100644--- a/wezterm-gui/src/termwindow/ui/context_menu.rs+++ b/wezterm-gui/src/termwindow/ui/context_menu.rs@@ -1314,7 +1314,11 @@ fn menu_icon(icon: &ContextMenuIcon) -> Option<SvgIcon> {ContextMenuIcon::ArchiveRestore => Some(SvgIcon::ArchiveRestore),ContextMenuIcon::Back | ContextMenuIcon::MoveLeft => Some(SvgIcon::ArrowLeft),ContextMenuIcon::Check => Some(SvgIcon::CircleCheck),+ ContextMenuIcon::Chip => Some(SvgIcon::Cpu),ContextMenuIcon::Close => Some(SvgIcon::X),+ ContextMenuIcon::Cloud => Some(SvgIcon::Cloud),+ ContextMenuIcon::Container => Some(SvgIcon::Package),+ ContextMenuIcon::Desktop => Some(SvgIcon::Monitor),ContextMenuIcon::Code => Some(SvgIcon::CodeXml),ContextMenuIcon::Collapse => Some(SvgIcon::Shrink),ContextMenuIcon::Copy => Some(SvgIcon::Copy),@@ -1327,6 +1331,9 @@ fn menu_icon(icon: &ContextMenuIcon) -> Option<SvgIcon> {ContextMenuIcon::FolderAdd => Some(SvgIcon::FolderPlus),ContextMenuIcon::FolderRemove => Some(SvgIcon::FolderMinus),ContextMenuIcon::Filter => Some(SvgIcon::SlidersHorizontal),+ ContextMenuIcon::Globe => Some(SvgIcon::Globe),+ ContextMenuIcon::Laptop => Some(SvgIcon::Laptop),+ ContextMenuIcon::MacMini => Some(SvgIcon::HardDrive),ContextMenuIcon::Group => Some(SvgIcon::Layers),ContextMenuIcon::Home => Some(SvgIcon::House),ContextMenuIcon::Info => Some(SvgIcon::Info),diff --git a/wezterm-gui/src/termwindow/ui/icons.rs b/wezterm-gui/src/termwindow/ui/icons.rsindex 470ebe5c..7a901eab 100644--- a/wezterm-gui/src/termwindow/ui/icons.rs+++ b/wezterm-gui/src/termwindow/ui/icons.rs@@ -135,6 +135,8 @@ pub enum SvgIcon {Mic,Camera,Network,+ /// The Mac mini a remote host can be shown as: lucide has none.+ HardDrive,/// The mux server of the README's architecture diagram: a host whose/// sessions live on it, which is what ThinkTerm Connect means.MuxServer,@@ -438,6 +440,9 @@ impl SvgIcon {Self::Camera => include_bytes!("../../../../third_party/lucide/icons/camera.svg"),Self::Apple => include_bytes!("../../../../third_party/simple-icons/icons/apple.svg"),Self::Network => include_bytes!("../../../../third_party/lucide/icons/network.svg"),+ Self::HardDrive => {+ include_bytes!("../../../../third_party/lucide/icons/hard-drive.svg")+ }Self::MuxServer => include_bytes!("../../../../assets/ui/mux-server.svg"),Self::QrCode => include_bytes!("../../../../third_party/lucide/icons/qr-code.svg"),Self::Smartphone => {@@ -968,6 +973,10 @@ mod tests {// Settings › General's permissions.SvgIcon::Mic,SvgIcon::Camera,+ // The kinds of machine a remote host can be shown as.+ SvgIcon::Laptop,+ SvgIcon::HardDrive,+ SvgIcon::Package,// What a plugin's panel is shown by in the selector.SvgIcon::Activity,SvgIcon::Bug,diff --git a/window/src/lib.rs b/window/src/lib.rsindex 4eca9e0f..8fc28a15 100644--- a/window/src/lib.rs+++ b/window/src/lib.rs@@ -211,12 +211,18 @@ pub enum ContextMenuIcon {ArchiveRestore,Back,Check,+ /// The kinds of machine a remote host can be shown as (`HostIcon`):+ /// these and `Server`.+ Chip,Close,+ Cloud,Code,Collapse,+ Container,Copy,Cut,Delete,+ Desktop,Disconnect,Edit,Expand,@@ -227,10 +233,13 @@ pub enum ContextMenuIcon {FolderRemove,/// What a view shows: the sliders of a view-options button.Filter,+ Globe,/// How a view groups its rows.Group,Home,Info,+ Laptop,+ MacMini,MoveLeft,MoveRight,Network,@@ -307,7 +316,11 @@ impl ContextMenuIcon {Self::ArchiveRestore => "tray.and.arrow.up",Self::Back => "chevron.left",Self::Check => "checkmark.circle",+ Self::Chip => "cpu",Self::Close => "xmark",+ Self::Cloud => "cloud",+ Self::Container => "shippingbox",+ Self::Desktop => "desktopcomputer",Self::Code => "chevron.left.forwardslash.chevron.right",Self::Collapse => "rectangle.compress.vertical",Self::Copy => "doc.on.doc",@@ -326,6 +339,9 @@ impl ContextMenuIcon {Self::FolderAdd => "folder.badge.plus",Self::FolderRemove => "folder.badge.minus",Self::Filter => "slider.horizontal.3",+ Self::Globe => "globe",+ Self::Laptop => "laptopcomputer",+ Self::MacMini => "macmini",Self::Group => "square.stack.3d.up",Self::Home => "house",Self::Info => "info.circle",@@ -369,7 +385,11 @@ impl ContextMenuIcon {include_bytes!("../../third_party/lucide/icons/arrow-left.svg")}Self::Check => include_bytes!("../../third_party/lucide/icons/circle-check.svg"),+ Self::Chip => include_bytes!("../../third_party/lucide/icons/cpu.svg"),Self::Close => include_bytes!("../../third_party/lucide/icons/x.svg"),+ Self::Cloud => include_bytes!("../../third_party/lucide/icons/cloud.svg"),+ Self::Container => include_bytes!("../../third_party/lucide/icons/package.svg"),+ Self::Desktop => include_bytes!("../../third_party/lucide/icons/monitor.svg"),Self::Code => include_bytes!("../../third_party/lucide/icons/code-xml.svg"),Self::Collapse => include_bytes!("../../third_party/lucide/icons/shrink.svg"),Self::Copy => include_bytes!("../../third_party/lucide/icons/copy.svg"),@@ -390,6 +410,11 @@ impl ContextMenuIcon {Self::Filter => {include_bytes!("../../third_party/lucide/icons/sliders-horizontal.svg")}+ Self::Globe => include_bytes!("../../third_party/lucide/icons/globe.svg"),+ Self::Laptop => include_bytes!("../../third_party/lucide/icons/laptop.svg"),+ // lucide has no Mac mini; its flat drive with the lights on the+ // front is the same squat box.+ Self::MacMini => include_bytes!("../../third_party/lucide/icons/hard-drive.svg"),Self::Group => include_bytes!("../../third_party/lucide/icons/layers.svg"),Self::Home => include_bytes!("../../third_party/lucide/icons/house.svg"),Self::Info => include_bytes!("../../third_party/lucide/icons/info.svg"),diff --git a/window/src/os/macos/menu.rs b/window/src/os/macos/menu.rsindex ceb00815..b225086c 100644--- a/window/src/os/macos/menu.rs+++ b/window/src/os/macos/menu.rs@@ -12,6 +12,11 @@ use objc::runtime::{Class, Object, Sel, BOOL, NO, YES};pub use objc::*;use std::ffi::c_void;+/// `NSMenuItemImageVisibilityVisible`. From macOS 27 a menu hides its items'+/// images unless each asks for them to show; ours are chosen for every item+/// that has one.+const MENU_ITEM_IMAGE_VISIBLE: NSInteger = 1;+pub struct Menu {menu: StrongPtr,}@@ -345,6 +350,16 @@ impl MenuItem {let () = msg_send![image, setTemplate:YES];let () = msg_send![*self.item, setImage:image];+ let shows: BOOL = msg_send![+ *self.item,+ respondsToSelector: sel!(setPreferredImageVisibility:)+ ];+ if shows == YES {+ let () = msg_send![+ *self.item,+ setPreferredImageVisibility: MENU_ITEM_IMAGE_VISIBLE+ ];+ }true}}@@ -371,6 +386,16 @@ impl MenuItem {let image = StrongPtr::new(image);let () = msg_send![*image, setTemplate:YES];let () = msg_send![*self.item, setImage:*image];+ let shows: BOOL = msg_send![+ *self.item,+ respondsToSelector: sel!(setPreferredImageVisibility:)+ ];+ if shows == YES {+ let () = msg_send![+ *self.item,+ setPreferredImageVisibility: MENU_ITEM_IMAGE_VISIBLE+ ];+ }}}