@@ -185,18 +185,21 @@ func buildClaudeCmd(claudeArgs []string, hasProxy bool, remoteCwd string) string
185185// buildTmuxRemoteCmd 构造 D-10 完整远程命令模板。所有参数已 shellescape。
186186//
187187// cd <cwd_q> && command -v tmux >/dev/null 2>&1 \
188- // && exec tmux new-session -A -d -s <session_q> <wrap_q> \; attach-session -t <session_q> \
188+ // && exec tmux -u new-session -A -d -s <session_q> <wrap_q> \; attach-session -t <session_q> \
189189// || exec <fallback>
190190//
191- // wrapCmd = "cd <cwd_q> && <claudeCmd>"(整体 shellescape 一次后塞给 tmux new-session)。
191+ // wrapCmd = "export LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 && cd <cwd_q> && <claudeCmd>"
192+ // (整体 shellescape 一次后塞给 tmux new-session)。
192193// fallback = wrapCmd 字面值(不经过 tmux 直接 exec)。
194+ //
195+ // -u 强制 tmux 输出 UTF-8;wrapCmd 注入 locale 确保 Claude Code 渲染中文正常。
193196func buildTmuxRemoteCmd (remoteCwd , sessionName , claudeCmd string ) string {
194197 cwdQ := shellescape .Quote (remoteCwd )
195198 sessionQ := shellescape .Quote (sessionName )
196- wrapCmd := fmt .Sprintf ("cd %s && %s" , cwdQ , claudeCmd )
199+ wrapCmd := fmt .Sprintf ("export LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 && cd %s && %s" , cwdQ , claudeCmd )
197200 wrapQ := shellescape .Quote (wrapCmd )
198201 return fmt .Sprintf (
199- "cd %s && command -v tmux >/dev/null 2>&1 && exec tmux new-session -A -d -s %s %s \\ ; attach-session -t %s || exec %s" ,
202+ "cd %s && command -v tmux >/dev/null 2>&1 && exec tmux -u new-session -A -d -s %s %s \\ ; attach-session -t %s || exec %s" ,
200203 cwdQ , sessionQ , wrapQ , sessionQ , wrapCmd ,
201204 )
202205}
@@ -898,6 +901,6 @@ func RunSessionsAttach(conn *ssh.Client, sessionName string, hasProxy bool, cwd
898901 fmt .Fprintln (os .Stderr , errcodes .Format (errcodes .SESSION_NOT_FOUND , sessionName ))
899902 return ExitConfigError , fmt .Errorf ("session not found: %s" , sessionName )
900903 }
901- remoteCmd := fmt .Sprintf ("exec tmux attach-session -t %s" , sessQ )
904+ remoteCmd := fmt .Sprintf ("exec tmux -u attach-session -t %s" , sessQ )
902905 return runClaudePTYBare (conn , remoteCmd )
903906}
0 commit comments