hive-bash-mcp: send queued output ahead of a status
This commit is contained in:
parent
c0b9c1778c
commit
a4b2ef0814
1 changed files with 11 additions and 7 deletions
|
|
@ -203,13 +203,10 @@ async fn run(
|
|||
let period = Duration::from_secs(bash_task::HEARTBEAT_S.unsigned_abs());
|
||||
let mut beat = tokio::time::interval_at(tokio::time::Instant::now() + period, period);
|
||||
loop {
|
||||
// Output first: a task's last chunks are queued before its final status,
|
||||
// and taking queued output ahead of a status keeps that order on the wire.
|
||||
tokio::select! {
|
||||
Some(event) = status_rx.recv() => {
|
||||
if let Event::Status { task, status } = event {
|
||||
apply(&mut live, &task, &status);
|
||||
publish_status(&mut queue, &target, &task, &status).await;
|
||||
}
|
||||
}
|
||||
biased;
|
||||
event = output_rx.recv() => {
|
||||
let Some(Event::Output { task, stream, text }) = event else { return };
|
||||
let missed = dropped.swap(0, Ordering::Relaxed);
|
||||
|
|
@ -218,6 +215,12 @@ async fn run(
|
|||
}
|
||||
publish_output(&mut queue, &target, &task, stream, &text).await;
|
||||
}
|
||||
Some(event) = status_rx.recv() => {
|
||||
if let Event::Status { task, status } = event {
|
||||
apply(&mut live, &task, &status);
|
||||
publish_status(&mut queue, &target, &task, &status).await;
|
||||
}
|
||||
}
|
||||
_ = beat.tick() => {
|
||||
for (task, status) in refresh(&mut live, unix_now()) {
|
||||
publish_status(&mut queue, &target, &task, &status).await;
|
||||
|
|
|
|||
Loading…
Reference in a new issue