This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-31
Channels
- # aleph (12)
- # announcements (4)
- # asami (7)
- # babashka (20)
- # beginners (92)
- # calva (74)
- # clj-kondo (8)
- # cljdoc (70)
- # clojure (47)
- # clojure-dev (29)
- # clojure-europe (27)
- # clojure-nl (7)
- # clojure-norway (3)
- # clojurescript (7)
- # cursive (2)
- # datomic (1)
- # emacs (8)
- # events (5)
- # fulcro (36)
- # gratitude (4)
- # humbleui (25)
- # introduce-yourself (1)
- # lsp (26)
- # malli (6)
- # missionary (8)
- # nbb (50)
- # off-topic (9)
- # pathom (2)
- # pedestal (3)
- # portal (32)
- # practicalli (5)
- # reitit (5)
- # releases (1)
- # ring (6)
- # shadow-cljs (87)
- # sql (31)
- # tools-deps (26)
- # vim (3)
- # xtdb (15)
Hi, newb here. I see instructions for middleware for deps and shadow here: https://cljdoc.org/d/djblue/portal/0.30.0/doc/guides/nrepl Any for lein?
I think something like:
(defproject middleware-test "0.1.0-SNAPSHOT"
:dependencies [[djblue/portal "0.33.0"]]
:repl-options {:nrepl-middleware [portal.nrepl/wrap-portal]})
Haven't tested it out but found it https://lambdaisland.com/guides/clojure-repls/clojure-repls#orge15e92d. If it works for you, I'll add it to the docs 👌Also, you still need to manually call (portal.api/open)
at the repl to open the Portal UI. The middleware doesn't automatically open the UI for you.
@U1G869VNV ok, let me try this
The thing at the bottom-left corner of Portal UI is I assume current path, is that true? But it seems that drilling down into a property via nav
integration resets it to []
. Would it be possible to make it to remember the full path? If I start with a list of users, select the 2nd one's id to nav
igate to her details, I'd like to see there still [1 :user/id]
. Or is it only showing the current selection? If so, would it make sense to add breadcrumbs showing the full path?
Yeah, that is the path of the currently selected value. The issue is that nav is one of many functions that can be applied to the currently selected value so concat'ing the path for all values in history doesn't generally make sense. What were you thinking a breadcrumb UI would look like / behave?
I see how that is complicated.
My use case is to allow users to navigate a graph of data via nav
and it would be useful, I imagine, if they knew where they are, like history in the browser. But at the same time it may be difficult to know what is a good name for each leg of the journey. E.g. portal can easily know that the user clicked the 5th User but for the human it would be better to show [:users
rather than [:users 4]. So perhaps I can look into creating my own bespoke breadcrumbs solution and see later whether it can be generalized...
I think one possible solution is to accumulate this info in the returned value as metadata :thinking_face:
If you have more deeply nested values, the tree viewer is a good choice. You can quickly switch through viewers with shift up / down for the currently selected value.
The reason the result is collapsed is that the eval result is wrapped in a map which increases its depth which is what Portal uses to decide what is expanded / collapsed by default. One thing the log viewer could do is reset the depth to make things more convenient :thinking_face:
This is why I have hot keys in Calva to cycle through viewers and to expand/collapse specific parts of a result. For middleware output, I can do ctrl+alt+space 2
to expand the "second" part -- the result -- or I can change the viewer with ctrl+alt+space 0
(and the first viewer it switches to is generally the tree viewer which works well for this).
https://github.com/djblue/portal/commit/52170ac6f5d07001d8f513ab5cbe170a28cbb9c7 will enable the result to be expanded by default 👌
Not quite sure how that would enable the result to expanded by default? You'd have to send metadata with everything with (some keyword and some value)?
The log viewer will decrement the depth for its result value, so the result will act as if it was one level higher.
Before this commit, Portal would use the depth to determine the background color. This solution would have caused issues with how Portal toggles the background between consecutive values. Now that they are decoupled, it's trivial for different viewers to adjust depth 👌
Ah, gotcha. Hence ctrl+alt+space 2
to expand the result part -- in future, I'll be able to use ctrl+alt+space 1
?
It won't change the selection targets, so you'll still need to dig into the log viewer to select the result. But, you'll be able to see a little more by default maybe reducing the need to expand as much.
OK. We'll see how that works in practice... I've gotten pretty used to using ctrl+enter
or alt+enter
for general eval where I don't care too much about the actual contents of the result and ctrl+t t
or ctrl+t space
for tap>
-based eval where I get "just" the value as a top-level expression (plus stdout plus test output plus any exceptions) instead of log-like output.
Yeah, I think this wont be useful for your workflow but might make the default nrepl middleware a little better. FYI if an eval result returns https://github.com/djblue/portal/blob/master/src/portal/nrepl.clj#L33, the nrepl middleware will ignore it 👌
BTW, are you on Mastodon?
After today's massive layoffs at Twitter and Musk's conspiracy theory RTs I'm no longer going to bother with it. I joined Mastodon a week ago and like it a lot better since you can join a small community and still interact with everyone in other communities (on other servers).
I mention it because I looked at my profile on Twitter today and it suggested I follow you there @djblue_live 🙂