notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit 683db21f8017eebeaacbfba8db19cde73993a424
parent 832d9bf07439714dbb0254015299e30a21a466f5
Author: William Casarin <jb55@jb55.com>
Date:   Tue, 27 Jan 2026 11:38:51 -0800

dave: fix Ctrl+P losing input focus

Two fixes for focus loss when toggling plan mode:

1. Request focus after TogglePlanMode action completes, matching the
   pattern used by other keybinding handlers

2. Show PLAN badge without embedded keybind to keep layout stable,
   painting the keybind hint as an overlay instead (same approach
   used for the non-plan-mode Ctrl+P hint)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Diffstat:
Mcrates/notedeck_dave/src/lib.rs | 4++++
Mcrates/notedeck_dave/src/ui/dave.rs | 33++++++++++++++++++++-------------
2 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/crates/notedeck_dave/src/lib.rs b/crates/notedeck_dave/src/lib.rs @@ -945,6 +945,10 @@ impl notedeck::App for Dave { } KeyAction::TogglePlanMode => { self.toggle_plan_mode(ui.ctx()); + // Restore input focus after toggling plan mode + if let Some(session) = self.session_manager.get_active_mut() { + session.focus_requested = true; + } } KeyAction::DeleteActiveSession => { if let Some(id) = self.session_manager.active_id() { diff --git a/crates/notedeck_dave/src/ui/dave.rs b/crates/notedeck_dave/src/ui/dave.rs @@ -680,16 +680,18 @@ impl<'a> DaveUi<'a> { dave_response = DaveResponse::send(); } - // Show plan mode indicator when active + // Show plan mode indicator when active (without keybind to keep layout stable) let ctrl_held = ui.input(|i| i.modifiers.ctrl); - if self.plan_mode_active { - let mut badge = super::badge::StatusBadge::new("PLAN") - .variant(super::badge::BadgeVariant::Info); - if ctrl_held { - badge = badge.keybind("P"); - } - badge.show(ui).on_hover_text("Ctrl+P to toggle plan mode"); - } + let plan_badge_response = if self.plan_mode_active { + Some( + super::badge::StatusBadge::new("PLAN") + .variant(super::badge::BadgeVariant::Info) + .show(ui) + .on_hover_text("Ctrl+P to toggle plan mode"), + ) + } else { + None + }; let r = ui.add( egui::TextEdit::multiline(self.input) @@ -713,11 +715,16 @@ impl<'a> DaveUi<'a> { ); notedeck_ui::include_input(ui, &r); - // Show Ctrl+P hint as overlay when Ctrl is held (but not in plan mode) + // Show Ctrl+P hint as overlay when Ctrl is held // Using paint_at() instead of show() avoids layout changes that cause focus loss - if ctrl_held && !self.plan_mode_active { - // Paint the hint near the right side of the input area - let hint_pos = r.rect.right_center() + egui::vec2(-30.0, 0.0); + if ctrl_held { + let hint_pos = if let Some(ref badge_resp) = plan_badge_response { + // Paint near the PLAN badge when in plan mode + badge_resp.rect.right_center() + egui::vec2(4.0, 0.0) + } else { + // Paint near the right side of the input area + r.rect.right_center() + egui::vec2(-30.0, 0.0) + }; super::paint_keybind_hint(ui, hint_pos, "P", 18.0); }