Skip to content

Commit 262436d

Browse files
committed
Add current mode display in header and mode line #127
1 parent a49c5e9 commit 262436d

File tree

1 file changed

+41
-4
lines changed

1 file changed

+41
-4
lines changed

agent-shell.el

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,9 +1642,24 @@ STATE should contain :agent-config with :icon-name, :buffer-name, and
16421642
:session with :mode-id and :modes for displaying the current session mode."
16431643
(unless state
16441644
(error "STATE is required"))
1645-
(let* ((text-header (format " %s @ %s"
1645+
(let* ((model-name (map-elt (seq-find (lambda (model)
1646+
(string= (map-elt model :model-id)
1647+
(map-nested-elt state '(:session :model-id))))
1648+
(map-nested-elt state '(:session :models)))
1649+
:name))
1650+
(mode-name (when-let ((mode-id (map-nested-elt state '(:session :mode-id))))
1651+
(agent-shell--resolve-session-mode-name
1652+
mode-id
1653+
(map-nested-elt state '(:session :modes)))))
1654+
(text-header (format " %s%s%s @ %s"
16461655
(propertize (concat (map-nested-elt state '(:agent-config :buffer-name)) " Agent")
16471656
'font-lock-face 'font-lock-variable-name-face)
1657+
(if model-name
1658+
(concat "" (propertize model-name 'font-lock-face 'font-lock-negation-char-face))
1659+
"")
1660+
(if mode-name
1661+
(concat "" (propertize mode-name 'font-lock-face 'font-lock-type-face))
1662+
"")
16481663
(propertize (string-remove-suffix "/" (abbreviate-file-name default-directory))
16491664
'font-lock-face 'font-lock-string-face))))
16501665
(pcase agent-shell-header-style
@@ -1685,6 +1700,20 @@ STATE should contain :agent-config with :icon-name, :buffer-name, and
16851700
(dom-node 'tspan
16861701
`((fill . ,(face-attribute 'font-lock-variable-name-face :foreground)))
16871702
(concat (map-nested-elt state '(:agent-config :buffer-name)) " Agent")))
1703+
;; Model name (optional)
1704+
(when model-name
1705+
;; Add separator arrow
1706+
(dom-append-child text-node
1707+
(dom-node 'tspan
1708+
`((fill . ,(face-attribute 'default :foreground))
1709+
(dx . "8"))
1710+
""))
1711+
;; Add model name
1712+
(dom-append-child text-node
1713+
(dom-node 'tspan
1714+
`((fill . ,(face-attribute 'font-lock-negation-char-face :foreground))
1715+
(dx . "8"))
1716+
model-name)))
16881717
;; Session mode (optional)
16891718
(when-let ((mode-id (map-nested-elt state '(:session :mode-id))))
16901719
;; Add separator arrow
@@ -3048,12 +3077,20 @@ See https://agentclientprotocol.com/protocol/session-modes for details."
30483077
(defun agent-shell--mode-line-format ()
30493078
"Return `agent-shell''s mode-line format.
30503079
3051-
Typically includes the session mode and activity or nil if unavailable.
3080+
Typically includes the model, session mode and activity or nil if unavailable.
30523081
3053-
For example: \" [Accept Edits] ░░░ \"."
3082+
For example: \" [Sonnet] [Accept Edits] ░░░ \"."
30543083
(when-let* (((derived-mode-p 'agent-shell-mode))
30553084
((memq agent-shell-header-style '(text none nil))))
3056-
(concat (when-let ((mode-name (agent-shell--resolve-session-mode-name
3085+
(concat (when-let ((model-name (map-elt (seq-find (lambda (model)
3086+
(string= (map-elt model :model-id)
3087+
(map-nested-elt (agent-shell--state) '(:session :model-id))))
3088+
(map-nested-elt (agent-shell--state) '(:session :models)))
3089+
:name)))
3090+
(propertize (format " [%s]" model-name)
3091+
'face 'font-lock-variable-name-face
3092+
'help-echo (format "Model: %s" model-name)))
3093+
(when-let ((mode-name (agent-shell--resolve-session-mode-name
30573094
(map-nested-elt (agent-shell--state) '(:session :mode-id))
30583095
(map-nested-elt (agent-shell--state) '(:session :modes)))))
30593096
(propertize (format " [%s]" mode-name)

0 commit comments

Comments
 (0)