Function: eca-chat--build-tool-call-approval-str-content
eca-chat--build-tool-call-approval-str-content is a natively compiled
function defined in eca-chat.el.
Signature
(eca-chat--build-tool-call-approval-str-content SESSION ID SPACING-LINE-PREFIX &optional CHAT-ID DETAILS)
Documentation
Build the tool call approval string for SESSION, ID and SPACING-LINE-PREFIX.
CHAT-ID overrides the buffer-local eca-chat--id for the approval
request, useful for subagent tool calls.
DETAILS is the tool call details, used for shellCommand breakdowns to
show which commands an approve & remember would remember, hiding the
remember action when nothing can be remembered.
Source Code
;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-chat.el
(defun eca-chat--build-tool-call-approval-str-content (session id spacing-line-prefix &optional chat-id details)
"Build the tool call approval string for SESSION, ID and SPACING-LINE-PREFIX.
CHAT-ID overrides the buffer-local `eca-chat--id' for the approval
request, useful for subagent tool calls.
DETAILS is the tool call details, used for shellCommand breakdowns to
show which commands an approve & remember would remember, hiding the
remember action when nothing can be remembered."
(let* ((keybinding-for (lambda (command)
(concat "("
(key-description (car (where-is-internal command eca-chat-mode-map)))
")")))
(effective-chat-id (or chat-id eca-chat--id))
(shell-command? (string= "shellCommand" (plist-get details :type)))
;; Only the keys that would be newly remembered: already-remembered
;; commands are excluded from the label.
(remember-keys (when shell-command?
(delete-dups
(delq nil (mapcar (lambda (cmd)
(-let* (((&plist :approvalKey approval-key :remembered remembered) cmd))
(when (and approval-key (not remembered))
approval-key)))
(plist-get details :commands))))))
;; When remembering would save nothing new (no generalizable command,
;; or everything already remembered), hide the remember action.
(hide-remember? (and shell-command? (null remember-keys)))
(remember-suffix
(if remember-keys
(concat (propertize " " 'font-lock-face 'eca-chat-tool-call-approval-content-face)
(mapconcat (lambda (key)
(propertize key 'font-lock-face 'eca-chat--tool-call-argument-value-face))
remember-keys
(propertize ", " 'font-lock-face 'eca-chat-tool-call-approval-content-face))
(propertize " " 'font-lock-face 'eca-chat-tool-call-approval-content-face))
(propertize " for this session "
'font-lock-face 'eca-chat-tool-call-approval-content-face))))
(concat (propertize "\n" 'font-lock-face 'eca-chat-tool-call-spacing-face)
(eca-buttonize
eca-chat-mode-map
(propertize "Accept"
'eca-tool-call-pending-approval-accept t
'eca-tool-call-id id
'line-prefix spacing-line-prefix
'font-lock-face 'eca-chat-tool-call-accept-face)
(lambda ()
(eca-api-notify session
:method "chat/toolCallApprove"
:params (list :chatId effective-chat-id
:toolCallId id))))
(propertize " " 'font-lock-face 'eca-chat-tool-call-approval-content-face)
(propertize (funcall keybinding-for #'eca-chat-tool-call-accept-all)
'font-lock-face 'eca-chat-tool-call-keybinding-face)
(unless hide-remember?
(concat
(propertize "\n" 'font-lock-face 'eca-chat-tool-call-spacing-face)
(eca-buttonize
eca-chat-mode-map
(propertize "Accept and remember"
'eca-tool-call-pending-approval-accept-and-remember t
'line-prefix spacing-line-prefix
'font-lock-face 'eca-chat-tool-call-accept-and-remember-face)
(lambda ()
(eca-api-notify session
:method "chat/toolCallApprove"
:params (list :chatId effective-chat-id
:save "session"
:toolCallId id))))
remember-suffix
(propertize (funcall keybinding-for #'eca-chat-tool-call-accept-all-and-remember)
'font-lock-face 'eca-chat-tool-call-keybinding-face)))
(propertize "\n" 'font-lock-face 'eca-chat-tool-call-spacing-face)
(eca-buttonize
eca-chat-mode-map
(propertize "Reject"
'eca-tool-call-pending-approval-reject t
'line-prefix spacing-line-prefix
'font-lock-face 'eca-chat-tool-call-reject-face)
(lambda ()
(eca-api-notify session
:method "chat/toolCallReject"
:params (list :chatId effective-chat-id
:toolCallId id))))
(propertize " and tell ECA what to do differently "
'font-lock-face 'eca-chat-tool-call-approval-content-face)
(propertize (funcall keybinding-for #'eca-chat-tool-call-reject-next)
'font-lock-face 'eca-chat-tool-call-keybinding-face))))