Skip to content

An open-source remote desktop application designed for self-hosting, as an alternative to TeamViewer.

fix(terminal): macos, env TERM (#13901)

fufesou5b2101e17d14
diff --git a/src/server/terminal_service.rs b/src/server/terminal_service.rs
index 945ae27bd..194e41ef1 100644
--- a/src/server/terminal_service.rs
+++ b/src/server/terminal_service.rs
@@ -774,6 +774,21 @@ impl TerminalServiceProxy {
#[allow(unused_mut)]
let mut cmd = CommandBuilder::new(&shell);
+ // Set `TERM` environment variable for macOS to ensure proper terminal behavior
+ // This fixes issues with control sequences (e.g., Delete/Backspace keys)
+ // macOS terminfo uses hex naming: '78' = 'x' for xterm entries
+ // Note: For Linux, `TERM` is set in src/platform/linux.rs try_start_server_()
+ #[cfg(target_os = "macos")]
+ {
+ let term = if std::path::Path::new("/usr/share/terminfo/78/xterm-256color").exists() {
+ "xterm-256color"
+ } else {
+ "xterm"
+ };
+ cmd.env("TERM", term);
+ log::debug!("Set TERM={} for macOS PTY", term);
+ }
+
#[cfg(target_os = "windows")]
if let Some(token) = &self.user_token {
cmd.set_user_token(*token as _);