Skip to content

CIDER REPL prompt not shown when "value" and "done" are in same response #3869

@ikappaki

Description

@ikappaki

When connecting CIDER to a jank nREPL server, the REPL buffer opens without displaying the namespace prompt (e.g. user>). The prompt only appears after pressing Enter.

This appears to be related to how CIDER handles responses that include both :value and :status ("done") in the same message. Are "done" responses expected to be exclusive (i.e. not include other keys such as :value)?

Expected behavior

The REPL prompt (e.g. user>) should be displayed immediately after connecting and after each evaluation.

Actual behavior

The REPL buffer opens without showing a prompt.
The prompt only appears after pressing Enter.

Evaluating expressions (e.g. 5) prints the result, but the prompt is still not shown until Enter is pressed again.

Steps to reproduce the problem

  1. Install jank:
    https://book.jank-lang.org/getting-started/01-installation.html

  2. Start the REPL:

    jank repl

    Note the nREPL port:

    user=> jank nREPL server is running on nrepl://127.0.0.1:PORT
    
  3. In Emacs:

    • Create and open a file scratch.jank

    • Enable clojure-mode

    • Run:

      M-x nrepl-toggle-message-logging
      
    • Connect:

      M-x cider-connect-clj
      

      (use the port from step 2)

  4. Observe the REPL buffer:

    • No prompt is shown initially
    • Press Enter -> prompt appears
    • Evaluate 5 -> result prints, but no prompt until Enter again

Additional context

From the nREPL message log, the final response includes both :value and :status:

(<--
  id         "4"
  session    "2218bbf8-72ea-4427-97ab-995d3f969c20"
  time-stamp "2026-03-26 07:12:54.076506209"
  ns         "user"
  status     ("done")
  value      "nil"
)

In CIDER’s response handler, it appears that :value takes precedence over :status (due to a cond), so the "done" handler, which is responsible for updating the REPL prompt, is not invoked when both keys are present in the same message:

cider/lisp/nrepl-client.el

Lines 821 to 889 in f4a8bc4

(defun nrepl-make-response-handler (buffer value-handler stdout-handler
stderr-handler done-handler
&optional eval-error-handler
content-type-handler
truncated-handler)
"Make a response handler for connection BUFFER.
A handler is a function that takes one argument - response received from
the server process. The response is an alist that contains at least `id'
and `session' keys. Other standard response keys are `value', `out', `err',
and `status'.
The presence of a particular key determines the type of the response. For
example, if `value' key is present, the response is of type `value', if
`out' key is present the response is `stdout' etc.
Depending on the type, the handler dispatches the appropriate value to one
of the supplied handlers: VALUE-HANDLER, STDOUT-HANDLER, STDERR-HANDLER,
DONE-HANDLER, EVAL-ERROR-HANDLER, CONTENT-TYPE-HANDLER, and
TRUNCATED-HANDLER.
Handlers are functions of the buffer and the value they handle, except for
the optional CONTENT-TYPE-HANDLER which should be a function of the buffer,
content, the content-type to be handled as a list `(type attrs)'.
If the optional EVAL-ERROR-HANDLER is nil, the default `nrepl-err-handler'
is used. If any of the other supplied handlers are nil nothing happens for
the corresponding type of response."
(lambda (response)
(nrepl-dbind-response response (content-type content-transfer-encoding body
value ns out err status id)
(when (buffer-live-p buffer)
(with-current-buffer buffer
(when (and ns (not (cider-clojure-major-mode-p)))
(cider-set-buffer-ns ns))))
(cond ((and content-type content-type-handler)
(funcall content-type-handler buffer
(if (string= content-transfer-encoding "base64")
(base64-decode-string body)
body)
content-type))
(value
(when value-handler
(funcall value-handler buffer value)))
(out
(when stdout-handler
(funcall stdout-handler buffer out)))
(err
(when stderr-handler
(funcall stderr-handler buffer err)))
(status
(when (and truncated-handler (member "nrepl.middleware.print/truncated" status))
(let ((warning (format "\n... output truncated to %sB ..."
(file-size-human-readable cider-print-quota))))
(funcall truncated-handler buffer warning)))
(when (member "notification" status)
(nrepl-dbind-response response (msg type)
(nrepl-notify msg type)))
(when (member "interrupted" status)
(message "Evaluation interrupted."))
(when (member "eval-error" status)
(funcall (or eval-error-handler nrepl-err-handler) buffer))
(when (member "namespace-not-found" status)
(message "Namespace `%s' not found." ns))
(when (member "need-input" status)
(cider-need-input buffer))
(when (member "done" status)
(nrepl--mark-id-completed id)
(when done-handler
(funcall done-handler buffer))))))))

Environment & Version information

CIDER version information

CIDER 1.21.0-snapshot (package: 1.21.0-snapshot)

Lein / Clojure CLI version

jank 0.1-alpha

Emacs version

GNU Emacs 29.3 

Operating system

any

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions