Function: eca-chat-inline--send

eca-chat-inline--send is a natively compiled function defined in eca-chat-inline.el.

Signature

(eca-chat-inline--send SESSION OV TEXT CONTEXTS &optional SOURCE-CHAT-ID CREATED-CHAT-BUFFER)

Documentation

Send TEXT with raw CONTEXTS for OV's chat via SESSION.

Uses the chat/inlinePrompt method with the overlay's chat-id. SOURCE-CHAT-ID asks the server to fork that chat's history into the inline chat when it is being created. Request errors are surfaced on the overlay; when CREATED-CHAT-BUFFER is non-nil (the mirror pre-created by this request), a failure also rolls it back so no ghost chat lingers in the session.

Source Code

;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-chat-inline.el
(defun eca-chat-inline--send (session ov text contexts
                                      &optional source-chat-id created-chat-buffer)
  "Send TEXT with raw CONTEXTS for OV's chat via SESSION.
Uses the `chat/inlinePrompt' method with the overlay's chat-id.
SOURCE-CHAT-ID asks the server to fork that chat's history into
the inline chat when it is being created.  Request errors are
surfaced on the overlay; when CREATED-CHAT-BUFFER is non-nil (the
mirror pre-created by this request), a failure also rolls it back
so no ghost chat lingers in the session."
  (let ((chat-id (overlay-get ov 'eca-chat-inline--chat-id))
        (refined (->> contexts
                      (-map #'eca-chat--refine-context)
                      (-keep #'eca-chat--materialize-context))))
    (eca-api-request-async
     session
     :method "chat/inlinePrompt"
     :params (append (list :chatId chat-id
                           :message text
                           :contexts (vconcat refined))
                     (when source-chat-id
                       (list :sourceChatId source-chat-id))
                     (when eca-chat-inline-model
                       (list :model eca-chat-inline-model))
                     (when eca-chat-inline-agent
                       (list :agent eca-chat-inline-agent))
                     (when eca-chat-inline-variant
                       (list :variant eca-chat-inline-variant)))
     :success-callback
     (lambda (res)
       ;; Param validation failures and internal server errors come
       ;; back as a normal response with an error status instead of a
       ;; jsonrpc error.
       (when (equal "error" (plist-get res :status))
         (eca-chat-inline--discard-failed-chat session ov created-chat-buffer)
         (when (overlay-buffer ov)
           (eca-chat-inline--set-status
            ov "Prompt failed, open the chat for details" 'finished))))
     :error-callback
     (lambda (err)
       (eca-chat-inline--discard-failed-chat session ov created-chat-buffer)
       (when (overlay-buffer ov)
         (eca-chat-inline--set-status
          ov
          (format "Error: %s" (or (plist-get err :message) err))
          'finished))))))