Skip to content

Commit

Permalink
Clear flow from UI when it's discarded from runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmonettas committed Jul 3, 2024
1 parent 80e32c6 commit 368ad1f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
7 changes: 6 additions & 1 deletion src-dbg/flow_storm/debugger/events_processor.clj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@

(defn- flow-created-event [flow-info]
(ui-utils/run-now
(ui-main/create-flow flow-info)))
(ui-main/create-flow flow-info)))

(defn- flow-discarded-event [flow-info]
(ui-utils/run-now
(flows-screen/remove-flow (:flow-id flow-info))))

(defn- threads-updated-event [{:keys [flow-id]}]
(ui-utils/run-now
Expand Down Expand Up @@ -103,6 +107,7 @@
:vanilla-namespace-uninstrumented (vanilla-namespace-uninstrumented-event ev-args-map)
:storm-instrumentation-updated-event (storm-instrumentation-updated-event ev-args-map)
:flow-created (flow-created-event ev-args-map)
:flow-discarded (flow-discarded-event ev-args-map)
:threads-updated (threads-updated-event ev-args-map)
:timeline-updated (timeline-updated-event ev-args-map)
:tap (tap-event ev-args-map)
Expand Down
28 changes: 15 additions & 13 deletions src-inst/flow_storm/nrepl/middleware.clj
Original file line number Diff line number Diff line change
Expand Up @@ -314,49 +314,51 @@

(comment
;; For testing middlewares

(let [p (promise)
#_:clj-kondo/ignore
(let [flow-id 0
thread-id 30
p (promise)
h (wrap-flow-storm (constantly true))]
(with-redefs [t/send (fn [_ rsp] (deliver p rsp))]

#_(h {:op "flow-storm-trace-count"
:flow-id nil
:thread-id 32})
:flow-id flow-id
:thread-id thread-id})

#_(h {:op "flow-storm-find-fn-call"
:fq-fn-symb "dev-tester/factorial"})

#_(h {:op "flow-storm-find-flow-fn-call"
:flow-id nil})
:flow-id flow-id})

#_(h {:op "flow-storm-get-form"
:form-id -798068730})

#_(h {:op "flow-storm-timeline-entry"
:flow-id nil
:thread-id 32
:flow-id flow-id
:thread-id thread-id
:idx 3
:drift "at"})

#_(h {:op "flow-storm-frame-data"
:flow-id nil
:thread-id 32
:flow-id flow-id
:thread-id thread-id
:fn-call-idx 0})

#_(h {:op "flow-storm-pprint"
:val-ref 5})

#_(h {:op "flow-storm-bindings"
:flow-id nil
:thread-id 32
:flow-id flow-id
:thread-id thread-id
:idx 8
:all-frame "true"})

#_(h {:op "flow-storm-toggle-recording"})

(h {:op "flow-storm-recorded-functions"})
#_(h {:op "flow-storm-recorded-functions"})

#_(h {:op "flow-storm-clear-recordings"})
(h {:op "flow-storm-clear-recordings"})

(deref p 1000 :no-response)))
)
3 changes: 2 additions & 1 deletion src-inst/flow_storm/runtime/debuggers_api.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@
(map first)
(into #{}))]
(doseq [fid flows-ids]
(discard-flow fid))
(discard-flow fid)
(rt-events/publish-event! (rt-events/make-flow-discarded-event fid)))

(rt-values/clear-vals-ref-registry)))

Expand Down
3 changes: 3 additions & 0 deletions src-inst/flow_storm/runtime/events.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
:form (pr-str form)
:timestamp timestamp}])

(defn make-flow-discarded-event [flow-id]
[:flow-discarded {:flow-id flow-id}])

(defn make-threads-updated-event [flow-id]
[:threads-updated {:flow-id flow-id}])

Expand Down

0 comments on commit 368ad1f

Please sign in to comment.