the runtime your coding agents live on
Rust agentagent-orchestrationaiai-agentsclaude-codeclicodexcoding-agentsdeveloper-toolsdevtoolsmultiplexerrustterminalterminal-multiplexerterminal-uitmuxtuiworkspace-manager
feat: add copy-on-select setting
Ogulcan Celik461745634892
diff --git a/docs/next/website/src/content/docs/configuration.mdx b/docs/next/website/src/content/docs/configuration.mdxindex 0822c1977..0f9a7096b 100644--- a/docs/next/website/src/content/docs/configuration.mdx+++ b/docs/next/website/src/content/docs/configuration.mdx@@ -308,6 +308,7 @@ sidebar_max_width = 36sidebar_collapsed_mode = "compact"mobile_width_threshold = 64mouse_capture = true+copy_on_select = truehost_cursor = "auto"right_click_passthrough_modifier = ""redraw_on_focus_gained = true@@ -334,6 +335,8 @@ The agent panel shows all agents across all spaces. `agent_panel_sort` can be `sSet `mouse_capture = false` if you want your terminal to handle normal clicks, such as command-clicking URLs. With mouse capture enabled, Ctrl-click opens pane links when your terminal sends that modified click to Herdr. This includes macOS; Cmd-click is not reported separately from plain click while Herdr captures mouse input. Use Shift-Ctrl-click on Linux or Shift-Cmd-click on macOS for the terminal-native bypass path.+Set `copy_on_select = false` to disable Herdr's mouse drag selection and double-click word copying. The default is `true`.+`host_cursor` controls whether Herdr uses the outer terminal's native cursor or draws its own cursor as terminal cell content. The default, `auto`, draws Herdr's cursor on native Windows builds and WSL to avoid ConPTY cursor flicker during active redraws, and uses the native cursor elsewhere. Set it to `native` to always use the outer terminal cursor, or `drawn` to always use Herdr's drawn cursor.Set `right_click_passthrough_modifier = "ctrl"` if you want Ctrl-right-click, hold, and drag gestures inside mouse-reporting pane apps to reach the app instead of opening Herdr's pane menu. The default is empty, which disables this passthrough. Supported modifiers are `ctrl`, `alt`, `cmd`, `super`, `meta`, and `hyper`; `shift` is rejected because many terminals reserve Shift+mouse for their own mouse bypass.diff --git a/docs/next/website/src/content/docs/ja/configuration.mdx b/docs/next/website/src/content/docs/ja/configuration.mdxindex 33c9d0ddf..a28ad6501 100644--- a/docs/next/website/src/content/docs/ja/configuration.mdx+++ b/docs/next/website/src/content/docs/ja/configuration.mdx@@ -304,6 +304,7 @@ sidebar_min_width = 18sidebar_max_width = 36mobile_width_threshold = 64mouse_capture = true+copy_on_select = trueright_click_passthrough_modifier = ""redraw_on_focus_gained = truemouse_scroll_lines = 3@@ -326,6 +327,8 @@ accent = "cyan"URL の command+クリックなど、通常のクリックをターミナルに処理させたい場合は `mouse_capture = false` を設定してください。マウスキャプチャが有効な場合、ターミナルが修飾キー付きクリックを Herdr に送れば、Ctrl+クリックでペインのリンクを開けます。これは macOS も含みます。Herdr がマウス入力をキャプチャしている間、Cmd+クリックは通常のクリックと区別して報告されません。ターミナルネイティブのバイパス経路には、Linux では Shift+Ctrl+クリック、macOS では Shift+Cmd+クリックを使ってください。+`copy_on_select = false` を設定すると、Herdr のマウスドラッグ選択とダブルクリックによる単語コピーが無効になります。デフォルトは `true` です。+マウスレポーティング対応のペインアプリの中で、Ctrl+右クリック、ホールド、ドラッグのジェスチャーを Herdr のペインメニューを開く代わりにアプリへ届けたい場合は `right_click_passthrough_modifier = "ctrl"` を設定してください。デフォルトは空で、このパススルーは無効です。対応する修飾キーは `ctrl`、`alt`、`cmd`、`super`、`meta`、`hyper` です。多くのターミナルが Shift+マウスを自分のマウスバイパスのために予約しているため、`shift` は拒否されます。Herdr に戻ったときの目に見える全画面リフレッシュを避けるには `redraw_on_focus_gained = false` を設定してください。まれに発生する古い/汚れたホストターミナル表示から全再描画で回復できるため、デフォルトは `true` です。diff --git a/docs/next/website/src/content/docs/zh-cn/configuration.mdx b/docs/next/website/src/content/docs/zh-cn/configuration.mdxindex a80ef2894..44d2ccfcb 100644--- a/docs/next/website/src/content/docs/zh-cn/configuration.mdx+++ b/docs/next/website/src/content/docs/zh-cn/configuration.mdx@@ -304,6 +304,7 @@ sidebar_min_width = 18sidebar_max_width = 36mobile_width_threshold = 64mouse_capture = true+copy_on_select = trueright_click_passthrough_modifier = ""redraw_on_focus_gained = truemouse_scroll_lines = 3@@ -326,6 +327,8 @@ accent = "cyan"如果想让终端处理普通点击,比如 command+点击 URL,设置 `mouse_capture = false`。鼠标捕获启用时,如果终端把带修饰键的点击传给 Herdr,Ctrl+点击可以打开窗格链接。macOS 也是如此;Herdr 捕获鼠标输入期间,Cmd+点击不会与普通点击区分上报。终端原生的绕过路径: Linux 上用 Shift+Ctrl+点击,macOS 上用 Shift+Cmd+点击。+设置 `copy_on_select = false` 可禁用 Herdr 的鼠标拖动选择和双击单词复制。默认值为 `true`。+如果想让 Ctrl+右键点击、按住和拖动手势到达启用鼠标上报的窗格应用,而不是打开 Herdr 的窗格菜单,设置 `right_click_passthrough_modifier = "ctrl"`。默认为空,即禁用这种透传。支持的修饰键有 `ctrl`、`alt`、`cmd`、`super`、`meta` 和 `hyper`;`shift` 被拒绝,因为许多终端把 Shift+鼠标保留给它们自己的鼠标绕过。设置 `redraw_on_focus_gained = false` 可以避免切回 Herdr 时可见的全屏刷新。默认为 `true`,因为完整重绘能从罕见的过期或脏的宿主终端画面中恢复。diff --git a/src/app/input/mod.rs b/src/app/input/mod.rsindex bcd5da984..421b37388 100644--- a/src/app/input/mod.rs+++ b/src/app/input/mod.rs@@ -408,6 +408,11 @@ impl App {}fn handle_pane_double_click(&mut self, mouse: MouseEvent) -> bool {+ if !self.state.copy_on_select {+ self.last_pane_click = None;+ return false;+ }+// A pane press stops being a double-click candidate once it becomes// a drag or completes as a real text selection.match mouse.kind {diff --git a/src/app/input/mouse.rs b/src/app/input/mouse.rsindex 495bcd53b..911e27c09 100644--- a/src/app/input/mouse.rs+++ b/src/app/input/mouse.rs@@ -640,12 +640,14 @@ impl AppState {mouse.row - info.inner_rect.y,mouse.column - info.inner_rect.x,);- self.selection = Some(Selection::anchor(- info.id,- row,- col,- self.pane_scroll_metrics(terminal_runtimes, info.id),- ));+ if self.copy_on_select {+ self.selection = Some(Selection::anchor(+ info.id,+ row,+ col,+ self.pane_scroll_metrics(terminal_runtimes, info.id),+ ));+ }if let Some(ws_idx) = self.active {return Some(MouseAction::FocusPane {ws_idx,diff --git a/src/app/input/terminal.rs b/src/app/input/terminal.rsindex 0fc35bd3c..dd1e811ff 100644--- a/src/app/input/terminal.rs+++ b/src/app/input/terminal.rs@@ -458,6 +458,34 @@ mod tests {assert_visible_selection(&app);}+ #[tokio::test]+ async fn copy_on_select_disabled_ignores_drag_and_double_click_selection() {+ let (mut app, info) = app_with_screen_bytes(b"alpha beta");+ app.state.copy_on_select = false;+ let row = info.inner_rect.y;+ let start_col = info.inner_rect.x;+ let end_col = info.inner_rect.x + 4;++ app.handle_mouse(mouse(+ MouseEventKind::Down(MouseButton::Left),+ start_col,+ row,+ ));+ app.handle_mouse(mouse(MouseEventKind::Drag(MouseButton::Left), end_col, row));+ app.handle_mouse(mouse(MouseEventKind::Up(MouseButton::Left), end_col, row));++ assert!(app.state.selection.is_none());+ assert!(app.state.selection_autoscroll.is_none());+ assert!(app.event_rx.try_recv().is_err());++ double_click(&mut app, start_col, row);++ assert!(app.state.selection.is_none());+ assert!(app.last_pane_click.is_none());+ assert!(app.selection_highlight_clear_deadline.is_none());+ assert!(app.event_rx.try_recv().is_err());+ }+#[tokio::test]async fn double_click_uses_display_columns_for_wide_chars() {let (mut app, info) = app_with_screen_bytes("echo 你好-world done".as_bytes());@@ -730,15 +758,58 @@ mod tests {}#[tokio::test]- async fn double_click_is_forwarded_when_mouse_reporting_is_enabled() {- let (mut app, info) = app_with_screen_bytes(b"\x1b[?1002halpha beta");- let col = info.inner_rect.x + 8;- let row = info.inner_rect.y;- double_click(&mut app, col, row);+ async fn copy_on_select_disabled_still_forwards_mouse_reporting_gestures() {+ let mut app = app_for_mouse_test();+ let mut ws = Workspace::test_new("test");+ let pane_id = ws.tabs[0].root_pane;+ let pane_infos = ws.tabs[0].layout.panes(Rect::new(26, 2, 80, 18));+ let info = pane_infos[0].clone();+ let (runtime, mut input_rx) =+ crate::terminal::TerminalRuntime::test_with_channel_and_scrollback_bytes(+ info.inner_rect.width,+ info.inner_rect.height,+ 0,+ b"\x1b[?1002h\x1b[?1006h",+ 4,+ );+ ws.insert_test_runtime(pane_id, runtime);+ app.state.workspaces = vec![ws];+ app.state.active = Some(0);+ app.state.selected = 0;+ app.state.mode = Mode::Terminal;+ app.state.view.pane_infos = pane_infos;+ app.state.copy_on_select = false;++ let col = info.inner_rect.x + 2;+ let row = info.inner_rect.y + 3;+ app.handle_mouse(mouse(MouseEventKind::Down(MouseButton::Left), col, row));+ app.handle_mouse(mouse(+ MouseEventKind::Drag(MouseButton::Left),+ col + 1,+ row + 1,+ ));+ app.handle_mouse(mouse(+ MouseEventKind::Up(MouseButton::Left),+ col + 1,+ row + 1,+ ));assert!(app.event_rx.try_recv().is_err());assert!(app.state.selection.is_none());assert!(app.selection_highlight_clear_deadline.is_none());+ assert_eq!(+ input_rx.try_recv().expect("forwarded left mouse down"),+ Bytes::from_static(b"\x1b[<0;3;4M")+ );+ assert_eq!(+ input_rx.try_recv().expect("forwarded left mouse drag"),+ Bytes::from_static(b"\x1b[<32;4;5M")+ );+ assert_eq!(+ input_rx.try_recv().expect("forwarded left mouse up"),+ Bytes::from_static(b"\x1b[<0;4;5m")+ );+ assert!(input_rx.try_recv().is_err());}#[tokio::test]diff --git a/src/app/mod.rs b/src/app/mod.rsindex 991813618..1a0c77a3e 100644--- a/src/app/mod.rs+++ b/src/app/mod.rs@@ -600,6 +600,7 @@ impl App {agent_panel_sort,next_agent_state_change_seq: 0,mouse_capture: config.ui.mouse_capture,+ copy_on_select: config.ui.copy_on_select,right_click_passthrough_modifiers: config.ui.right_click_passthrough_modifiers(),right_click_passthrough: None,redraw_on_focus_gained: config.ui.redraw_on_focus_gained,@@ -1358,6 +1359,17 @@ impl App {.sidebar_width.clamp(self.state.sidebar_min_width, self.state.sidebar_max_width);self.state.mouse_capture = config.ui.mouse_capture;+ self.state.copy_on_select = config.ui.copy_on_select;+ if !self.state.copy_on_select {+ if self.state.mode == Mode::Copy {+ self.state.stop_selection_autoscroll_state();+ } else {+ self.state.clear_selection();+ }+ self.last_pane_click = None;+ self.selection_autoscroll_deadline = None;+ self.selection_highlight_clear_deadline = None;+ }if self.state.redraw_on_focus_gained != config.ui.redraw_on_focus_gained {self.state.request_client_config_reload = true;}@@ -2524,12 +2536,35 @@ mod tests {std::fs::create_dir_all(path.parent().unwrap()).unwrap();std::fs::write(&path,- "[terminal]\ndefault_shell = \"nu\"\nshell_mode = \"non_login\"\nnew_cwd = \"home\"\n[keys]\nnew_workspace = \"prefix+m\"\nprefix = \"ctrl+a\"\n[update]\nversion_check = false\nmanifest_check = false\n[ui]\nagent_panel_scope = \"current\"\nagent_panel_sort = \"priority\"\nredraw_on_focus_gained = false\nright_click_passthrough_modifier = \"ctrl\"\n[ui.toast]\ndelivery = \"herdr\"\n[experimental]\nswitch_ascii_input_source_in_prefix = true\n",+ "[terminal]\ndefault_shell = \"nu\"\nshell_mode = \"non_login\"\nnew_cwd = \"home\"\n[keys]\nnew_workspace = \"prefix+m\"\nprefix = \"ctrl+a\"\n[update]\nversion_check = false\nmanifest_check = false\n[ui]\nagent_panel_scope = \"current\"\nagent_panel_sort = \"priority\"\nredraw_on_focus_gained = false\ncopy_on_select = false\nright_click_passthrough_modifier = \"ctrl\"\n[ui.toast]\ndelivery = \"herdr\"\n[experimental]\nswitch_ascii_input_source_in_prefix = true\n",).unwrap();std::env::set_var(crate::config::CONFIG_PATH_ENV_VAR, &path);let mut app = test_app();+ let selection_pane = crate::layout::PaneId::alloc();+ app.state.selection = Some(crate::selection::Selection::range(+ selection_pane,+ 0,+ 0,+ 1,+ None,+ ));+ app.state.selection_autoscroll = Some(state::SelectionAutoscroll {+ direction: state::SelectionAutoscrollDirection::Down,+ last_mouse_screen_col: 1,+ last_mouse_screen_row: 1,+ inner_rect: ratatui::layout::Rect::new(0, 0, 2, 2),+ });+ let selection_deadline = Instant::now();+ app.selection_autoscroll_deadline = Some(selection_deadline);+ app.selection_highlight_clear_deadline = Some(selection_deadline);+ app.last_pane_click = Some(PaneClickState {+ pane_id: selection_pane,+ viewport_row: 0,+ col: 0,+ at: selection_deadline,+ });app.next_auto_update_check = Some(Instant::now());app.next_agent_manifest_update_check = Some(Instant::now());let report = app.reload_config();@@ -2548,6 +2583,24 @@ mod tests {);assert_eq!(app.state.agent_panel_sort, state::AgentPanelSort::Priority);assert!(!app.state.redraw_on_focus_gained);+ assert!(!app.state.copy_on_select);+ assert!(app.state.selection.is_none());+ assert!(app.state.selection_autoscroll.is_none());+ assert!(app.selection_autoscroll_deadline.is_none());+ assert!(app.selection_highlight_clear_deadline.is_none());+ assert!(app.last_pane_click.is_none());++ app.state.mode = Mode::Copy;+ app.state.selection = Some(crate::selection::Selection::range(+ selection_pane,+ 0,+ 0,+ 1,+ None,+ ));+ let report = app.reload_config();+ assert_eq!(report.status, crate::config::ConfigReloadStatus::Applied);+ assert!(app.state.selection.is_some());assert_eq!(app.state.right_click_passthrough_modifiers,Some(KeyModifiers::CONTROL)diff --git a/src/app/state.rs b/src/app/state.rsindex 338c9ca39..be858678d 100644--- a/src/app/state.rs+++ b/src/app/state.rs@@ -1407,6 +1407,7 @@ pub struct AppState {/// Capture mouse input for Herdr's own mouse UI. When false, Herdr only/// captures mouse while the focused pane app requests mouse reporting.pub mouse_capture: bool,+ pub copy_on_select: bool,pub right_click_passthrough_modifiers: Option<KeyModifiers>,pub right_click_passthrough: Option<RightClickPassthroughGesture>,pub redraw_on_focus_gained: bool,@@ -1765,6 +1766,7 @@ impl AppState {agent_panel_sort: AgentPanelSort::Spaces,next_agent_state_change_seq: 0,mouse_capture: true,+ copy_on_select: true,right_click_passthrough_modifiers: None,right_click_passthrough: None,redraw_on_focus_gained: true,diff --git a/src/config/model.rs b/src/config/model.rsindex c45f1b7a2..16bc595df 100644--- a/src/config/model.rs+++ b/src/config/model.rs@@ -786,6 +786,8 @@ pub struct UiConfig {pub mobile_width_threshold: u16,/// Capture mouse input for Herdr's mouse UI. Default: true.pub mouse_capture: bool,+ /// Copy text selected with the mouse. Default: true.+ pub copy_on_select: bool,/// Host cursor policy. Default: auto.pub host_cursor: HostCursorModeConfig,/// Modifier that lets right-click gestures pass through to pane apps. Empty disables it.@@ -989,6 +991,7 @@ impl Default for UiConfig {sidebar_collapsed_mode: SidebarCollapsedModeConfig::Compact,mobile_width_threshold: DEFAULT_MOBILE_WIDTH_THRESHOLD,mouse_capture: true,+ copy_on_select: true,host_cursor: HostCursorModeConfig::Auto,right_click_passthrough_modifier: RightClickPassthroughModifierConfig::default(),redraw_on_focus_gained: true,@@ -1398,6 +1401,19 @@ mouse_capture = falseassert!(!config.ui.mouse_capture);}+ #[test]+ fn copy_on_select_default_on_and_parse() {+ let default_config = Config::default();+ assert!(default_config.ui.copy_on_select);++ let toml = r#"+[ui]+copy_on_select = false+"#;+ let config: Config = toml::from_str(toml).unwrap();+ assert!(!config.ui.copy_on_select);+ }+#[test]fn right_click_passthrough_modifier_defaults_off_and_parses() {let default_config = Config::default();diff --git a/src/main.rs b/src/main.rsindex a439ad34e..57ca4dc22 100644--- a/src/main.rs+++ b/src/main.rs@@ -259,6 +259,10 @@ const DEFAULT_CONFIG: &str = r##"# herdr configuration# Pane apps like lazygit and btop can still receive mouse when they request it.# mouse_capture = true+# Copy text selected by mouse drag or double-click.+# Set false to disable mouse text selection and copying.+# copy_on_select = true+# Host cursor policy: "auto", "native", or "drawn".# "auto" draws Herdr's own cursor on native Windows builds and WSL to avoid ConPTY cursor flicker, and uses the native terminal cursor elsewhere.# "native" always uses the outer terminal cursor. "drawn" always draws Herdr's cursor as terminal cell content.