portal

hanDerPeder 2023-10-20T11:00:26.323009Z

seems portal.runtime/session only contains the latest primary selection under :selection . would it be possible to also update for multi-select?

hanDerPeder 2023-10-20T11:02:54.876309Z

I find myself doing this:

;; click first arg
(def arg1 @session)
;; click second arg
(def arg2 @session)
(my-func arg1 arg2)
would be nice if I could alt click my arguments and do:
;; click first arg
;; alt-click second arg
(apply my-func @session)

hanDerPeder 2023-10-20T11:05:13.930239Z

same goes for registered functions, seems they only get the primary selection

djblue 2023-10-20T16:15:46.148139Z

https://github.com/djblue/portal/blob/master/src/portal/ui/state.cljs#L306is the code responsible for syncing the selected values with the runtime. We could update it to send all selected values instead of just the first one. We would also need to update the https://github.com/djblue/portal/blob/master/src/portal/runtime/jvm/client.clj#L58 to only pull the first to preserve the existing API. How would you want to access all the selected values from a session? I could see adding a portal.api/selected function 🤔

hanDerPeder 2023-10-20T16:36:58.107919Z

portal.api/selected seems good for discoverability. We access portal from a dev ns so I'll probably roll my own.

djblue 2023-10-20T16:44:22.782499Z

Is this feature something you want take a crack at?

hanDerPeder 2023-10-20T16:45:12.637729Z

sure, I'll send a PR asap 👍

🙏 1
lukasz 2023-10-20T15:57:16.467999Z

Is there a way of changing fonts/colors at run time via portal.api? Or at least pass a custom theme when creating a session - my use case is to provide an editor integration with emacs similar to VS Code - syncing colors and font sizes

djblue 2023-10-20T16:19:41.608819Z

I think I currently bake the themes into the UI, but that should be relatively easy to change. What kind of API are you thinking would be ideal here? I think defining themes should be independent of any particular session but selecting the default theme will be per session. You mention syncing, how would you expect to update a theme, put or patch?

lukasz 2023-10-20T16:23:23.706819Z

I was thinking of something as simple as passing a map, rather than a keyword for a predefined theme - then you can do this as "simply" (😉 ) as:

(portal.api/open {:theme (merge (:portal.colors/nord-light portal.colors/theme) {:font-size 8})
I'm still toying with the Portal <-> Monroe (the nREPL client for Emacs) integration, and making slow progress - so passing current front size from Emacs when invoking the code above would be pretty straight forward

djblue 2023-10-20T16:24:55.005849Z

Ohh, so you would want to be able to tweak existing themes slightly, not necessarily create a new theme?

lukasz 2023-10-20T16:25:38.902359Z

With the above you can do both, either modify existing one, or provide a completely new one without shipping it with portal itself

lukasz 2023-10-20T16:26:20.212439Z

"modify" in the sense that you're passing a custom theme based on an existing one

👍 1
djblue 2023-10-20T16:26:38.299629Z

So with the above example, if the window has already been opened, how would you expect to sync the theme?

lukasz 2023-10-20T16:28:55.808959Z

Ah, good question 🤔 I didn't think about what happens after, I never change font sizes or themes in my editor :D I'd guess it would have to be something that portal.api would have to expose too - something along the lines of (portal.api/set-theme :session-id {:some-theme :map})) (I'm very new to portal, so I'm a bit hazy on the details of using sessions etc - I always use just one)

djblue 2023-10-20T16:32:30.003129Z

I think that could work, but if we make it independent of sessions it might be easier to use. Something like:

(portal.api/set-theme ::my-theme (merge (:portal.colors/nord-light portal.colors/theme) {:font-size 8}))
(portal.api/open {:theme ::my-theme})
(portal.api/set-theme ::my-theme {:font-size 12}) ;; assuming set theme will merge?

djblue 2023-10-20T16:33:10.008149Z

This way your emacs integration wouldn't have to worry about sessions at all

lukasz 2023-10-20T16:34:12.265609Z

Indeed!

lukasz 2023-10-20T16:35:47.600829Z

as an aside, I wish I used Portal earlier, I was aware of it but now that I'm using it in earnest it has super charged my workflow - I built a couple of utility functions to debug Postgres errors coming from JDBC, with SQL syntax formatting, dealing with the dreaded "Invalid query... postiion 10000" and stuff like that. Works amazingly when debugging queries generated via HoneySQL

1
djblue 2023-10-20T16:39:33.344349Z

That's awesome! I feel like enabling custom debug workflows is exactly how I wanted people to use Portal, I'm really glad it's serving you well.

djblue 2023-10-20T16:41:01.859469Z

If you feel like this is something others might find useful and feel like doing so, a new "Honey SQL" https://github.com/djblue/portal/tree/master/doc/guides in Portal would be amazing!

lukasz 2023-10-20T16:42:01.174649Z

I need to tidy it up, it's quite messy right now - and it uses an external dependency to reformat the query string (HoneySQL's "pretty" formatting is really basic, understandably)

djblue 2023-10-20T16:42:40.351809Z

Gotcha, yeah getting things into a sharable state is always a challenge 👌

djblue 2023-10-20T16:50:51.935299Z

If you do get something together that is sharable before the 24th, I would be down to demo it in my "Portal Internals" talk

lukasz 2023-10-20T16:51:15.706989Z

Would a screenshot be enough? :-)

1
djblue 2023-10-20T16:52:12.522219Z

Yeah, that would be great! Also, maybe some points on your workflow

lukasz 2023-10-20T16:52:30.524699Z

no promises, but I'll try to jot something down 🤞

🙏 1
lukasz 2023-10-20T20:35:11.823209Z

@djblue best I could do in such a short time :-) https://gist.github.com/lukaszkorecki/6031472de7514a27261c06f4d9ae865a - I think the code viewer can also do syntax highlighting but I didn't dig that deep

🙏 2