Function: eca-chat-delete

eca-chat-delete is an interactive and natively compiled function defined in eca-chat.el.

Signature

(eca-chat-delete)

Documentation

Delete the active chat of the current session from the server.

When called from a registered chat buffer, delete that chat. Otherwise, delete the session's last visited chat. Unlike killing its buffer, this never prompts; the chat is always removed server-side. When the session has other chats, any window showing the deleted chat switches to another chat first.

Key Bindings

eca-chat-mode-map C-c C-S-k

Source Code

;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-chat.el
;;;###autoload
(defun eca-chat-delete ()
  "Delete the active chat of the current session from the server.
When called from a registered chat buffer, delete that chat.
Otherwise, delete the session's last visited chat.  Unlike killing
its buffer, this never prompts; the chat is always removed
server-side.  When the session has other chats, any window showing
the deleted chat switches to another chat first."
  (interactive)
  (let ((session (eca-session)))
    (eca-assert-session-running session)
    (let* ((buffer (eca-chat--get-active-buffer session))
           (chat-id (and (buffer-live-p buffer)
                         (buffer-local-value 'eca-chat--id buffer))))
      (unless (and (buffer-live-p buffer) chat-id)
        (user-error "No active chat to delete"))
      (with-current-buffer buffer
        (eca-chat--stream-flush))
      (eca-chat--switch-windows-to-sibling session buffer)
      (eca-api-request-sync session
                            :method "chat/delete"
                            :params (list :chatId chat-id))
      ;; The server normally sends `chat/deleted' before the response,
      ;; but clean up locally too so a missed notification cannot leave a
      ;; dead buffer in the session registry.
      (setf (eca--session-chats session)
            (eca-dissoc (eca--session-chats session) chat-id))
      (eca-chat--invalidate-tab-line-cache session)
      (when (buffer-live-p buffer)
        ;; Keep the kill hook from prompting or sending a second delete.
        (with-current-buffer buffer
          (setq-local eca-chat--closed t))
        (kill-buffer buffer))
      (eca-chat--force-tab-line-update))))