The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
tui: broaden the nested-hn guard to match tmux itself (#459)
elvised5e6627b486
diff --git a/tui/src/main.rs b/tui/src/main.rsindex b52dbc84c..bba32c436 100644--- a/tui/src/main.rs+++ b/tui/src/main.rs@@ -314,19 +314,21 @@ async fn run(config: config::Config) -> io::Result<()> {if !found { if !ipc::alive(f.socket.as_deref(), f.name.as_deref()) { eprintln!("can't find session: {t}") } std::process::exit(1) }}}- // Refuse to start a client from inside an existing hn client — as tmux- // refuses `tmux` from inside a tmux pane. Without this, `hn` (and `harness- // tui`, which wraps `hn`) inside a pane would open a whole TUI on top of- // itself, tail-eating the parent's screen until the process tree gives up.- // Detection matches ipc::chosen's own rule: $TMUX's socket path pointing at- // hn's socket directory means the parent process is a client of ours. Match- // tmux's exact wording so tmux-savvy users read the same escape hatch:- // `TMUX= hn` (or `unset TMUX; hn`) bypasses.- if std::env::var("TMUX").ok()- .and_then(|t| t.split(',').next().map(std::path::PathBuf::from))- .filter(|p| p.starts_with(ipc::dir()))- .is_some()- {+ // Refuse to start a client from inside an existing multiplexer session —+ // as tmux itself does. Without this, `hn` (and `harness tui`, which wraps+ // `hn`) opened inside a pane stacks a whole TUI on top of the parent's+ // screen; when the parent multiplexer is hn, the recursion keeps going+ // until the process tree gives up, and when it's a real tmux (for+ // instance, the tmux backend that Harness Desktop uses to host its+ // terminals), the pane borders and status bars overlap into a cascade+ // that reads as an infinite loop to the user.+ //+ // Follow tmux's own rule: any $TMUX at all is a nested-client signal.+ // The message and the escape hatch stay tmux's exact wording so muscle+ // memory carries over: `TMUX= hn` (or `unset TMUX; hn`) bypasses when the+ // caller truly wants a nested client, matching tmux's `unset $TMUX to+ // force`.+ if std::env::var("TMUX").ok().filter(|t| !t.is_empty()).is_some() {eprintln!("sessions should be nested with care, unset $TMUX to force");std::process::exit(1);}