tui: /yolo works while a turn runs; '!' on permission prompt allows and enables yolo

This commit is contained in:
hermes committed 2026-10-17 13:52:39 +00:00
1 parent 43944eb6b5
commit 5171e7458a
3 files changed
+18 -2

No files matched your search

+4
View File
@@ -366,6 +366,10 @@ impl Allow {
})
}
pub fn yolo_on(&self) -> bool {
self.yolo
}
/// Toggle: allow everything (not persisted); returns the new state.
pub fn toggle_yolo(&mut self) -> bool {
self.yolo = !self.yolo;
+13 -1
View File
@@ -453,6 +453,18 @@ pub async fn run(setup: Setup) -> std::io::Result<()> {
dirty = true;
match ev {
TEvent::Key(k) if k.kind != KeyEventKind::Release && app.perm.is_some() => {
if k.code == KeyCode::Char('!') {
let mut a = app.state.allow.lock().unwrap_or_else(|e| e.into_inner());
if !a.yolo_on() {
a.toggle_yolo();
}
drop(a);
if let Some((p, reply)) = app.perm.take() {
app.t.push(Item::Info(format!("yolo on; allowed {} {}", p.req.tool, p.req.detail)));
let _ = reply.send(hx_core::permit::Decision::Once);
}
continue;
}
if let Some((p, _)) = &mut app.perm
&& let Some(d) = p.key(k)
&& let Some((p, reply)) = app.perm.take()
@@ -1272,7 +1284,7 @@ async fn submit(app: &mut App, mut line: String, c: &Ctx<'_>) {
let (c, arg) = cmd
.split_once(' ')
.map_or((cmd, ""), |(a, b)| (a, b.trim()));
if app.busy && !matches!(c, "quit" | "btw") {
if app.busy && !matches!(c, "quit" | "btw" | "yolo") {
app.t.push(Item::Error("busy; esc to abort first".into()));
return;
}