Function: eca-chat-config-updated
eca-chat-config-updated is a natively compiled function defined in
eca-chat.el.
Signature
(eca-chat-config-updated SESSION CHAT-CONFIG &optional CHAT-ID)
Documentation
Update chat based on CHAT-CONFIG for SESSION and optional CHAT-ID.
Session-level fields (welcomeMessage, models, agents) are always
applied to the session record. Variants and per-chat fields
(selectModel, selectAgent, selectVariant, selectTrust) are scoped by
CHAT-ID:
- when CHAT-ID is present the per-chat fields apply only to that
chat's buffer (eca-emacs#231 - prevents one chat's model change
from leaking into other chats);
- while a legacy chat/open request is pending, an unscoped
selection-only restore update applies to the opening chat;
- otherwise, when CHAT-ID is absent the legacy session-wide path is
used. This path is still needed for the initial config/updated
after initialize, which pushes session defaults to all chats.
Source Code
;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-chat.el
(defun eca-chat-config-updated (session chat-config &optional chat-id)
"Update chat based on CHAT-CONFIG for SESSION and optional CHAT-ID.
Session-level fields (welcomeMessage, models, agents) are always
applied to the session record. Variants and per-chat fields
(selectModel, selectAgent, selectVariant, selectTrust) are scoped by
CHAT-ID:
- when CHAT-ID is present the per-chat fields apply only to that
chat's buffer (eca-emacs#231 - prevents one chat's model change
from leaking into other chats);
- while a legacy `chat/open' request is pending, an unscoped
selection-only restore update applies to the opening chat;
- otherwise, when CHAT-ID is absent the legacy session-wide path is
used. This path is still needed for the initial `config/updated'
after `initialize', which pushes session defaults to all chats."
(let ((target-chat-id
(eca-chat--config-target-id session chat-config chat-id)))
(-some->> (plist-get chat-config :welcomeMessage)
(setf (eca--session-chat-welcome-message session)))
(-some->> (plist-get chat-config :models)
(setf (eca--session-models session)))
(-some->> (plist-get chat-config :agents)
(setf (eca--session-chat-agents session)))
(unless target-chat-id
(eca-chat--apply-session-defaults session chat-config)
(when (plist-member chat-config :variants)
(setf (eca--session-chat-variants session)
(append (plist-get chat-config :variants) nil))))
(if target-chat-id
(when-let* ((chat-buffer
(eca-get (eca--session-chats session) target-chat-id))
((buffer-live-p chat-buffer)))
(eca-chat--apply-per-chat-config chat-config chat-buffer))
(seq-doseq (chat-buffer (eca-vals (eca--session-chats session)))
(when (buffer-live-p chat-buffer)
(eca-chat--apply-per-chat-config chat-config chat-buffer))))))