commit aa22d1916da51fa80e0e79a07018b26ca494e135
parent 7a72d5be17acfa417f64e44661213daf86688c5e
Author: William Casarin <jb55@jb55.com>
Date: Mon, 9 Feb 2026 15:56:36 -0800
dave: raise OS window when auto-steal focus switches sessions
When auto-steal focus mode is active and a session transitions to
NeedsInput, send ViewportCommand::Focus to bring the window to the
foreground so the user doesn't have to manually switch to it.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat:
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/crates/notedeck_dave/src/lib.rs b/crates/notedeck_dave/src/lib.rs
@@ -897,7 +897,7 @@ impl notedeck::App for Dave {
self.focus_queue.update_from_statuses(status_iter);
// Process auto-steal focus mode
- update::process_auto_steal_focus(
+ let stole_focus = update::process_auto_steal_focus(
&mut self.session_manager,
&mut self.focus_queue,
&mut self.scene,
@@ -906,6 +906,12 @@ impl notedeck::App for Dave {
&mut self.home_session,
);
+ // Raise the OS window when auto-steal switches to a NeedsInput session
+ if stole_focus {
+ ui.ctx()
+ .send_viewport_cmd(egui::ViewportCommand::Focus);
+ }
+
// Render UI and handle actions
if let Some(action) = self.ui(ctx, ui).action {
if let Some(returned_action) = self.handle_ui_action(action, ctx, ui) {
diff --git a/crates/notedeck_dave/src/update.rs b/crates/notedeck_dave/src/update.rs
@@ -534,6 +534,8 @@ pub fn toggle_auto_steal(
}
/// Process auto-steal focus logic: switch to focus queue items as needed.
+/// Returns true if focus was stolen (switched to a NeedsInput session),
+/// which can be used to raise the OS window.
pub fn process_auto_steal_focus(
session_manager: &mut SessionManager,
focus_queue: &mut FocusQueue,
@@ -541,9 +543,9 @@ pub fn process_auto_steal_focus(
show_scene: bool,
auto_steal_focus: bool,
home_session: &mut Option<SessionId>,
-) {
+) -> bool {
if !auto_steal_focus {
- return;
+ return false;
}
let has_needs_input = focus_queue.has_needs_input();
@@ -575,6 +577,7 @@ pub fn process_auto_steal_focus(
}
}
tracing::debug!("Auto-steal: switched to session {:?}", entry.session_id);
+ return true;
}
}
}
@@ -591,6 +594,8 @@ pub fn process_auto_steal_focus(
}
tracing::debug!("Auto-steal: returned to home session {:?}", home_id);
}
+
+ false
}
// =============================================================================