diff --git a/src/bin/poc-daemon/main.rs b/src/bin/poc-daemon/main.rs index 31bd01a..337354e 100644 --- a/src/bin/poc-daemon/main.rs +++ b/src/bin/poc-daemon/main.rs @@ -116,6 +116,11 @@ enum Command { /// Value to set (omit to query) value: Option, }, + /// Send a test message to the Claude pane + TestSend { + /// Message to send + message: Vec, + }, /// Dump full internal state as JSON Debug, /// Shut down daemon @@ -256,6 +261,17 @@ async fn client_main(cmd: Command) -> Result<(), Box> { req.get().set_seconds(seconds.unwrap_or(300)); req.send().promise.await?; } + Command::TestSend { message } => { + let msg = message.join(" "); + let pane = { + let reply = daemon.status_request().send().promise.await?; + let s = reply.get()?.get_status()?; + s.get_claude_pane()?.to_str()?.to_string() + }; + let ok = crate::tmux::send_prompt(&pane, &msg); + println!("send_prompt(pane={}, ok={}): {}", pane, ok, msg); + return Ok(()); + } Command::Afk => { daemon.afk_request().send().promise.await?; println!("marked AFK"); diff --git a/src/bin/poc-daemon/tmux.rs b/src/bin/poc-daemon/tmux.rs index dc5dc49..e8f71c7 100644 --- a/src/bin/poc-daemon/tmux.rs +++ b/src/bin/poc-daemon/tmux.rs @@ -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 {