commit 9dea6f83985e8c0b7694bd191fb8de52b97ea629
parent f242df85b1ae50a9afd504aef32764727e3c05c1
Author: William Casarin <jb55@jb55.com>
Date: Mon, 26 Jan 2026 18:50:21 -0800
dave: fix N key spawning duplicate agents
The N key was being handled in two places:
1. Global keybindings (keybindings.rs) - returns KeyAction::NewAgent
2. Scene local handler (scene.rs) - returns SceneAction::SpawnAgent
Both handlers fired on the same keypress, causing two agents to be
created at the same position. Removed the duplicate handler from
scene.rs since global keybindings already handles it.
Also use consume_key for Tab handling to prevent egui's native widget
focus navigation from also processing the key.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Diffstat:
2 files changed, 12 insertions(+), 18 deletions(-)
diff --git a/crates/notedeck_dave/src/ui/keybindings.rs b/crates/notedeck_dave/src/ui/keybindings.rs
@@ -29,13 +29,12 @@ pub fn check_keybindings(ctx: &egui::Context, has_pending_permission: bool) -> O
}
// Tab / Shift+Tab for cycling through agents (works even with text input focus)
- if let Some(action) = ctx.input(|i| {
- if i.key_pressed(Key::Tab) {
- if i.modifiers.shift {
- Some(KeyAction::PreviousAgent)
- } else {
- Some(KeyAction::NextAgent)
- }
+ // We use input_mut to consume the Tab key so egui's native widget focus navigation doesn't also process it
+ if let Some(action) = ctx.input_mut(|i| {
+ if i.consume_key(egui::Modifiers::NONE, Key::Tab) {
+ Some(KeyAction::NextAgent)
+ } else if i.consume_key(egui::Modifiers::SHIFT, Key::Tab) {
+ Some(KeyAction::PreviousAgent)
} else {
None
}
diff --git a/crates/notedeck_dave/src/ui/scene.rs b/crates/notedeck_dave/src/ui/scene.rs
@@ -257,17 +257,12 @@ impl AgentScene {
}
// Handle keyboard input (only when no text input has focus)
- if !ui.ctx().wants_keyboard_input() {
- if ui.input(|i| i.key_pressed(egui::Key::Delete) || i.key_pressed(egui::Key::Backspace))
- && !self.selected.is_empty()
- {
- response = SceneResponse::new(SceneAction::DeleteSelected);
- }
-
- // Handle 'n' key to spawn new agent
- if ui.input(|i| i.key_pressed(egui::Key::N)) {
- response = SceneResponse::new(SceneAction::SpawnAgent);
- }
+ // Note: N key for spawning agents is handled globally in keybindings.rs
+ if !ui.ctx().wants_keyboard_input()
+ && ui.input(|i| i.key_pressed(egui::Key::Delete) || i.key_pressed(egui::Key::Backspace))
+ && !self.selected.is_empty()
+ {
+ response = SceneResponse::new(SceneAction::DeleteSelected);
}
// Handle box selection completion