diff --git a/src/frontend/gui/overlay/launcher.rs b/src/frontend/gui/overlay/launcher.rs index f239c8880..410a8169f 100644 --- a/src/frontend/gui/overlay/launcher.rs +++ b/src/frontend/gui/overlay/launcher.rs @@ -57,7 +57,7 @@ pub fn launcher( for (domain_id, domain_state, domain_name) in &domains { let entry = if *domain_state == DomainState::Attached { Entry::Spawn { - label: format!("New Tab (domain `{}`)", domain_name), + label: format!("New Tab ({})", domain_name), command: SpawnCommand { domain: SpawnTabDomain::Domain(*domain_id), ..SpawnCommand::default() @@ -66,7 +66,7 @@ pub fn launcher( } } else { Entry::Attach { - label: format!("Attach domain `{}`", domain_name), + label: format!("Attach {}", domain_name), domain: *domain_id, } }; diff --git a/src/frontend/gui/termwindow.rs b/src/frontend/gui/termwindow.rs index f90c737a2..99c370a76 100644 --- a/src/frontend/gui/termwindow.rs +++ b/src/frontend/gui/termwindow.rs @@ -1080,7 +1080,16 @@ impl TermWindow { domains.retain(|dom| dom.spawnable()); let domains: Vec<(DomainId, DomainState, String)> = domains .iter() - .map(|dom| (dom.domain_id(), dom.state(), dom.domain_name().to_owned())) + .map(|dom| { + let name = dom.domain_name(); + let label = dom.domain_label(); + let label = if name == label || label == "" { + format!("domain `{}`", name) + } else { + format!("domain `{}` - {}", name, label) + }; + (dom.domain_id(), dom.state(), label) + }) .collect(); let domain_id_of_current_tab = tab.domain_id(); diff --git a/src/mux/domain.rs b/src/mux/domain.rs index b93cb1ba0..59119e98c 100644 --- a/src/mux/domain.rs +++ b/src/mux/domain.rs @@ -53,9 +53,15 @@ pub trait Domain: Downcast { /// a handle on the domain later. fn domain_id(&self) -> DomainId; - /// Returns the name of the domain + /// Returns the name of the domain. + /// Should be a short identifier. fn domain_name(&self) -> &str; + /// Returns a label describing the domain. + fn domain_label(&self) -> &str { + self.domain_name() + } + /// Re-attach to any tabs that might be pre-existing in this domain async fn attach(&self) -> anyhow::Result<()>; diff --git a/src/server/domain.rs b/src/server/domain.rs index 8d88fe09b..5ecdb67da 100644 --- a/src/server/domain.rs +++ b/src/server/domain.rs @@ -99,6 +99,16 @@ impl ClientDomainConfig { } } + pub fn label(&self) -> String { + match self { + ClientDomainConfig::Unix(unix) => format!("unix mux {}", unix.socket_path().display()), + ClientDomainConfig::Tls(tls) => format!("TLS mux {}", tls.remote_address), + ClientDomainConfig::Ssh(ssh) => { + format!("SSH mux {}@{}", ssh.username, ssh.remote_address) + } + } + } + pub fn connect_automatically(&self) -> bool { match self { ClientDomainConfig::Unix(unix) => unix.connect_automatically, @@ -127,6 +137,7 @@ impl ClientInner { pub struct ClientDomain { config: ClientDomainConfig, + label: String, inner: RefCell>>, local_domain_id: DomainId, } @@ -134,8 +145,10 @@ pub struct ClientDomain { impl ClientDomain { pub fn new(config: ClientDomainConfig) -> Self { let local_domain_id = alloc_domain_id(); + let label = config.label(); Self { config, + label, inner: RefCell::new(None), local_domain_id, } @@ -283,6 +296,10 @@ impl Domain for ClientDomain { self.config.name() } + fn domain_label(&self) -> &str { + &self.label + } + async fn spawn( &self, size: PtySize, diff --git a/src/ssh.rs b/src/ssh.rs index 29c55bcfb..d347fd890 100644 --- a/src/ssh.rs +++ b/src/ssh.rs @@ -233,7 +233,7 @@ impl RemoteSshDomain { Self { pty_system, id, - name: name.to_string(), + name: format!("SSH to {}", name), } } }