Function: eca-chat--render-history-contents
eca-chat--render-history-contents is a natively compiled function
defined in eca-chat.el.
Signature
(eca-chat--render-history-contents SESSION CHAT-BUFFER CONTENTS)
Documentation
Prepend CONTENTS above existing content in CHAT-BUFFER for SESSION.
CONTENTS is the list of chat/history items (each shaped like a
chat/contentReceived payload); they are rendered in order at the top
of the message area so older pages stack above newer ones. Subagent
items (those carrying :parentChatId) are routed into their parent tool
call exactly as the streaming path does.
The live-turn marker eca-chat--last-user-message-pos is saved and
restored so prepending older content does not move the scope used by the
streaming renderer; fontification and table styling are applied to the
prepended region explicitly. Callers are expected to re-apply
eca-chat--protect-non-prompt afterwards.
Source Code
;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-chat.el
(defun eca-chat--render-history-contents (session chat-buffer contents)
"Prepend CONTENTS above existing content in CHAT-BUFFER for SESSION.
CONTENTS is the list of `chat/history' items (each shaped like a
`chat/contentReceived' payload); they are rendered in order at the top
of the message area so older pages stack above newer ones. Subagent
items (those carrying :parentChatId) are routed into their parent tool
call exactly as the streaming path does.
The live-turn marker `eca-chat--last-user-message-pos' is saved and
restored so prepending older content does not move the scope used by the
streaming renderer; fontification and table styling are applied to the
prepended region explicitly. Callers are expected to re-apply
`eca-chat--protect-non-prompt' afterwards."
(eca-chat--with-current-buffer chat-buffer
(let* ((roots (eca--session-workspace-folders session))
(start (eca-chat--older-content-start))
(m (copy-marker start t))
(saved-last-user-pos eca-chat--last-user-message-pos))
(unwind-protect
(let ((eca-chat--insertion-point-override m)
(eca-chat-stream-flush-interval nil))
(seq-do
(lambda (item)
(let ((role (plist-get item :role))
(content (plist-get item :content))
(parent-chat-id (plist-get item :parentChatId))
(item-chat-id (plist-get item :chatId)))
(if parent-chat-id
(when-let* ((tool-call-id (gethash item-chat-id eca-chat--subagent-chat-id->tool-call-id)))
(eca-chat--render-content session chat-buffer role content roots tool-call-id item-chat-id))
(eca-chat--render-content session chat-buffer role content roots))))
contents))
(setq-local eca-chat--last-user-message-pos saved-last-user-pos)
;; Separate the prepended block from the content below with a single
;; newline: historical content has no trailing turn-end newline, so the
;; last older line would otherwise glue to the first existing line. A
;; user message below keeps the empty line it is rendered with instead.
(let ((pos (marker-position m)))
(when (and (> pos (point-min))
(< pos (point-max)))
(cond
((eq (get-text-property pos 'font-lock-face)
'eca-chat-user-messages-face)
(eca-chat--ensure-empty-line-before pos))
((and (not (eq (char-before pos) ?\n))
(not (eq (char-after pos) ?\n)))
(save-excursion (goto-char pos) (insert "\n"))))))
(let ((end (marker-position m)))
(font-lock-ensure start end)
(eca-chat--align-tables start)
(eca-chat--beautify-tables start))
(set-marker m nil)))))