fix: hide OSC 7 hook injection from terminal output
Some checks failed
Build & Sign Wraith / Build Windows + Sign (push) Failing after 6s

The CWD hook command was visible to the user. Now wrapped in
stty -echo/echo to suppress echo, followed by clear to wipe the
screen. Space prefix prevents history recording in most shells.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Vantz Stockwell 2026-03-25 01:16:20 -04:00
parent 6b5fad2289
commit 0bcf59865d

View File

@ -160,15 +160,17 @@ impl SshService {
// Inject OSC 7 CWD reporting hook into the user's shell. // Inject OSC 7 CWD reporting hook into the user's shell.
// This enables SFTP CWD following on all platforms (Linux, macOS, FreeBSD). // This enables SFTP CWD following on all platforms (Linux, macOS, FreeBSD).
// Sent via the PTY channel so it configures the interactive shell. // Sent via the PTY channel so it configures the interactive shell.
// Wrapped in stty -echo/echo so the command is invisible to the user,
// then clear the line with \r and overwrite with spaces.
{ {
let osc7_hook = concat!( let osc7_hook = concat!(
// Detect shell and inject the appropriate hook silently " stty -echo; ",
r#"if [ -n "$ZSH_VERSION" ]; then "#, r#"if [ -n "$ZSH_VERSION" ]; then "#,
r#"precmd() { printf '\033]7;file://%s%s\033\\' "$HOST" "$PWD"; }; "#, r#"precmd() { printf '\033]7;file://%s%s\033\\' "$HOST" "$PWD"; }; "#,
r#"elif [ -n "$BASH_VERSION" ]; then "#, r#"elif [ -n "$BASH_VERSION" ]; then "#,
r#"PROMPT_COMMAND='printf "\033]7;file://%s%s\033\\\\" "$HOSTNAME" "$PWD"'; "#, r#"PROMPT_COMMAND='printf "\033]7;file://%s%s\033\\\\" "$HOSTNAME" "$PWD"'; "#,
r#"fi"#, r#"fi; "#,
"\n" "stty echo; clear\n"
); );
let h = handle.lock().await; let h = handle.lock().await;
let _ = h.data(channel_id, CryptoVec::from_slice(osc7_hook.as_bytes())).await; let _ = h.data(channel_id, CryptoVec::from_slice(osc7_hook.as_bytes())).await;