the runtime your coding agents live on
Rust agentagent-orchestrationaiai-agentsclaude-codeclicodexcoding-agentsdeveloper-toolsdevtoolsmultiplexerrustterminalterminal-multiplexerterminal-uitmuxtuiworkspace-manager
fix: honor mouse capture config in terminal attach (#2995)
akbash1b56601630c8
diff --git a/src/client/mod.rs b/src/client/mod.rsindex c33157fb0..27a2e9c41 100644--- a/src/client/mod.rs+++ b/src/client/mod.rs@@ -348,11 +348,11 @@ fn setup_terminal(mouse_capture: bool) -> io::Result<TerminalGuard> {/// Sets up a direct attach terminal.///-/// Direct attach forwards stdin to the attached PTY. It enables mouse capture-/// so wheel events can drive the attached viewport or be forwarded to child+/// Direct attach forwards stdin to the attached PTY. When configured, mouse+/// capture lets wheel events drive the attached viewport or reach child/// programs that requested mouse input.-fn setup_direct_attach_terminal() -> io::Result<TerminalGuard> {- setup_terminal_with_capabilities(false, true)+fn setup_direct_attach_terminal(mouse_capture: bool) -> io::Result<TerminalGuard> {+ setup_terminal_with_capabilities(false, mouse_capture)}fn setup_terminal_with_capabilities(@@ -1284,7 +1284,7 @@ fn run_client_with_mode(// so we don't leave the terminal in raw mode if the server rejects us.let direct_attach = attach_escape.is_some();let terminal_guard = if direct_attach {- setup_direct_attach_terminal()+ setup_direct_attach_terminal(mouse_capture)} else {setup_terminal(mouse_capture)}diff --git a/tests/client_mode.rs b/tests/client_mode.rsindex 855fc3180..998df2be1 100644--- a/tests/client_mode.rs+++ b/tests/client_mode.rs@@ -82,6 +82,15 @@ fn spawn_client_process(config_home: &PathBuf,runtime_dir: &PathBuf,api_socket_path: &PathBuf,+) -> SpawnedHerdr {+ spawn_client_process_with_args(config_home, runtime_dir, api_socket_path, &["client"])+}++fn spawn_client_process_with_args(+ config_home: &PathBuf,+ runtime_dir: &PathBuf,+ api_socket_path: &PathBuf,+ args: &[&str],) -> SpawnedHerdr {register_runtime_dir(runtime_dir);let pair = native_pty_system()@@ -94,7 +103,7 @@ fn spawn_client_process(.unwrap();let mut cmd = CommandBuilder::new(env!("CARGO_BIN_EXE_herdr"));- cmd.arg("client");+ cmd.args(args);cmd.env("HERDR_DISABLE_SOUND", "1");cmd.env("XDG_CONFIG_HOME", config_home);cmd.env("XDG_RUNTIME_DIR", runtime_dir);@@ -382,6 +391,118 @@ fn client_connects_and_receives_frame() {cleanup_spawned_herdr(spawned, base);}+#[test]+fn direct_attach_initial_mouse_capture_follows_config() {+ let _lock = test_lock();+ let base = unique_test_dir();+ let config_home = base.join("config");+ let runtime_dir = base.join("runtime");+ let api_socket = runtime_dir.join("herdr.sock");+ let client_socket = runtime_dir.join("herdr-client.sock");+ let config_path = config_home.join(app_dir_name()).join("config.toml");++ let spawned_server = spawn_server_with_config(+ &config_home,+ &runtime_dir,+ &api_socket,+ &client_socket,+ "onboarding = false\n[ui]\nmouse_capture = false\n",+ );+ wait_for_socket(&api_socket, Duration::from_secs(10));+ wait_for_socket(&client_socket, Duration::from_secs(10));+ let created = send_json_request(+ &api_socket,+ &serde_json::json!({+ "id": "create-workspace-for-direct-attach",+ "method": "workspace.create",+ "params": {"cwd": base},+ })+ .to_string(),+ );+ let terminal_id = created["result"]["root_pane"]["terminal_id"]+ .as_str()+ .expect("created terminal id")+ .to_string();++ let mut attach = spawn_client_process_with_args(+ &config_home,+ &runtime_dir,+ &api_socket,+ &["terminal", "attach", &terminal_id],+ );+ let output = spawn_pty_drain(+ attach+ ._master+ .as_ref()+ .expect("direct attach master")+ .try_clone_reader()+ .expect("clone direct attach PTY reader"),+ );+ assert!(+ wait_until(Duration::from_secs(5), Duration::from_millis(20), || {+ read_output(&output).contains("\x1b[?7l")+ }),+ "direct attach terminal setup should complete; output: {:?}",+ read_output(&output)+ );+ assert!(+ !read_output(&output).contains("\x1b[?1000h"),+ "mouse capture disabled must not enable host mouse reporting; output: {:?}",+ read_output(&output)+ );++ attach+ ._master+ .as_ref()+ .expect("direct attach master")+ .take_writer()+ .expect("direct attach PTY writer")+ .write_all(b"\x02q")+ .expect("detach direct attach client");+ assert!(+ wait_until(Duration::from_secs(5), Duration::from_millis(20), || {+ attach.child.try_wait().ok().flatten().is_some()+ }),+ "direct attach client should detach"+ );+ drop(attach);++ fs::write(+ &config_path,+ "onboarding = false\n[ui]\nmouse_capture = true\n",+ )+ .unwrap();+ let attach = spawn_client_process_with_args(+ &config_home,+ &runtime_dir,+ &api_socket,+ &["terminal", "attach", &terminal_id],+ );+ let output = spawn_pty_drain(+ attach+ ._master+ .as_ref()+ .expect("direct attach master")+ .try_clone_reader()+ .expect("clone direct attach PTY reader"),+ );+ assert!(+ wait_until(Duration::from_secs(5), Duration::from_millis(20), || {+ read_output(&output).contains("\x1b[?7l")+ }),+ "direct attach terminal setup should complete; output: {:?}",+ read_output(&output)+ );+ assert!(+ read_output(&output).contains("\x1b[?1000h"),+ "mouse capture enabled must retain host mouse reporting; output: {:?}",+ read_output(&output)+ );++ drop(spawned_server);+ cleanup_spawned_herdr(attach, base);+}+#[test]fn client_sees_headless_startup_config_diagnostic() {let _lock = test_lock();