Fork me on GitHub
#portal
<
2023-08-22
>
chromalchemy18:08:32

@clojurians.net What is the way to customize viewers when evaluating stuff in Portal via Playback? https://cljdoc.org/d/djblue/portal/0.46.0/doc/ui-concepts/viewers Specifically, If I have a sequence of maps that I would like to reliably see as a table , on repeated evaluations. Or with the default inspector, at least have maps auto-expanded… (would like to be able to do this with just Portal also..) I would be nice if this could be easily changed at the function location, to change default viewer as the function evolves. Or is this more a general Portal consideration? since Playback has it’s own sense of custom viewer to show the incremental computations?

djblue18:08:29

I would suspect that if the value arrived to portal with the metadata like {:portal.viewer/default :portal.viewer/table} it would use the table viewer by default

djblue18:08:09

In terms of expansion, I would use the new expand-inc command. It allows for quick incremental expansion of children values.

djblue18:08:40

You can also use the command via the shift+space or shift+e shortcuts

chromalchemy18:08:33

OK I’ll try that. Is that to prevent performance issues if all the Maps are auto expanded? I’m assuming the rest of a long sequence is lazy loaded?

djblue19:08:03

I would say keeping things collapsed by default is more stylistic with my preference being showing less by default. For performance, values are lazily rendered based on if they are near the viewport independently of if they are expanded or collapsed.

djblue19:08:20

However, I have been playing with the idea of additional metadata to specify expansion depth :thinking_face:

chromalchemy19:08:28

Interesting. I thought that it might be there somewhere. At least I could run the expand inc n times automatically after the evaluation if i need it..

chromalchemy19:08:59

My experience using the Cursive repl is that the results window is cleared before every evaluation (via custom repl command), and I turn off the auto-scroll-to-bottom, so the top of the results just kind of stay in place from evaluation to evaluation, so I can focus on the (top) result data, static but evolving over time, and not be distracted by the previous results.

gnl19:08:40

Off the top of my head, I'm thinking I could just pass any metadata through to tap>/Portal, so you can do anything you like and even use newer Portal features related to this without needing any changes in Playback.

djblue19:08:13

(def last-tap (atom nil))
(defn submit [value] (reset! last-tap value))
(portal.api/inspect last-tap)
(add-tap #'submit)
@U09D96P9B ☝️ might suit your workflow better then 👌

chromalchemy19:08:30

@clojurians.net Can i do that now? I am familiar with the preload code.

chromalchemy19:08:42

@djblue thanks! Ill try that

gnl19:08:04

> Can i do that now? I am familiar with the preload code. @U09D96P9B I think this will probably require changes to debux, but it should be a straightforward thing and it makes a lot of sense, so maybe this or next week.

djblue19:08:05

Are values flowing directly to portal or is there some serialization happening that strips the metadata?

gnl19:08:36

I think if you're tracing a simple value rather than, say, a threading macro, it should probably flow straight through to Portal, so maybe that's already working actually.

👍 2
gnl19:08:16

Gonna take a closer look at the debux code later.

gnl19:08:11

Oh, and Chris – let me use this opportunity to say thanks for Portal, I (obviously) love it. :)

❤️ 4
chromalchemy20:08:29

@djblue I tried to recommendation in the previous thread. And it is working to clear and reset the view every time I evaluate a tap. But the default table viewer is not working as expected for a sequence of maps. The first value is selected, and the default inspector is in effect ( because the table viewer is not possible with this selection?). If I select the parent container (4 in this example), then I can access the table viewer.

(tap> ^{:portal.viewer/default :portal.viewer/table} sequence-of-maps)

djblue21:08:41

I think here you want to use with-meta since it needs to apply metadata to a dynamic value. Currently, the metadata is being set on the symbol.

2
chromalchemy21:08:31

That worked. Thank you

👍 2
djblue21:08:33

I wonder if having an actual portal.viewer namespace with helper functions would be useful. I feel like the nuance of metadata might be an unnecessary barrier here :thinking_face: The helper fns could also provider some help if the input doesn't conform to the viewers assumptions.

djblue21:08:23

Do you think a portal.viewer ns would have been helpful for you?

djblue22:08:46

Might also be useful for discoverability via code auto complete :thinking_face:

chromalchemy19:08:54

@djblue Yes that would be awesome. I’m not too experienced with metatdata, and also the pattern you gave me of (add-tap #'fn) passing vars..

chromalchemy20:08:13

For context, I have switched from over to vscode from Cursive, prompted by trying to using this https://www.cursorless.org/ . Which has prompted me to go deeper than I ever have for editor/repl setup (never did emacs, was ok with parinfer, etc) Part of the value proposition beyond full on voice coding for ergonomic reasons, is intuitive immediate access to potentially unlimited amount of commands (a command grammar), without overloading and short-circuiting on keyboard hotkeys (limited real estate both physically and in immediate muscle memory). Command pallets get most of the way there in terms of broad access, but vocal commands are even more immediate, and parameters can be declared inline, and the eye can navigate faster than the mouse, etc…. Long story short, it’s been a huge invitation to take “scripting” more seriously. So I truly appreciate the effort you have made for surfacing the api for all this repl stuff. I am leveraging Calva custom repl snippets to call as many Portal functions as needed to have a rich lexicon for dynamic evaluation. Any code I can see in window, or that is “bookmarked” I can immediately and naturally evaluate with a single command, in whatever flavor of eval context (top level, etc) or viewer, with a dynamic tap> + meta. And I also want to drive the ui and post-evaluate selections, etc..

👍 1