Function: eca-chat-handle-ask-question
eca-chat-handle-ask-question is a natively compiled function defined
in eca-chat.el.
Signature
(eca-chat-handle-ask-question SESSION REQUEST PARAMS)
Documentation
Handle chat/askQuestion REQUEST for SESSION with PARAMS.
Renders the question in the chat buffer and switches the prompt
to answer mode. Several questions can be pending at once, e.g.
from parallel ask_user tool calls, each answered on its own.
Returns :async — the response is sent later when the user answers
or cancels.
Source Code
;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-chat.el
;;; Ask question
(defun eca-chat-handle-ask-question (session request params)
"Handle chat/askQuestion REQUEST for SESSION with PARAMS.
Renders the question in the chat buffer and switches the prompt
to answer mode. Several questions can be pending at once, e.g.
from parallel `ask_user' tool calls, each answered on its own.
Returns :async — the response is sent later when the user answers
or cancels."
(let* ((chat-id (plist-get params :chatId))
(text (plist-get params :question))
;; Guard against a non-sequence `:options` (e.g. a malformed
;; string from a misbehaving server): `append' on a string would
;; split it into character integers that render as random numbers.
(options (let ((raw (plist-get params :options)))
(when (or (listp raw) (vectorp raw))
(append raw nil))))
(tool-call-id (plist-get params :toolCallId))
(chat-buffer (eca-chat--get-chat-buffer session chat-id)))
(if (and chat-buffer (buffer-live-p chat-buffer))
(progn
(eca-chat--with-current-buffer chat-buffer
;; The buttons rendered below answer this very question, so
;; answering one never settles another pending question.
(let ((question (list :session session :request request
:question text :options options
:tool-call-id tool-call-id
:allow-freeform (plist-get params :allowFreeform)
:block-ov nil)))
(if tool-call-id
(progn
(eca-chat--update-expandable-content
tool-call-id
(propertize (concat "Q: " text)
'font-lock-face 'eca-chat-question-face)
(eca-chat--build-question-options-content question))
(eca-chat--expandable-content-toggle tool-call-id t nil))
(plist-put question :block-ov
(eca-chat--render-ask-question-standalone question)))
(setq eca-chat--pending-questions
(append eca-chat--pending-questions (list question)))
(eca-chat--refresh-question-prompt-prefix)
;; A pending question keeps the turn active server-side, so
;; surface the stop affordance even if the chat reports idle.
(eca-chat--refresh-transient-area)
(eca-chat--notify-status-changed session)))
:async)
(list :answer nil :cancelled t))))