Skip to content

Commit

Permalink
Make thread auto-update configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmonettas committed Dec 19, 2024
1 parent 3978cc6 commit 1b34294
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

### Changes

- Thread tab auto-update every 1sec (no more red arrow needed)
- Configurable thread tab auto-update every 1sec (on by default)
- Remove middleware dependency on cider-nrepl-middleware
- Aspect extractors signature deprecation. Now it recieves the object and a map with extras

Expand Down
2 changes: 1 addition & 1 deletion build.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[clojure.spec.alpha :as s]))

(def version (or (System/getenv "VERSION")
"4.1.0-SNAPSHOT"))
"4.1.0-beta2"))

(def target-dir "target")
(def class-dir (str target-dir "/classes"))
Expand Down
4 changes: 3 additions & 1 deletion src-dbg/flow_storm/debugger/events_processor.clj
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@
;; If there is a tab open for the thread already, update it
(when (dbg-state/get-thread flow-id thread-id)
(ui-utils/run-later
(flows-screen/update-outdated-thread-ui flow-id thread-id))))
(if (:auto-update-ui? (dbg-state/debugger-config))
(flows-screen/update-outdated-thread-ui flow-id thread-id)
(flows-screen/make-outdated-thread flow-id thread-id)))))

(defn- task-submitted-event [_]
(ui-main/set-task-cancel-btn-enable true))
Expand Down
10 changes: 8 additions & 2 deletions src-dbg/flow_storm/debugger/state.clj
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,15 @@
(s/def :config/runtime-host string?)
(s/def :config/debug-mode? boolean?)
(s/def :config/auto-jump-on-exception? boolean?)
(s/def :config/auto-update-ui? boolean?)

(s/def ::debugger-config (s/keys :req-un [:config/repl
:config/debugger-host
:config/debugger-ws-port
:config/runtime-host
:config/debug-mode?
:config/auto-jump-on-exception?]))
:config/auto-jump-on-exception?
:config/auto-update-ui?]))

(s/def :bookmark/id (s/tuple :flow/id :thread/id int?))
(s/def :bookmark/flow-id :flow/id)
Expand Down Expand Up @@ -270,7 +272,8 @@
:debugger-ws-port (or ws-port 7722)
:runtime-host (or runtime-host "localhost")
:debug-mode? false
:auto-jump-on-exception? false}
:auto-jump-on-exception? false
:auto-update-ui? true}
:bookmarks {}
:visualizers {}
:data-windows {}})
Expand Down Expand Up @@ -316,6 +319,9 @@
(defn set-auto-jump-on-exception [enable?]
(swap! state assoc-in [:debugger-config :auto-jump-on-exception?] enable?))

(defn set-auto-update-ui [enable?]
(swap! state assoc-in [:debugger-config :auto-update-ui?] enable?))

(defn toggle-debug-mode []
(swap! state update-in [:debugger-config :debug-mode?] not))

Expand Down
6 changes: 5 additions & 1 deletion src-dbg/flow_storm/debugger/ui/components.clj
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@
[javafx.scene.web WebView WebEngine]))


(defn menu-item [{:keys [text on-click accel check-item? disable?]}]
(defn menu-item [{:keys [text on-click accel check-item? checked? disable?]}]
(let [mi (if check-item?
(CheckMenuItem. text)
(MenuItem. text))]
(.setOnAction mi (event-handler [_]
(if check-item?
(on-click (.isSelected mi))
(on-click))))

(when check-item?
(.setSelected mi (boolean checked?)))

(when disable?
(.setDisable mi true))
(when accel
Expand Down
18 changes: 18 additions & 0 deletions src-dbg/flow_storm/debugger/ui/flows/screen.clj
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,24 @@
(flow-fns/update-functions-pane flow-id thread-id)
(flow-code/update-thread-trace-count-lbl flow-id thread-id))

(defn make-outdated-thread [flow-id thread-id]
(when-let [[^Tab tab] (obj-lookup flow-id thread-id "tab")]
(let [th-info (dbg-state/get-thread-info thread-id)
thread-label (ui/thread-label (:thread/id th-info) (:thread/name th-info))
refresh-tab-content (ui/h-box
:childs [(ui/label :text thread-label)
(ui/icon-button :icon-name "mdi-reload"
:tooltip "There are new recordings for this thread, click this button to update the UI."
:on-click (fn []
(update-outdated-thread-ui flow-id thread-id)
(doto tab
(.setText thread-label)
(.setGraphic nil)))
:classes ["thread-refresh" "btn-sm"])])]
(doto tab
(.setText nil)
(.setGraphic refresh-tab-content)))))

(defn update-threads-list [flow-id]
(let [[{:keys [set-items menu-button] :as menu-data}] (obj-lookup flow-id "flow_threads_menu")]
(when menu-data
Expand Down
7 changes: 6 additions & 1 deletion src-dbg/flow_storm/debugger/ui/main.clj
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,12 @@
:on-click (fn [] (ask-and-set-threads-limit))}
{:text "Auto jump to exceptions"
:check-item? true
:on-click (fn [enable?] (dbg-state/set-auto-jump-on-exception enable?))}])
:checked? (:auto-jump-on-exception? (dbg-state/debugger-config))
:on-click (fn [enable?] (dbg-state/set-auto-jump-on-exception enable?))}
{:text "Auto update UI"
:check-item? true
:checked? (:auto-update-ui? (dbg-state/debugger-config))
:on-click (fn [enable?] (dbg-state/set-auto-update-ui enable?))}])
help-menu (ui/menu :label "_Help"
:items [{:text "Tutorial"
:on-click (fn []
Expand Down

0 comments on commit 1b34294

Please sign in to comment.