Function: eca-chat-exit
eca-chat-exit is a natively compiled function defined in eca-chat.el.
Signature
(eca-chat-exit SESSION)
Documentation
Exit the ECA chat for SESSION.
Source Code
;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-chat.el
(defun eca-chat-exit (session)
"Exit the ECA chat for SESSION."
;; Cancel the global repeating idle timer that tracks cursor position.
(when (timerp eca-chat--cursor-context-timer)
(cancel-timer eca-chat--cursor-context-timer)
(setq eca-chat--cursor-context-timer nil))
;; Remove the global window-size-change handler registered by eca-chat-mode.
(remove-hook 'window-size-change-functions #'eca-chat--on-window-size-change)
;; Closed chat buffers can keep SESSION reachable through buffer-local state.
(eca-chat--invalidate-tab-line-cache session)
(mapcar (lambda (title+buffer)
(let ((chat-buffer (cdr title+buffer)))
(when (buffer-live-p chat-buffer)
(eca-chat--with-current-buffer chat-buffer
(eca-chat--stream-flush)
;; Cancel all timers if chat was still loading/stopping.
(eca-chat--spinner-stop)
(eca-chat--tool-call-elapsed-stop-all)
(when eca-chat--modeline-timer
(cancel-timer eca-chat--modeline-timer)
(setq-local eca-chat--modeline-timer nil))
(when eca-chat--stopping-safety-timer
(cancel-timer eca-chat--stopping-safety-timer)
(setq-local eca-chat--stopping-safety-timer nil))
(setq eca-chat--closed t)
(force-mode-line-update)
(goto-char (point-max))
(rename-buffer (concat (buffer-name) ":closed") t)
;; Keep only the most recently closed chat buffer; kill older ones.
(let ((current (current-buffer)))
(dolist (b (buffer-list))
(when (and (not (eq b current))
(string-match-p "^<eca-chat:.*>:closed$" (buffer-name b)))
(kill-buffer b))))
(when-let* ((window (get-buffer-window chat-buffer)))
(quit-window nil window))))))
(eca--session-chats session)))