I think I found a bug in the statecharts rad integration. I have a mutation that does a pathom query, and uses that data to create a form. I used to be able to do this:
(form/create! app :ns.of.account/Form {:initial-state {:account/name "Bill" :account/email ""})
This would fill in the form using the data from the mutation. Using the rad sc integration (ri/create!) it fails to fill in the form. I can see the initial-state dict on :options in the statechart's local memory, but the ui form is not filled in. How to pass the form fields correctly using the rad-integration?Full mutation code for reference.
#?(:clj
(pco/defmutation generate-ai
"generate new AI chat completion"
[env params]
{::pco/input [:prompt/content
(pco/? :prompt/system)
(pco/? :model)
(pco/? :seed)
(pco/? :max_tokens)
(pco/? :temperature)]}
(let [r (chat-completion env params)]
#_(tap> {:from ::generate-ai-clj :env env :params params :r r :i i})
; generate tempids map for fulcro/datomic save middleware
(assoc-in r [:tempids] (hash-map (tempid/tempid) (:chat-completion/id r)))))
:cljs
(m/defmutation generate-ai [{:keys [tempid] :as params}]
(remote [env] (m/returning env :us.whitford.gailish.ui.chat-completion-forms/ChatCompletionForm))
(ok-action [{:keys [app result] :as env}]
#_(tap> {:from ::generate-ai-cljs-ok-action :env env})
(ri/create! app :us.whitford.gailish.ui.chat-completion-forms/ChatCompletionForm
(let [r (get-in result [:body `generate-ai])]
(tap> {:from ::ok-action :r r})
; strip id here, pathom will query db if included
; id readded in save middleware from :tempids injected by clj mutation
{:initial-state (dissoc r :chat-completion/id)})))))the RAD integration is new and not heavily tested…so not surprised if I missed something. Look at the implementation of form/create! vs the new integration and it will prob be obvious, then send a PR. I’m swamped right now
I’m actively works on this stuff, but in the context of a consulting project, and I’ve got a ton of other stuff to do, so I’ll reach these issues as I go, but otherwise reports with PRs are nice.
After clearing up an issue with a missing conditional cljs tag from clj, this is working now. Not sure what fixed it but it was probably on my side,