From 1b7e779a38eb31f67d885a95bf1a160b416e509a Mon Sep 17 00:00:00 2001 From: "Aaron L. Zeng" Date: Fri, 27 Mar 2026 16:35:22 -0400 Subject: [PATCH] Display qualifier key binding help in text style header Previously, the qualifier (e.g., "[1/5][Edit]") and key binding hints (e.g., "C-c C-c Submit") were only rendered in graphical-style headers. This meant that users with agent-shell-header-style set to 'text would not see any key documentation in the header line. --- agent-shell.el | 90 +++++++++++++++++++++++++++++--------------------- 1 file changed, 52 insertions(+), 38 deletions(-) diff --git a/agent-shell.el b/agent-shell.el index 6a8182a..a1655e5 100644 --- a/agent-shell.el +++ b/agent-shell.el @@ -3217,44 +3217,58 @@ When provided, included in help-echo tooltips." (unless state (error "STATE is required")) (let* ((header-model (agent-shell--make-header-model state :qualifier qualifier :bindings bindings)) - (text-header (format " %s%s%s @ %s%s%s%s" - (propertize (map-elt header-model :buffer-name) - 'font-lock-face 'font-lock-variable-name-face) - (if (map-elt header-model :model-name) - (concat " ➤ " (propertize (map-elt header-model :model-name) - 'font-lock-face 'font-lock-negation-char-face - 'help-echo (concat "Click to open LLM model menu " - (when model-binding - (propertize model-binding 'face 'help-key-binding))) - 'mouse-face 'mode-line-highlight - 'local-map (let ((map (make-sparse-keymap))) - (define-key map [header-line mouse-1] - (agent-shell--mode-line-model-menu)) - map))) - "") - (if (map-elt header-model :mode-name) - (concat " ➤ " (propertize (map-elt header-model :mode-name) - 'font-lock-face 'font-lock-type-face - 'help-echo (concat "Click to open session mode menu " - (when mode-binding - (propertize mode-binding 'face 'help-key-binding))) - 'mouse-face 'mode-line-highlight - 'local-map (let ((map (make-sparse-keymap))) - (define-key map [header-line mouse-1] - (agent-shell--mode-line-mode-menu)) - map))) - "") - (propertize (map-elt header-model :project-name) 'font-lock-face 'font-lock-string-face) - (if (map-elt header-model :session-id) - (concat " ➤ " (map-elt header-model :session-id)) - "") - (if (map-elt header-model :context-indicator) - (concat (if (> (length (map-elt header-model :context-indicator)) 1) " ➤ " " ") - (map-elt header-model :context-indicator)) - "") - (if (map-elt header-model :busy-indicator-frame) - (map-elt header-model :busy-indicator-frame) - "")))) + (text-header (concat + (format " %s%s%s @ %s%s%s%s" + (propertize (map-elt header-model :buffer-name) + 'font-lock-face 'font-lock-variable-name-face) + (if (map-elt header-model :model-name) + (concat " ➤ " (propertize (map-elt header-model :model-name) + 'font-lock-face 'font-lock-negation-char-face + 'help-echo (concat "Click to open LLM model menu " + (when model-binding + (propertize model-binding 'face 'help-key-binding))) + 'mouse-face 'mode-line-highlight + 'local-map (let ((map (make-sparse-keymap))) + (define-key map [header-line mouse-1] + (agent-shell--mode-line-model-menu)) + map))) + "") + (if (map-elt header-model :mode-name) + (concat " ➤ " (propertize (map-elt header-model :mode-name) + 'font-lock-face 'font-lock-type-face + 'help-echo (concat "Click to open session mode menu " + (when mode-binding + (propertize mode-binding 'face 'help-key-binding))) + 'mouse-face 'mode-line-highlight + 'local-map (let ((map (make-sparse-keymap))) + (define-key map [header-line mouse-1] + (agent-shell--mode-line-mode-menu)) + map))) + "") + (propertize (map-elt header-model :project-name) 'font-lock-face 'font-lock-string-face) + (if (map-elt header-model :session-id) + (concat " ➤ " (map-elt header-model :session-id)) + "") + (if (map-elt header-model :context-indicator) + (concat (if (> (length (map-elt header-model :context-indicator)) 1) " ➤ " " ") + (map-elt header-model :context-indicator)) + "") + (if (map-elt header-model :busy-indicator-frame) + (map-elt header-model :busy-indicator-frame) + "")) + (when (or bindings qualifier) + (concat + " " + (when qualifier + (concat qualifier " ")) + (mapconcat + (lambda (binding) + (format "%s %s" + (propertize (map-elt binding :key) + 'font-lock-face 'help-key-binding) + (map-elt binding :description))) + bindings + " ")))))) (pcase agent-shell-header-style ((or 'none (pred null)) nil) ('text text-header)