fix manager loop: pending wake + move sleep into Empty arm only
This commit is contained in:
parent
f2a0dc4107
commit
25508d7399
1 changed files with 11 additions and 2 deletions
|
|
@ -134,8 +134,18 @@ async fn serve(
|
||||||
let outcome = turn::drive_turn(&prompt, files, &bus).await;
|
let outcome = turn::drive_turn(&prompt, files, &bus).await;
|
||||||
turn::emit_turn_end(&bus, &outcome);
|
turn::emit_turn_end(&bus, &outcome);
|
||||||
bus.set_state(TurnState::Idle);
|
bus.set_state(TurnState::Idle);
|
||||||
|
// Check for messages that arrived during the turn and loop
|
||||||
|
// immediately if any are waiting — mirrors hive-ag3nt behaviour.
|
||||||
|
let pending = inbox_unread(socket).await;
|
||||||
|
if pending > 0 {
|
||||||
|
tracing::info!(%pending, "pending messages after turn; fetching next");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(ManagerResponse::Empty) => {
|
||||||
|
// Idle: sleep briefly before next long-poll attempt.
|
||||||
|
tokio::time::sleep(interval).await;
|
||||||
}
|
}
|
||||||
Ok(ManagerResponse::Empty) => {}
|
|
||||||
Ok(
|
Ok(
|
||||||
ManagerResponse::Ok
|
ManagerResponse::Ok
|
||||||
| ManagerResponse::Status { .. }
|
| ManagerResponse::Status { .. }
|
||||||
|
|
@ -151,7 +161,6 @@ async fn serve(
|
||||||
tracing::warn!(error = ?e, "recv failed; retrying");
|
tracing::warn!(error = ?e, "recv failed; retrying");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tokio::time::sleep(interval).await;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue