diff --git a/linux/pkg/session/pty.go b/linux/pkg/session/pty.go index bc66e07a..15d575c5 100644 --- a/linux/pkg/session/pty.go +++ b/linux/pkg/session/pty.go @@ -65,42 +65,22 @@ func NewPTY(session *Session) (*PTY, error) { debugLog("[DEBUG] NewPTY: Set working directory to: %s", session.info.Cwd) } - // Set up environment with filtered variables like Rust implementation - // Only pass safe environment variables - safeEnvVars := []string{"TERM", "SHELL", "LANG", "LC_ALL", "PATH", "USER", "HOME"} - env := make([]string, 0) + // Pass all environment variables like Node.js implementation does + // This ensures terminal features, locale settings, and shell prompts work correctly + env := os.Environ() - // Copy only safe environment variables from parent - for _, v := range os.Environ() { - parts := strings.SplitN(v, "=", 2) - if len(parts) == 2 { - for _, safe := range safeEnvVars { - if parts[0] == safe { - env = append(env, v) - break - } - } - } - } - - // Ensure TERM and SHELL are set - hasTermVar := false - hasShellVar := false - for _, v := range env { + // Override TERM if specified in session info + termSet := false + for i, v := range env { if strings.HasPrefix(v, "TERM=") { - hasTermVar = true - } - if strings.HasPrefix(v, "SHELL=") { - hasShellVar = true + env[i] = "TERM=" + session.info.Term + termSet = true + break } } - - if !hasTermVar { + if !termSet { env = append(env, "TERM="+session.info.Term) } - if !hasShellVar { - env = append(env, "SHELL="+cmdline[0]) - } cmd.Env = env diff --git a/linux/pkg/session/terminal.go b/linux/pkg/session/terminal.go index 33add73a..3246f7e1 100644 --- a/linux/pkg/session/terminal.go +++ b/linux/pkg/session/terminal.go @@ -31,7 +31,7 @@ func configurePTYTerminal(ptyFile *os.File) error { // Match node-pty's default behavior: keep most settings from the parent terminal // but ensure proper signal handling and character processing - + // Ensure proper input processing // ICRNL: Map CR to NL on input (important for Enter key) termios.Iflag |= unix.ICRNL @@ -64,7 +64,7 @@ func configurePTYTerminal(ptyFile *os.File) error { termios.Cc[unix.VINTR] = 3 // Ctrl+C termios.Cc[unix.VKILL] = 21 // Ctrl+U termios.Cc[unix.VMIN] = 1 // Minimum characters for read - termios.Cc[unix.VQUIT] = 28 // Ctrl+\ + termios.Cc[unix.VQUIT] = 28 // Ctrl+\ termios.Cc[unix.VSUSP] = 26 // Ctrl+Z termios.Cc[unix.VTIME] = 0 // Timeout for read diff --git a/linux/pkg/session/terminal_darwin.go b/linux/pkg/session/terminal_darwin.go index 665c3aa0..803a3b84 100644 --- a/linux/pkg/session/terminal_darwin.go +++ b/linux/pkg/session/terminal_darwin.go @@ -7,4 +7,4 @@ import "golang.org/x/sys/unix" const ( ioctlGetTermios = unix.TIOCGETA ioctlSetTermios = unix.TIOCSETA -) \ No newline at end of file +) diff --git a/linux/pkg/session/terminal_linux.go b/linux/pkg/session/terminal_linux.go index 2d725741..282e10c9 100644 --- a/linux/pkg/session/terminal_linux.go +++ b/linux/pkg/session/terminal_linux.go @@ -7,4 +7,4 @@ import "golang.org/x/sys/unix" const ( ioctlGetTermios = unix.TCGETS ioctlSetTermios = unix.TCSETS -) \ No newline at end of file +) diff --git a/linux/pkg/session/terminal_other.go b/linux/pkg/session/terminal_other.go index d1f479ae..574cbb93 100644 --- a/linux/pkg/session/terminal_other.go +++ b/linux/pkg/session/terminal_other.go @@ -8,4 +8,4 @@ const ( // Default to Linux constants for other Unix systems ioctlGetTermios = unix.TCGETS ioctlSetTermios = unix.TCSETS -) \ No newline at end of file +)