daemon: add test-send subcommand, flatten newlines in send_prompt

test-send calls send_prompt() directly for debugging tmux delivery.
Flatten newlines to spaces in literal mode to prevent premature
input submission.

Co-Authored-By: ProofOfConcept <poc@bcachefs.org>
This commit is contained in:
Kent Overstreet 2026-03-08 19:41:32 -04:00
parent 46f8fe662e
commit e2f3a5a364
2 changed files with 19 additions and 2 deletions

View file

@ -35,9 +35,10 @@ pub fn send_prompt(pane: &str, msg: &str) -> bool {
let preview: String = msg.chars().take(100).collect();
info!("SEND [{pane}]: {preview}...");
// Type the message literally
// Type the message literally (flatten newlines — they'd submit the input early)
let flat: String = msg.chars().map(|c| if c == '\n' { ' ' } else { c }).collect();
let ok = Command::new("tmux")
.args(["send-keys", "-t", pane, "-l", msg])
.args(["send-keys", "-t", pane, "-l", &flat])
.output()
.is_ok();
if !ok {