Fork me on GitHub
#portal
<
2022-10-31
>
dumrat07:10:02

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?

djblue07:10:53

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 👌

djblue07:10:09

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.

dumrat07:10:16

@U1G869VNV ok, let me try this

dumrat07:10:10

Yeah, this seems to work

Jakub Holý (HolyJak)09:10:24

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 navigate 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?

djblue16:10:45

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?

Jakub Holý (HolyJak)12:11:54

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...

djblue15:11:25

I think one possible solution is to accumulate this info in the returned value as metadata :thinking_face:

❤️ 1
dumrat13:10:44

How do I get portal to auto expand my result?

dumrat13:10:42

Note, works fine when sending tap> . But just eval in repl doesn't expand

dumrat13:10:47

not a huge issue

dumrat13:10:32

Related, is it possible to expand the object tree by default?

djblue16:10:41

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.

djblue16:10:51

You can also quickly expand values with the space or e shortcut

👍 1
djblue16:10:43

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:

seancorfield17:10:58

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).

👍 1
😻 1
seancorfield03:11:05

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)?

djblue03:11:56

The log viewer will decrement the depth for its result value, so the result will act as if it was one level higher.

djblue03:11:33

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 👌

seancorfield03:11:41

Ah, gotcha. Hence ctrl+alt+space 2 to expand the result part -- in future, I'll be able to use ctrl+alt+space 1?

djblue03:11:11

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.

seancorfield03:11:04

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.

👍 1
djblue03:11:24

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 👌

seancorfield03:11:34

I will say that I'm loving the stdout rendering 🙂

awesome 1
seancorfield03:11:32

BTW, are you on Mastodon?

djblue03:11:59

No I haven't tried it yet but was thinking about it 😆

seancorfield04:11:03

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).

💯 1
seancorfield04:11:42

I mention it because I looked at my profile on Twitter today and it suggested I follow you there @djblue_live 🙂

😆 1
👍 1