notedeck

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

commit d04c945646c312e92d1c8f6575bc82bee2ddc2ba
parent 5ca4820d20c6608f876c0f35a3dbe76986a4b275
Author: William Casarin <jb55@jb55.com>
Date:   Tue, 27 Jan 2026 09:09:36 -0800

dave: fix input losing focus when Ctrl is pressed

The input would lose focus when pressing Ctrl because UI elements
(StatusBadge + keybind hint) were being conditionally added to the
layout. In a right_to_left layout, this shifted the text input
position, causing egui to lose focus.

Fix by painting the Ctrl+P hint as an overlay using paint_keybind_hint()
which doesn't allocate layout space. This allows Ctrl+V paste to work
while still showing the helpful visual indicator.

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

Diffstat:
Mcrates/notedeck_dave/src/ui/dave.rs | 25+++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/crates/notedeck_dave/src/ui/dave.rs b/crates/notedeck_dave/src/ui/dave.rs @@ -616,22 +616,15 @@ impl<'a> DaveUi<'a> { dave_response = DaveResponse::send(); } - // Show plan mode indicator or Ctrl+P hint + // Show plan mode indicator when active let ctrl_held = ui.input(|i| i.modifiers.ctrl); if self.plan_mode_active { - super::badge::StatusBadge::new("PLAN") - .variant(super::badge::BadgeVariant::Info) - .show(ui) - .on_hover_text("Ctrl+P to toggle plan mode"); + let mut badge = super::badge::StatusBadge::new("PLAN") + .variant(super::badge::BadgeVariant::Info); if ctrl_held { - super::keybind_hint(ui, "P"); + badge = badge.keybind("P"); } - } else if ctrl_held { - // Show temporary plan hint when Ctrl is held - super::badge::StatusBadge::new("Plan") - .variant(super::badge::BadgeVariant::Default) - .show(ui); - super::keybind_hint(ui, "P"); + badge.show(ui).on_hover_text("Ctrl+P to toggle plan mode"); } let r = ui.add( @@ -656,6 +649,14 @@ 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) + // 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); + super::paint_keybind_hint(ui, hint_pos, "P", 18.0); + } + // Request focus if flagged (e.g., after spawning a new agent) if *self.focus_requested { r.request_focus();