Skip to content

A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.

feat(ssh): let the Files panel connect to a host by itself

RoversX6d19a9bcb754
diff --git a/thinkterm-core/src/ssh_hosts.rs b/thinkterm-core/src/ssh_hosts.rs
index 3acecaa6..dee5353d 100644
--- a/thinkterm-core/src/ssh_hosts.rs
+++ b/thinkterm-core/src/ssh_hosts.rs
@@ -54,6 +54,11 @@ pub struct SshHostSpec {
/// until one does; the next connection tries again.
#[serde(default)]
pub shell_integration_failure: Option<ShellIntegrationFailure>,
+ /// Whether the right sidebar's Files panel connects to this host by
+ /// itself, beside a terminal there, rather than once the user presses
+ /// Connect.
+ #[serde(default)]
+ pub files_auto_connect: bool,
}
/// Why setting a host's shell integration up failed.
@@ -190,6 +195,7 @@ pub fn parse_system_ssh_config(content: &str) -> Vec<SshHostEntry> {
shell_integration_applied: false,
shell_integration_unsupported: None,
shell_integration_failure: None,
+ files_auto_connect: false,
},
});
}
@@ -339,6 +345,10 @@ mod tests {
let hosts = list_saved_hosts_from_path(&path).unwrap();
assert_eq!(hosts[0].spec.label, "AM2");
assert!(hosts[0].spec.multiplexing);
+ assert!(
+ !hosts[0].spec.files_auto_connect,
+ "saved before there was one: Files waits to be asked"
+ );
}
#[test]
@@ -361,6 +371,7 @@ mod tests {
shell_integration_applied: false,
shell_integration_unsupported: None,
shell_integration_failure: None,
+ files_auto_connect: false,
};
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.ftl
index 0910440e..459dbc7a 100644
--- a/thinkterm-i18n/i18n/de-DE.ftl
+++ b/thinkterm-i18n/i18n/de-DE.ftl
@@ -490,6 +490,7 @@ ssh-group-session = Sitzung
ssh-detect-os = Betriebssystem erkennen
ssh-use-mosh = Mit Mosh verbinden
ssh-use-mux = ThinkTerm Connect
+ssh-files-auto-connect = Dateien automatisch verbinden
ssh-shell-integration = Entfernte Programme erkennen
ssh-shell-integration-note = Wirkt bei SSH: Das Tab-Symbol zeigt, was auf diesem Server läuft.
ssh-shell-integration-install = Eingeschaltet fügt die nächste Verbindung den bash- oder zsh-Startdateien des Servers eine Zeile hinzu.
diff --git a/thinkterm-i18n/i18n/en-US.ftl b/thinkterm-i18n/i18n/en-US.ftl
index 30f9345d..e591a02d 100644
--- a/thinkterm-i18n/i18n/en-US.ftl
+++ b/thinkterm-i18n/i18n/en-US.ftl
@@ -490,6 +490,7 @@ ssh-group-session = Session
ssh-detect-os = Detect OS
ssh-use-mosh = Connect with Mosh
ssh-use-mux = ThinkTerm Connect
+ssh-files-auto-connect = Connect Files automatically
ssh-shell-integration = Detect remote programs
ssh-shell-integration-note = Works over SSH: tab icons show what runs on this server.
ssh-shell-integration-install = When on, the next connection adds one line to the server's bash or zsh startup files.
diff --git a/thinkterm-i18n/i18n/fr-FR.ftl b/thinkterm-i18n/i18n/fr-FR.ftl
index ac05e4e8..0939993e 100644
--- a/thinkterm-i18n/i18n/fr-FR.ftl
+++ b/thinkterm-i18n/i18n/fr-FR.ftl
@@ -490,6 +490,7 @@ ssh-group-session = Session
ssh-detect-os = Détecter le système
ssh-use-mosh = Se connecter avec Mosh
ssh-use-mux = ThinkTerm Connect
+ssh-files-auto-connect = Connecter Fichiers automatiquement
ssh-shell-integration = Détecter les programmes distants
ssh-shell-integration-note = Fonctionne en SSH : l’icône de l’onglet montre ce qui tourne sur ce serveur.
ssh-shell-integration-install = Une fois activé, la prochaine connexion ajoute une ligne aux fichiers de démarrage bash ou zsh du serveur.
diff --git a/thinkterm-i18n/i18n/ja-JP.ftl b/thinkterm-i18n/i18n/ja-JP.ftl
index b7212586..1d593548 100644
--- a/thinkterm-i18n/i18n/ja-JP.ftl
+++ b/thinkterm-i18n/i18n/ja-JP.ftl
@@ -481,6 +481,7 @@ ssh-group-session = セッション
ssh-detect-os = OS を検出
ssh-use-mosh = Mosh で接続
ssh-use-mux = ThinkTerm Connect
+ssh-files-auto-connect = ファイルパネルを自動で接続
ssh-shell-integration = リモートのプログラムを識別
ssh-shell-integration-note = SSH 接続で有効:タブのアイコンがこのサーバーで動いているプログラムを表示します。
ssh-shell-integration-install = オンにすると、次回の接続時にサーバーの bash / zsh の起動ファイルへ 1 行追加します。
diff --git a/thinkterm-i18n/i18n/zh-CN.ftl b/thinkterm-i18n/i18n/zh-CN.ftl
index b7b5a925..e06618c7 100644
--- a/thinkterm-i18n/i18n/zh-CN.ftl
+++ b/thinkterm-i18n/i18n/zh-CN.ftl
@@ -481,6 +481,7 @@ ssh-group-session = 会话
ssh-detect-os = 检测操作系统
ssh-use-mosh = 使用 Mosh 连接
ssh-use-mux = ThinkTerm Connect
+ssh-files-auto-connect = 文件面板自动连接
ssh-shell-integration = 识别远端程序
ssh-shell-integration-note = SSH 连接时起作用:tab 图标显示这台服务器上正在运行的程序。
ssh-shell-integration-install = 开启后,下次连接时会在服务器的 bash / zsh 启动文件里加一行。
diff --git a/wezterm-gui/src/ssh_hosts.rs b/wezterm-gui/src/ssh_hosts.rs
index c3f7b778..4bac40d1 100644
--- a/wezterm-gui/src/ssh_hosts.rs
+++ b/wezterm-gui/src/ssh_hosts.rs
@@ -791,6 +791,7 @@ fn parse_system_ssh_config_str(content: &str) -> Vec<SshHostEntry> {
shell_integration_applied: false,
shell_integration_unsupported: None,
shell_integration_failure: None,
+ files_auto_connect: false,
};
out.push(SshHostEntry {
id: system_host_id(&alias),
@@ -1054,6 +1055,7 @@ Host prod *.internal
shell_integration_applied: false,
shell_integration_unsupported: None,
shell_integration_failure: None,
+ files_auto_connect: false,
}
}
diff --git a/wezterm-gui/src/termwindow/ssh_hosts_view.rs b/wezterm-gui/src/termwindow/ssh_hosts_view.rs
index 2b2516f7..083fe0bf 100644
--- a/wezterm-gui/src/termwindow/ssh_hosts_view.rs
+++ b/wezterm-gui/src/termwindow/ssh_hosts_view.rs
@@ -151,6 +151,8 @@ enum SshViewAction {
ToggleMosh,
ToggleMux,
ToggleShellIntegration,
+ /// The Files panel connects to the host by itself.
+ ToggleFilesAutoConnect,
RevealPassword,
Save,
SaveAndConnect,
@@ -187,6 +189,7 @@ struct HostForm {
use_mosh: bool,
multiplexing: bool,
shell_integration: bool,
+ files_auto_connect: bool,
error: Option<String>,
}
@@ -357,6 +360,7 @@ impl SshHostsView {
let use_mosh = spec.use_mosh;
let multiplexing = spec.multiplexing;
let shell_integration = spec.shell_integration;
+ let files_auto_connect = spec.files_auto_connect;
// Sorted so the rows keep a stable order between opens.
let mut option_pairs: Vec<(String, String)> = spec
.ssh_options
@@ -379,6 +383,7 @@ impl SshHostsView {
use_mosh,
multiplexing,
shell_integration,
+ files_auto_connect,
error: None,
});
self.focus = Focus::Field(FIELD_HOST);
@@ -444,6 +449,7 @@ impl SshHostsView {
shell_integration_applied: false,
shell_integration_unsupported: None,
shell_integration_failure: None,
+ files_auto_connect: false,
});
spec.label = label;
spec.host = host;
@@ -471,6 +477,7 @@ impl SshHostsView {
spec.use_mosh = form.use_mosh;
spec.multiplexing = form.multiplexing;
spec.shell_integration = form.shell_integration;
+ spec.files_auto_connect = form.files_auto_connect;
let mosh_server_command = form.fields[FIELD_MOSH_SERVER].text().trim();
if spec.use_mosh && mosh_server_command.is_empty() {
form.error = Some(crate::i18n::tr("ssh-error-mosh-command"));
@@ -734,6 +741,12 @@ impl SshHostsView {
}
ContentViewResponse::Redraw
}
+ SshViewAction::ToggleFilesAutoConnect => {
+ if let Some(form) = self.form.as_mut() {
+ form.files_auto_connect = !form.files_auto_connect;
+ }
+ ContentViewResponse::Redraw
+ }
SshViewAction::Save => {
self.persist_form();
ContentViewResponse::Redraw
@@ -870,6 +883,7 @@ impl SshHostsView {
form.use_mosh = spec.use_mosh;
form.multiplexing = spec.multiplexing;
form.shell_integration = spec.shell_integration;
+ form.files_auto_connect = spec.files_auto_connect;
form.options = spec
.ssh_options
.iter()
@@ -2176,6 +2190,7 @@ impl SshHostsView {
let use_mosh = form.use_mosh;
let multiplexing = form.multiplexing;
let shell_integration = form.shell_integration;
+ let files_auto_connect = form.files_auto_connect;
let advanced_open = form.advanced_open;
let error = form.error.clone();
let fields = form.fields.clone();
@@ -2407,7 +2422,7 @@ impl SshHostsView {
inner,
)
});
- let mut session_rows = vec![field_h, toggle_h, toggle_h, toggle_h];
+ let mut session_rows = vec![field_h, toggle_h, toggle_h, toggle_h, toggle_h];
if use_mosh {
session_rows.push(field_h);
}
@@ -2476,6 +2491,18 @@ impl SshHostsView {
fy,
inner,
)? + gap;
+ fy = self.paint_toggle_row(
+ ctx,
+ &mut body_layers,
+ font,
+ palette,
+ &crate::i18n::tr("ssh-files-auto-connect"),
+ files_auto_connect,
+ SshViewAction::ToggleFilesAutoConnect,
+ x + pad,
+ fy,
+ inner,
+ )? + gap;
if let Some(lines) = &integration_note {
fy = self.paint_toggle_row(
ctx,
@@ -2941,6 +2968,7 @@ mod tests {
shell_integration_applied: false,
shell_integration_unsupported: None,
shell_integration_failure: None,
+ files_auto_connect: false,
}
}
diff --git a/wezterm-gui/src/termwindow/ui/right_sidebar.rs b/wezterm-gui/src/termwindow/ui/right_sidebar.rs
index b6bd507c..46cd73cc 100644
--- a/wezterm-gui/src/termwindow/ui/right_sidebar.rs
+++ b/wezterm-gui/src/termwindow/ui/right_sidebar.rs
@@ -11252,6 +11252,15 @@ impl crate::TermWindow {
if changed {
self.clear_right_sidebar_text_focus();
self.right_sidebar_remote_file_tree_scroll_offset = 0.0;
+ // A host whose setting says so is connected as though
+ // Connect were pressed.
+ if Self::remote_files_auto_connect(&target) {
+ crate::termwindow::remote_files::authorize_remote_source(
+ &crate::termwindow::remote_files::RemoteFilesState::source_key(
+ &target.source,
+ ),
+ );
+ }
}
let effects = self
.right_sidebar_remote_files
@@ -12316,6 +12325,25 @@ impl crate::TermWindow {
Ok(domain)
}
+ /// Whether the Files panel connects by itself to the machine `target`
+ /// names: a saved host -- reached directly, or through a mux domain it is
+ /// connected under -- whose setting says to.
+ fn remote_files_auto_connect(target: &workspace_threads::RemoteFilesTarget) -> bool {
+ match &target.source {
+ workspace_threads::RemoteFilesSource::SshHost(host_id) => {
+ crate::ssh_hosts::host_spec(host_id).is_some_and(|spec| spec.files_auto_connect)
+ }
+ workspace_threads::RemoteFilesSource::ClientDomain(domain) => {
+ crate::ssh_hosts::list_all_hosts().into_iter().any(|entry| {
+ entry.spec.files_auto_connect
+ && crate::ssh_hosts::domain_names_for_host(&entry.spec)
+ .iter()
+ .any(|name| name == domain)
+ })
+ }
+ }
+ }
+
fn ssh_config_for_remote_files_source(
target: &workspace_threads::RemoteFilesTarget,
) -> Result<config::SshDomain, String> {