Fork me on GitHub
#portal
<
2024-02-28
>
chromalchemy03:02:38

I’m trying execute a portal ui command from a code window.

(ns gbo.portal
  (:require
   [portal.api :as p]
   [portal.ui.commands :as pui]))

returns
> Execution error (FileNotFoundException) at gbo.portal/eval11569$loading (REPL:1).
>  Could not locate portal/ui/commands__init.class, portal/ui/commands.clj or portal/ui/commands.cljc on classpath
The normal portal.api works fine. Im attempting to execute (pui/toggle-shell state) from code. (so I dont have to focus portal window and go through ui. If i can load dependency fn… what would state be in this case? Does the portal instance need to be defined as a def ? Would I need surface the session id? What is the idiomatic way to reference a portal window.

djblue05:02:47

So to execute ui commands, you need to send code to the client. https://github.com/seancorfield/vscode-calva-setup/blob/develop/calva/config.edn#L141-L153 is an example of how to do it. I have been thinking about making this easier from the user's runtime, but haven't gotten around to it yet.

chromalchemy17:02:42

Looks a bit over my head atm. I am familiar w Calva repl snippets and will try some cut&paste to try out. Thanks for the pointers!

djblue20:02:33

I think the main thing you probably care about in the above snippets is:

(p/eval-str portal "(portal.ui.commands/toggle-shell portal.ui.state/state)")