aboutsummaryrefslogtreecommitdiff
path: root/src/pane.rs
diff options
context:
space:
mode:
authorJJ Liebig <jonathan.liebig@gmail.com>2026-09-02 15:34:03 +0400
committerGitHub <noreply@github.com>2026-09-02 13:34:03 +0200
commit8633a398e653eee47b375c963996c78a8a14aa48 (patch)
tree459c5063c2560883cefd2112d725ce500c3d5a02 /src/pane.rs
parent6c0bb273d5d5405a00985621b17e36f8b4d64609 (diff)
fix: reliably submit delayed agent prompts (#3506)
Diffstat (limited to 'src/pane.rs')
-rw-r--r--src/pane.rs40
1 files changed, 25 insertions, 15 deletions
diff --git a/src/pane.rs b/src/pane.rs
index 48928034..c71665f5 100644
--- a/src/pane.rs
+++ b/src/pane.rs
@@ -1181,24 +1181,29 @@ impl PaneRuntimeIo {
}
}
- fn send_bytes_after(&self, bytes: Bytes, delay: std::time::Duration) {
+ fn queue_user_input_submission(
+ &self,
+ text: Bytes,
+ enter: Bytes,
+ delay: std::time::Duration,
+ ) -> std::io::Result<std::sync::mpsc::Receiver<std::io::Result<()>>> {
match self {
- PaneRuntimeIo::Actor(actor) => {
- let actor = actor.clone();
- tokio::spawn(async move {
- tokio::time::sleep(delay).await;
- if let Err(err) = actor.write_user_input(bytes).await {
- warn!(error = %err, "failed to send delayed PTY input");
- }
- });
- }
+ PaneRuntimeIo::Actor(actor) => actor.queue_user_input_submission(text, enter, delay),
#[cfg(test)]
PaneRuntimeIo::TestChannel { sender, .. } => {
let sender = sender.clone();
- tokio::spawn(async move {
- tokio::time::sleep(delay).await;
- let _ = sender.send(bytes).await;
+ let (reply_tx, reply_rx) = std::sync::mpsc::channel();
+ std::thread::spawn(move || {
+ let result = sender
+ .try_send(text)
+ .map_err(std::io::Error::other)
+ .and_then(|()| {
+ std::thread::sleep(delay);
+ sender.try_send(enter).map_err(std::io::Error::other)
+ });
+ let _ = reply_tx.send(result);
});
+ Ok(reply_rx)
}
}
}
@@ -2856,8 +2861,13 @@ impl PaneRuntime {
self.io.try_send_bytes(bytes)
}
- pub fn send_bytes_after(&self, bytes: Bytes, delay: std::time::Duration) {
- self.io.send_bytes_after(bytes, delay);
+ pub fn queue_user_input_submission(
+ &self,
+ text: Bytes,
+ enter: Bytes,
+ delay: std::time::Duration,
+ ) -> std::io::Result<std::sync::mpsc::Receiver<std::io::Result<()>>> {
+ self.io.queue_user_input_submission(text, enter, delay)
}
pub fn try_send_paste(&self, text: String) -> Result<(), mpsc::error::TrySendError<Bytes>> {