portal

markaddleman 2022-12-08T16:54:17.843839Z

I would love to completely switch from Cursive’s console repl to portal but I can’t get the portal nrepl middleware to work. I have set up an .nrepl.edn file with contents

{:middleware [portal.nrepl/wrap-portal]}
My user.clj contains the following:
(defonce portal* (do
                   (add-tap portal.api/submit)
                   (portal.api/open {})))
When I start a repl, Portal opens and tap> are displayed in it but Cursive namespace and form evaluation results do not get displayed in Portal. I know that .nrepl.edn file is getting picked up because if I add garbage middleware to it, the repl does not start.

djblue 2022-12-08T17:05:05.243039Z

As a heuristic to avoid tapping tooling evals,https://github.com/djblue/portal/blob/master/src/portal/nrepl.clj#L63 will only tap nrepl eval requests with a :file . I think you might be running into this if you are trying to eval from the repl window instead of a file.

djblue 2022-12-08T17:06:02.913649Z

I assume this would work if you eval code from the editor directly, but I haven't tested it

markaddleman 2022-12-08T17:08:21.966609Z

I’m not familiar with middleware and I don’t know how Cursive sends evaluation requests to nrepl. What I can say is that neither Cursive’s “Load File in REPL” nor “Send form to REPL” commands show up in Portal

🤔 1
markaddleman 2022-12-08T17:08:47.936299Z

Eval-ing code directly from the editor is “Send form to REPL” and that does not end up in Portal.

markaddleman 2022-12-08T17:09:36.085579Z

Is there a debug option to turn off portal’s filtering heuristics?

djblue 2022-12-08T17:10:24.189859Z

Not currently, nrepl middleware tend to be a bit more difficult to make configurable

markaddleman 2022-12-08T17:10:41.763539Z

Yeah, I can see that. Maybe a jvm -D option?

djblue 2022-12-08T17:13:32.327079Z

I'll see if I can getting it working out of the box for cursive users. For now, I think it would be easiest to vendor the portal.nrepl middleware since it's only a single file and remove the :file requirement

markaddleman 2022-12-08T17:14:13.354959Z

Thanks!

djblue 2022-12-08T17:58:17.292859Z

^{:clojure.core/eval-file \"/Users/abadahdah/repos/portal/src/portal/nrepl.clj\" :line 57 :column 1} (+ 1 2 3) cursive seems to be doing an interesting thing for eval 🤔

markaddleman 2022-12-08T17:59:03.566889Z

How does that compare to other editors?

djblue 2022-12-08T17:59:29.166089Z

the nrepl protocol has explicit fields in the request map for :file, :line and :column

markaddleman 2022-12-08T17:59:37.876119Z

ah

djblue 2022-12-08T17:59:53.111549Z

The metadata approach has issues with values that don't support metadata 😬

markaddleman 2022-12-08T18:00:33.744179Z

Yeah, what happens with you try to eval a string?

djblue 2022-12-08T18:02:31.438119Z

The nrepl request looks roughly like:

{:ns "portal.nrepl",
 :op "eval",
 :id "213087fb-a648-418c-9ecf-945290605ef2", 
 :code "\"hello\""}

djblue 2022-12-08T18:03:18.430609Z

The difficult bit here is that cursive also submits tooling request via eval

markaddleman 2022-12-08T18:03:56.760659Z

Is it worth raising the issue in #cursive?

djblue 2022-12-08T18:05:51.818149Z

Might be worth it. If cursive updated the request map to include the file info, it should be backwards compatible and portal.nrepl would work with the existing heuristic

markaddleman 2022-12-08T18:06:15.808619Z

Cool. I’ll raise the issue in #cursive and reference this thread

🙏 1