Skip to content

Commit

Permalink
handle disconnect runtime in inspect
Browse files Browse the repository at this point in the history
  • Loading branch information
thheller committed May 19, 2024
1 parent c3689e0 commit 4cc37fc
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/main/shadow/cljs/ui/components/build.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
[env build-id]
(->> (::m/runtime env)
(vals)
(remove :disconnected)
(filter (fn [{:keys [runtime-info]}]
(and (= :cljs (:lang runtime-info))
(= build-id (:build-id runtime-info)))))
Expand Down
11 changes: 7 additions & 4 deletions src/main/shadow/cljs/ui/components/inspect.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@
(event ::code-eval! [env {:keys [code]}]
(sg/run-tx env
{:e ::m/inspect-code-eval!
:runtime-ident (:runtime object)
:runtime-id (:runtime-id object)
:ref-oid (:oid object)
:panel-idx panel-idx
:code code}))
Expand Down Expand Up @@ -367,19 +367,22 @@

(render
(let [{:keys [ns line column label]} summary
{:keys [runtime-info runtime-id]} runtime
{:keys [runtime-info runtime-id disconnected]} runtime

$row
(css
:font-mono :border-b :px-2 :py-1 :cursor-pointer
[:hover :bg-gray-100]
["&.disconnected" :cursor-not-allowed {:opacity "0.5"}]
["&.focus" :bg-gray-200]
["& > .header" :text-xs :text-gray-500]
["& > .val" :truncate])]

(<< [:div
{:class (str $row (when focus " focus"))
:on-click {:e ::inspect-object! :oid oid}}
{:class (str $row (when focus " focus") (when disconnected " disconnected"))
:title (when disconnected "runtime disconnected")
:on-click (when-not disconnected
{:e ::inspect-object! :oid oid})}

[:div.header
(str (:added-at-ts summary)
Expand Down
1 change: 1 addition & 0 deletions src/main/shadow/cljs/ui/components/runtimes.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
(defn q-runtimes-sorted [env]
(->> (::m/runtime env)
(vals)
(remove :disconnected)
(sort-by #(get-in % [:runtime-info :since]))
(mapv :runtime-id)))

Expand Down
4 changes: 2 additions & 2 deletions src/main/shadow/cljs/ui/db/explorer.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,5 @@

(defn runtime-deselect-var!
{::ev/handle ::m/runtime-deselect-var!}
[tx {:keys [runtime-ident] :as msg}]
(update-in tx [::m/ui runtime-ident] dissoc ::m/explore-var ::m/explore-var-object))
[tx {:keys [runtime-id] :as msg}]
(update-in tx [::m/runtime runtime-id] dissoc ::m/explore-var ::m/explore-var-object))
6 changes: 4 additions & 2 deletions src/main/shadow/cljs/ui/db/inspect.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
(ev/queue-fx :relay-send [{:op :request-supported-ops :to client-id}])))

:client-disconnect
(update env ::m/runtime dissoc client-id)))
(assoc-in env [::m/runtime client-id :disconnected] true)))

(defn relay-supported-ops
{::ev/handle ::relay-ws/supported-ops}
Expand Down Expand Up @@ -442,7 +442,9 @@
(defn inspect-code-eval!
{::ev/handle ::m/inspect-code-eval!}
[tx {:keys [code runtime-id runtime-ns ref-oid panel-idx] :as msg}]
(let [{:keys [supported-ops]} (get-in tx [::m/runtime runtime-id])
(let [supported-ops (get-in tx [::m/runtime runtime-id :supported-ops])

_ (js/console.log "code-eval" tx msg supported-ops)

;; FIXME: ns and eval mode should come from UI
[eval-mode ns]
Expand Down
3 changes: 3 additions & 0 deletions src/main/shadow/cljs/ui/main.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{:dev/always true
:shadow.css/include ["shadow/cljs/ui/main.css"]}
(:require
[clojure.core.protocols :as cp]
[shadow.grove :as sg :refer (<< defc)]
[shadow.css :refer (css)]
[shadow.grove.history :as history]
Expand Down Expand Up @@ -224,6 +225,8 @@

(sg/add-kv-table rt-ref ::m/object
{:primary-key :oid
:attrs
{:runtime-id {:references ::m/runtime}}
;; :oid number
;; :runtime-id number
;; :display-type keyword
Expand Down

0 comments on commit 4cc37fc

Please sign in to comment.