From c4a8d281d4a569c658fcd7f4cda425d683dd4be6 Mon Sep 17 00:00:00 2001 From: kumabook Date: Sat, 15 Aug 2026 21:10:26 +0900 Subject: [PATCH] Stabilize tmux input submission --- reattachd/src/tmux/send.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/reattachd/src/tmux/send.rs b/reattachd/src/tmux/send.rs index aefdb01..625d76d 100644 --- a/reattachd/src/tmux/send.rs +++ b/reattachd/src/tmux/send.rs @@ -1,7 +1,9 @@ -use std::process::Command; +use std::{process::Command, thread, time::Duration}; use crate::tmux::TmuxError; +const SUBMIT_DELAY: Duration = Duration::from_millis(100); + pub fn send_keys(target: &str, text: &str) -> Result<(), TmuxError> { let output = Command::new("tmux") .args(["send-keys", "-t", target, "-l", text]) @@ -13,6 +15,10 @@ pub fn send_keys(target: &str, text: &str) -> Result<(), TmuxError> { return Err(TmuxError::Command(stderr.to_string())); } + // Keep the submit key out of terminal applications' rapid-input/paste + // detection so that it is consistently handled as Enter. + thread::sleep(SUBMIT_DELAY); + let output = Command::new("tmux") .args(["send-keys", "-t", target, "Enter"]) .output()