commit dc3d2756716c610909df663b481a880369efd14d
parent 96297f06ac54121c78412174814e830455e57419
Author: William Casarin <jb55@jb55.com>
Date: Mon, 26 Jan 2026 18:14:18 -0800
dave: unfocus input when permission request is pending
This allows keyboard shortcuts (Y/A/N/D) to work for responding to
permission prompts without keystrokes going into the text input field.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Diffstat:
2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/crates/notedeck_dave/src/lib.rs b/crates/notedeck_dave/src/lib.rs
@@ -369,6 +369,8 @@ You are an AI agent for the nostr protocol called Dave, created by Damus. nostr
== crate::agent_status::AgentStatus::Working;
// Render chat UI for selected session
+ let has_pending_permission =
+ !session.pending_permissions.is_empty();
let response = DaveUi::new(
self.model_config.trial,
&session.chat,
@@ -377,6 +379,7 @@ You are an AI agent for the nostr protocol called Dave, created by Damus. nostr
.compact(true)
.is_working(is_working)
.interrupt_pending(interrupt_pending)
+ .has_pending_permission(has_pending_permission)
.ui(app_ctx, ui);
if response.action.is_some() {
@@ -460,9 +463,11 @@ You are an AI agent for the nostr protocol called Dave, created by Damus. nostr
.allocate_new_ui(egui::UiBuilder::new().max_rect(chat_rect), |ui| {
if let Some(session) = self.session_manager.get_active_mut() {
let is_working = session.status() == crate::agent_status::AgentStatus::Working;
+ let has_pending_permission = !session.pending_permissions.is_empty();
DaveUi::new(self.model_config.trial, &session.chat, &mut session.input)
.is_working(is_working)
.interrupt_pending(interrupt_pending)
+ .has_pending_permission(has_pending_permission)
.ui(app_ctx, ui)
} else {
DaveResponse::default()
@@ -516,9 +521,11 @@ You are an AI agent for the nostr protocol called Dave, created by Damus. nostr
let interrupt_pending = self.is_interrupt_pending();
if let Some(session) = self.session_manager.get_active_mut() {
let is_working = session.status() == crate::agent_status::AgentStatus::Working;
+ let has_pending_permission = !session.pending_permissions.is_empty();
DaveUi::new(self.model_config.trial, &session.chat, &mut session.input)
.is_working(is_working)
.interrupt_pending(interrupt_pending)
+ .has_pending_permission(has_pending_permission)
.ui(app_ctx, ui)
} else {
DaveResponse::default()
diff --git a/crates/notedeck_dave/src/ui/dave.rs b/crates/notedeck_dave/src/ui/dave.rs
@@ -94,6 +94,7 @@ impl<'a> DaveUi<'a> {
compact: false,
is_working: false,
interrupt_pending: false,
+ has_pending_permission: false,
}
}
@@ -112,6 +113,11 @@ impl<'a> DaveUi<'a> {
self
}
+ pub fn has_pending_permission(mut self, has_pending_permission: bool) -> Self {
+ self.has_pending_permission = has_pending_permission;
+ self
+ }
+
fn chat_margin(&self, ctx: &egui::Context) -> i8 {
if self.compact || notedeck::ui::is_narrow(ctx) {
20
@@ -617,6 +623,12 @@ impl<'a> DaveUi<'a> {
);
notedeck_ui::include_input(ui, &r);
+ // Unfocus text input when there's a pending permission request
+ // so keyboard shortcuts (Y/A/N/D) can be used to respond
+ if self.has_pending_permission {
+ r.surrender_focus();
+ }
+
if r.has_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter)) {
DaveResponse::send()
} else {