commit 592d330403ffa1ef6803a54e92308d2fb07fb49a
parent 6683045ecd54874dc5cf42d70c6237cf6f531cd0
Author: William Casarin <jb55@jb55.com>
Date: Fri, 30 Jan 2026 22:37:50 -0800
fix(dave): exit plan mode when tentative-accepting ExitPlanMode
When using shift-click to add a message while approving an ExitPlanMode
request, it now correctly exits plan mode. Previously only the direct
approve button would exit plan mode.
Also refactors has_pending_question() to use a shared helper
pending_permission_tool_name() for cleaner code.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Diffstat:
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/crates/notedeck_dave/src/lib.rs b/crates/notedeck_dave/src/lib.rs
@@ -792,25 +792,28 @@ You are an AI agent for the nostr protocol called Dave, created by Damus. nostr
/// Check if the first pending permission is an AskUserQuestion tool call
fn has_pending_question(&self) -> bool {
- let Some(session) = self.session_manager.get_active() else {
- return false;
- };
+ self.pending_permission_tool_name() == Some("AskUserQuestion")
+ }
- // Get the first pending permission request ID
- let Some(request_id) = session.pending_permissions.keys().next() else {
- return false;
- };
+ /// Check if the first pending permission is an ExitPlanMode tool call
+ fn has_pending_exit_plan_mode(&self) -> bool {
+ self.pending_permission_tool_name() == Some("ExitPlanMode")
+ }
+
+ /// Get the tool name of the first pending permission request
+ fn pending_permission_tool_name(&self) -> Option<&str> {
+ let session = self.session_manager.get_active()?;
+ let request_id = session.pending_permissions.keys().next()?;
- // Find the corresponding PermissionRequest in chat to check tool_name
for msg in &session.chat {
if let Message::PermissionRequest(req) = msg {
- if &req.id == request_id && req.tool_name == "AskUserQuestion" {
- return true;
+ if &req.id == request_id {
+ return Some(&req.tool_name);
}
}
}
- false
+ None
}
/// Handle a permission response (from UI button or keybinding)
@@ -1502,6 +1505,8 @@ impl notedeck::App for Dave {
match tentative_state {
crate::session::PermissionMessageState::TentativeAccept => {
// Send permission Allow with the message from input
+ // If this is ExitPlanMode, also exit plan mode
+ let is_exit_plan_mode = self.has_pending_exit_plan_mode();
if let Some(request_id) = self.first_pending_permission() {
let message = self
.session_manager
@@ -1512,6 +1517,9 @@ impl notedeck::App for Dave {
if let Some(session) = self.session_manager.get_active_mut() {
session.input.clear();
}
+ if is_exit_plan_mode {
+ self.exit_plan_mode(ui.ctx());
+ }
self.handle_permission_response(
request_id,
PermissionResponse::Allow { message },