herdr support: report idle/working/blocked, resume command, release
This commit is contained in:
1 parent
b223fd1f22
commit
789ee75a27
7 files changed
+287
-3
No files matched your search
@@ -267,24 +267,39 @@ pub async fn run(setup: Setup) -> std::io::Result<()> {
|
||||
.ask
|
||||
.set(std::sync::Arc::new(move |q: String| {
|
||||
let (otx, orx) = tokio::sync::oneshot::channel();
|
||||
hx_core::herdr::blocked(q.clone());
|
||||
let _ = tx.send(Ui::Ask(q, otx));
|
||||
Box::pin(async move { orx.await.unwrap_or(false) })
|
||||
Box::pin(async move {
|
||||
let r = orx.await.unwrap_or(false);
|
||||
hx_core::herdr::working();
|
||||
r
|
||||
})
|
||||
}));
|
||||
}
|
||||
if !yolo {
|
||||
let tx = tx.clone();
|
||||
let _ = agent.cx.state.permit.set(std::sync::Arc::new(move |r| {
|
||||
let (otx, orx) = tokio::sync::oneshot::channel();
|
||||
hx_core::herdr::blocked(format!("{}: {}", r.tool, r.detail));
|
||||
let _ = tx.send(Ui::Permit(r, otx));
|
||||
Box::pin(async move { orx.await.unwrap_or(hx_core::permit::Decision::Deny) })
|
||||
Box::pin(async move {
|
||||
let d = orx.await.unwrap_or(hx_core::permit::Decision::Deny);
|
||||
hx_core::herdr::working();
|
||||
d
|
||||
})
|
||||
}));
|
||||
}
|
||||
{
|
||||
let tx = tx.clone();
|
||||
let _ = agent.cx.state.choose.set(std::sync::Arc::new(move |q| {
|
||||
let (otx, orx) = tokio::sync::oneshot::channel();
|
||||
hx_core::herdr::blocked("choose an option");
|
||||
let _ = tx.send(Ui::Choose(q, otx));
|
||||
Box::pin(async move { orx.await.unwrap_or(None) })
|
||||
Box::pin(async move {
|
||||
let c = orx.await.unwrap_or(None);
|
||||
hx_core::herdr::working();
|
||||
c
|
||||
})
|
||||
}));
|
||||
}
|
||||
let (stx, mut srx) = mpsc::unbounded_channel();
|
||||
|
||||
Reference in new issue
Block a user