From 9f6da475959c514ee9b2d5954a4f92b3fee51ba0 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Wed, 12 Aug 2026 11:49:22 -0500 Subject: [PATCH] =?UTF-8?q?Add=20"agent-shell-queue-list"=20to=20see=20wha?= =?UTF-8?q?t=E2=80=99s=20queued?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, you couldn’t see what you had queued. This pops up a small buffer to display what’s queued. You can’t edit it, however. --- agent-shell-prompt-queue.el | 62 +++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/agent-shell-prompt-queue.el b/agent-shell-prompt-queue.el index 59c74a8c..f5e2cf6f 100644 --- a/agent-shell-prompt-queue.el +++ b/agent-shell-prompt-queue.el @@ -31,6 +31,7 @@ (require 'map) (require 'ring) +(require 'text-property-search) (require 'agent-shell-faces) (eval-when-compile (require 'cl-lib)) @@ -266,6 +267,67 @@ either remove all or select a specific prompt to remove." (map-put! agent-shell--state :pending-prompts nil) (message "Removed all pending prompts"))))) +(defun agent-shell-queue-list-next-prompt () + "Move to the next queued prompt." + (declare (modes agent-shell-queue-list-mode)) + (interactive) + (if-let* ((match (save-excursion + (text-property-search-forward 'agent-shell-queue-item nil nil t)))) + (goto-char (prop-match-beginning match)) + (user-error "No next prompt"))) + +(defun agent-shell-queue-list-previous-prompt () + "Move to the previous queued prompt." + (declare (modes agent-shell-queue-list-mode)) + (interactive) + (if-let* ((match (save-excursion + (text-property-search-backward 'agent-shell-queue-item nil nil t)))) + (goto-char (prop-match-beginning match)) + (user-error "No previous prompt"))) + +(defvar agent-shell-queue-list-mode-map + (let ((map (make-sparse-keymap))) + (define-key map (kbd "n") #'agent-shell-queue-list-next-prompt) + (define-key map (kbd "p") #'agent-shell-queue-list-previous-prompt) + map) + "Keymap for `agent-shell-queue-list-mode'.") + +(define-derived-mode agent-shell-queue-list-mode special-mode "Agent Shell Queue" + "Major mode for viewing pending `agent-shell' prompts.") + +(defun agent-shell-queue-list () + "Show all pending prompts, in full, in a dedicated read-only buffer. + +Acts on the current project's shell, resolving it via +`agent-shell--shell-buffer' so this works even when invoked outside a +shell buffer." + (interactive) + (with-current-buffer (agent-shell--shell-buffer :no-create t) + (agent-shell--prompt-queue-migrate) + (let ((pending (map-elt agent-shell--state :pending-prompts)) + (list-buffer (get-buffer-create (concat (buffer-name) " [queue]")))) + (when (seq-empty-p pending) + (user-error "No pending prompts")) + (with-current-buffer list-buffer + (let ((inhibit-read-only t)) + (erase-buffer) + (insert (propertize (format "Pending prompts: %d" (length pending)) + 'face 'agent-shell-section-heading) + "\n") + (seq-do-indexed + (lambda (prompt idx) + (insert "\n" + (propertize (format "%d:" (1+ idx)) + 'face 'agent-shell-secondary + 'agent-shell-queue-item (1+ idx)) + "\n" + (string-trim-right prompt) + "\n")) + pending)) + (agent-shell-queue-list-mode) + (goto-char (point-min))) + (pop-to-buffer list-buffer)))) + (provide 'agent-shell-prompt-queue) ;;; agent-shell-prompt-queue.el ends here