Commit b5e37ea8ae0f

Vincent Demeester <vincent@sbr.pm>
2026-06-23 15:20:57
fix(emacs): add completion picker on double prefix arg
Routed C-u C-u to an explicit session completion picker for both agent DWIM launchers, since any prefix previously forced a new instance and never reached the picker.
1 parent 8f9d62c
Changed files (1)
dots
config
emacs
dots/config/emacs/init.el
@@ -3181,10 +3181,13 @@ No prefix ARG:
 - 1 shell  -> toggle its window (show/hide)
 - N shells -> `completing-read' to pick one, then display.
 
-With \\[universal-argument]: always force a brand-new shell."
+With \\[universal-argument]: always force a brand-new shell.
+With \\[universal-argument] \\[universal-argument]: always prompt with completion."
     (interactive "P")
-    (if arg
-	(agent-shell '(4))
+    (cond
+     ((equal arg '(16)) (agent-shell '(16)))
+     (arg (agent-shell '(4)))
+     (t
       (let ((buffers (agent-shell-project-buffers)))
 	(pcase (length buffers)
 	  (0 (agent-shell))
@@ -3196,7 +3199,7 @@ With \\[universal-argument]: always force a brand-new shell."
 	  (_ (agent-shell--display-buffer
 	      (agent-shell--read-shell-buffer
 	       :prompt "Project agent shell: "
-	       :buffers buffers)))))))
+	       :buffers buffers))))))))
   :config
   (setq agent-shell-google-authentication
 	(agent-shell-google-make-authentication :api-key (passage-get "redhat/google/osp/vdeemest-api-key")))
@@ -3236,11 +3239,23 @@ No prefix ARG:
 - 1 session  -> toggle its windows (show/hide)
 - N sessions -> `completing-read' to pick one, then show.
 
-With \\[universal-argument]: prompt for a session name (new named session)."
+With \\[universal-argument]: prompt for a session name (new named session).
+With \\[universal-argument] \\[universal-argument]: always prompt with completion."
     (interactive "P")
-    (if arg
-	(let ((current-prefix-arg '(4)))
-	  (call-interactively #'pi-coding-agent))
+    (cond
+     ((equal arg '(16))
+      (let* ((buffers (or (pi-coding-agent-project-buffers)
+			  (user-error "No pi session for this project")))
+	     (alist (mapcar (lambda (b) (cons (buffer-name b) b)) buffers))
+	     (choice (completing-read "Pi session: " alist nil t))
+	     (chat-buf (cdr (assoc choice alist)))
+	     (input-buf (buffer-local-value 'pi-coding-agent--input-buffer
+					    chat-buf)))
+	(pi-coding-agent--show-session-buffers chat-buf input-buf)))
+     (arg
+      (let ((current-prefix-arg '(4)))
+	(call-interactively #'pi-coding-agent)))
+     (t
       (let ((buffers (pi-coding-agent-project-buffers)))
 	(pcase (length buffers)
 	  (0 (pi-coding-agent))
@@ -3250,7 +3265,7 @@ With \\[universal-argument]: prompt for a session name (new named session)."
 		    (chat-buf (cdr (assoc choice alist)))
 		    (input-buf (buffer-local-value 'pi-coding-agent--input-buffer
 						   chat-buf)))
-	       (pi-coding-agent--show-session-buffers chat-buf input-buf)))))))
+	       (pi-coding-agent--show-session-buffers chat-buf input-buf))))))))
   :custom
   (pi-coding-agent-input-window-height 10)
   (pi-coding-agent-tool-preview-lines 10)