Watch
0
0
Fork
You've already forked hyperhive
0

hive-bash-mcp: send queued output ahead of a status

This commit is contained in:
damocles 2026-11-15 17:57:47 +01:00
commit a4b2ef0814

View file

@ -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;