Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

fix(host): pause send's timeout for an approval older than the catch-up

leepokai2e2d998e90bd
diff --git a/host/src/send_cli/events.rs b/host/src/send_cli/events.rs
index fb99daf0..5afa6746 100644
--- a/host/src/send_cli/events.rs
+++ b/host/src/send_cli/events.rs
@@ -254,8 +254,9 @@ impl State {
fn update_pause(&mut self) {
let Some(t) = self.tracking.as_mut() else { return };
- let pending = self.bots.get(&t.bot).is_some_and(|b| b["status"] == "needsInput")
- && self.permissions.values().any(|p| p["botId"] == t.bot && p["data"]["status"] == "pending");
+ // The host sets `needsInput` only while an approval card waits, and that card can be older than the
+ // catch-up's newest 200 entries: the status alone says the bot is waiting for the user.
+ let pending = self.bots.get(&t.bot).is_some_and(|b| b["status"] == "needsInput");
if pending {
t.pause_started.get_or_insert_with(Instant::now);
} else if let Some(start) = t.pause_started.take() {
diff --git a/host/tests/send_cli_e2e.rs b/host/tests/send_cli_e2e.rs
index f911d6b5..4bb7e33d 100644
--- a/host/tests/send_cli_e2e.rs
+++ b/host/tests/send_cli_e2e.rs
@@ -282,3 +282,14 @@ async fn an_approval_from_before_the_send_is_reported_and_pauses_the_clock() {
1
);
}
+
+#[tokio::test]
+async fn an_approval_card_older_than_the_catch_up_still_pauses_the_clock() {
+ let host = Host::start().await;
+ let mock = MockHost::start(Mode::ApprovalOutsideCatchUp, &host.token).await;
+ let output =
+ host.run(&["--port", &mock.port, "--bot", "Transport", "--wait", "--json", "--timeout", "2", "test"]).await;
+ let result = json_output(&output, 0);
+ assert_eq!(result["status"], "completed");
+ assert!(result["waitedForApprovalSeconds"].as_f64().unwrap() >= 2.5);
+}
diff --git a/host/tests/send_cli_e2e/transport.rs b/host/tests/send_cli_e2e/transport.rs
index 2eda1e9e..d6068c65 100644
--- a/host/tests/send_cli_e2e/transport.rs
+++ b/host/tests/send_cli_e2e/transport.rs
@@ -21,6 +21,8 @@ pub enum Mode {
Rejected,
Resync,
PriorApproval,
+ /// Waiting for an approval whose card is older than the catch-up.
+ ApprovalOutsideCatchUp,
}
#[derive(Clone)]
@@ -84,6 +86,8 @@ async fn events_stream(State(state): State<Shared>) -> Sse<impl Stream<Item = Re
// `rev` is ahead of the catch-up, as after a write no event carries (a memory file, say).
let head = if state.mode == Mode::PriorApproval {
vec![json!({"type":"hello","rev":9,"catchUp":2}), bot("needsInput", 1), permission("pending", 2)]
+ } else if state.mode == Mode::ApprovalOutsideCatchUp {
+ vec![json!({"type":"hello","rev":9,"catchUp":1}), bot("needsInput", 1)]
} else {
vec![json!({"type":"hello","rev":9,"catchUp":1}), bot("idle", 1)]
};
@@ -109,10 +113,12 @@ async fn send(State(state): State<Shared>, Json(body): Json<Value>) -> Response
if state.mode == Mode::Resync {
let _ = state.events.send(json!({"type":"resync"}));
}
- if matches!(state.mode, Mode::EarlyFinal | Mode::PriorApproval) {
+ if matches!(state.mode, Mode::EarlyFinal | Mode::PriorApproval | Mode::ApprovalOutsideCatchUp) {
tokio::spawn(async move {
- if state.mode == Mode::PriorApproval {
+ if matches!(state.mode, Mode::PriorApproval | Mode::ApprovalOutsideCatchUp) {
tokio::time::sleep(Duration::from_secs(3)).await;
+ }
+ if state.mode == Mode::PriorApproval {
let _ = state.events.send(permission("approved", 3));
}
let _ = state.events.send(json!({"type":"entry","rev":3,"entry":entry("queued", 3)}));