Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 34 additions & 5 deletions eca-chat.el
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
(require 'f)
(require 'markdown-mode)
(require 'compat)
(require 'svg-lib)

(require 'eca-util)
(require 'eca-api)
Expand Down Expand Up @@ -593,6 +594,31 @@ the prompt/context line."
(eq (line-number-at-pos (point))
(line-number-at-pos (eca-chat--prompt-field-start-point))))

(defun eca-chat--header-line-icon (icon)
"Create an SVG icon for use in the header line.
ICON is the name of the Bootstrap icon to display.
Returns an SVG image suitable for insertion in the header line,
styled to match the current theme's header-line face."
(svg-lib-icon icon nil
:background (face-background 'header-line nil 'mode-line)
:collection "bootstrap"
:foreground (face-foreground 'eca-chat-option-key-face nil t)
:stroke 0))

(defun eca-chat--header-line-label (name icon)
"Create a formatted label string for the header line.
NAME is the text label to display.
ICON is the Bootstrap icon name to display before the name.
Returns a string containing the icon (if in graphical display) followed
by the name and a colon separator, suitable for header line display."
(with-temp-buffer
(when (display-graphic-p)
(when-let ((svg-icon (eca-chat--header-line-icon icon)))
(insert-image svg-icon)))
(insert name)
(insert ": ")
(buffer-substring (point-min) (point-max))))

(defun eca-chat--header-line-string (session)
"Update chat header line for SESSION."
(let ((model-keymap (make-sparse-keymap))
Expand All @@ -601,25 +627,28 @@ the prompt/context line."
(define-key model-keymap (kbd "<header-line> <mouse-1>") #'eca-chat-select-model)
(define-key behavior-keymap (kbd "<header-line> <mouse-1>") #'eca-chat-select-behavior)
(define-key mcp-keymap (kbd "<header-line> <mouse-1>") #'eca-mcp-details)
(list (propertize "model:"
(list (propertize (eca-chat--header-line-label "Model" "cpu")
'font-lock-face 'eca-chat-option-key-face
'pointer 'hand
'keymap model-keymap)

" "
(propertize (eca-chat--model session)
'font-lock-face 'eca-chat-option-value-face
'pointer 'hand
'keymap model-keymap)
" "
(propertize "behavior:"
" "
(propertize (eca-chat--header-line-label "Behavior" "robot")
'font-lock-face 'eca-chat-option-key-face
'pointer 'hand
'keymap behavior-keymap)
" "
(propertize (eca-chat--behavior session)
'font-lock-face 'eca-chat-option-value-face
'pointer 'hand
'keymap behavior-keymap)
" "
(propertize "mcps:"
" "
(propertize (eca-chat--header-line-label "MCPs" "server")
'font-lock-face 'eca-chat-option-key-face
'pointer 'hand
'keymap mcp-keymap)
Expand Down
2 changes: 1 addition & 1 deletion eca.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;; Author: Eric Dallo <[email protected]>
;; Maintainer: Eric Dallo <[email protected]>
;; Version: 0.0.1
;; Package-Requires: ((emacs "28.1") (dash "2.18.0") (f "0.20.0") (markdown-mode "2.3") (compat "30.1"))
;; Package-Requires: ((emacs "28.1") (dash "2.18.0") (f "0.20.0") (markdown-mode "2.3") (compat "30.1") (svg-lib "0.3"))
;; Keywords: tools
;; Homepage: https://github.com/editor-code-assistant/eca-emacs
;;
Expand Down