Skip to content

Commit e953b5c

Browse files
fix(discover): allow proceed when native epoch-cb is available, no 10x required
Closes #15. discover used to refuse with :ns-not-loaded any time :ten-x-loaded? was false. Since the native epoch-cb path landed (rf-ybv, re-frame ≥ 1.4), re-frame-pair's runtime can read epochs without 10x — the panel-based UI is one consumer of the trace stream, not the only one. discover wasn't aware. Now: refuse only when both :ten-x-loaded? AND :native-epoch-cb? are false. With the native cb installed, discover succeeds even on stacks that don't use 10x (re-frisk, plain dev tools, no panel UI at all). Hint updated to name both alternatives. 2 new deftests cover the two new branches: native-cb-true-no-10x → success; both-false → :ns-not-loaded with the new hint. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5e98434 commit e953b5c

2 files changed

Lines changed: 53 additions & 2 deletions

File tree

scripts/ops.clj

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,10 +1037,15 @@
10371037
(not (:ok? health))
10381038
(emit (with-version health))
10391039

1040-
(not (:ten-x-loaded? health))
1040+
;; #15 — only refuse on missing 10x when the native epoch cb
1041+
;; (re-frame ≥ rf-ybv) is also unavailable. With the native cb
1042+
;; installed, re-frame-pair can read epochs without 10x — useful
1043+
;; for stacks using re-frisk or no panel-based dev tooling at all.
1044+
(and (not (:ten-x-loaded? health))
1045+
(not (:native-epoch-cb? health)))
10411046
(emit (with-version
10421047
{:ok? false :reason :ns-not-loaded :missing :re-frame-10x
1043-
:hint "Add re-frame-10x to your dev deps and preloads."}))
1048+
:hint "No epoch source available. Either add re-frame-10x to dev deps + preloads, or upgrade to re-frame ≥ 1.4 (which provides register-epoch-cb — re-frame-pair installs it automatically and consumes epochs without 10x)."}))
10441049

10451050
(not (:trace-enabled? health))
10461051
(emit (with-version

tests/ops_smoke.bb

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,9 @@
12041204
ops/inject-runtime! (fn [_build-id _opts]
12051205
{:ok? true
12061206
:ten-x-loaded? false
1207+
;; #15 — also no native cb,
1208+
;; so :ns-not-loaded fires.
1209+
:native-epoch-cb? false
12071210
:trace-enabled? true})
12081211
ops/startup-context (fn [_build-id] {})
12091212
ops/version-check (fn [] {:current "0.1.0-beta.6"
@@ -1214,6 +1217,49 @@
12141217
(is (= "0.1.0-beta.6" (:version @emitted))
12151218
"operator reporting a bug always sees their version")))))
12161219

1220+
(deftest discover-proceeds-without-ten-x-when-native-epoch-cb-present
1221+
(testing "#15 — discover does NOT block on missing 10x when native epoch cb is available"
1222+
(let [emitted (atom nil)]
1223+
(with-redefs [ops/ensure-port! (fn [] true)
1224+
ops/read-port (fn [] 8777)
1225+
ops/shadow-cljs-available? (fn [_] true)
1226+
ops/list-builds-on-port (fn [_] [:app])
1227+
ops/inject-runtime! (fn [_build-id _opts]
1228+
{:ok? true
1229+
:ten-x-loaded? false
1230+
:native-epoch-cb? true
1231+
:trace-enabled? true
1232+
:re-com-debug? true
1233+
:versions {:by-dep {}}})
1234+
ops/startup-context (fn [_build-id] {})
1235+
ops/version-check (fn [] nil)
1236+
ops/emit (fn [m] (reset! emitted m))]
1237+
(#'ops/discover [])
1238+
(is (true? (:ok? @emitted))
1239+
"discover succeeds with no 10x because native epoch cb is the alternate epoch source")
1240+
(is (not= :ns-not-loaded (:reason @emitted))
1241+
"no :ns-not-loaded refusal when native cb is present")))))
1242+
1243+
(deftest discover-blocks-when-both-ten-x-and-native-cb-missing
1244+
(testing "#15 — discover still blocks when neither 10x nor the native epoch cb is available"
1245+
(let [emitted (atom nil)]
1246+
(with-redefs [ops/ensure-port! (fn [] true)
1247+
ops/read-port (fn [] 8777)
1248+
ops/shadow-cljs-available? (fn [_] true)
1249+
ops/list-builds-on-port (fn [_] [:app])
1250+
ops/inject-runtime! (fn [_build-id _opts]
1251+
{:ok? true
1252+
:ten-x-loaded? false
1253+
:native-epoch-cb? false
1254+
:trace-enabled? true})
1255+
ops/startup-context (fn [_build-id] {})
1256+
ops/version-check (fn [] nil)
1257+
ops/emit (fn [m] (reset! emitted m))]
1258+
(#'ops/discover [])
1259+
(is (= :ns-not-loaded (:reason @emitted)) "still refuses when no epoch source at all")
1260+
(is (str/includes? (:hint @emitted) "register-epoch-cb")
1261+
":hint mentions the native cb as an alternative to 10x")))))
1262+
12171263
;; ---------------------------------------------------------------------------
12181264
;; Tests for issue #14: refuse non-shadow-cljs nREPLs early with a structured
12191265
;; :unsupported-build-tool, instead of crashing on the first call to

0 commit comments

Comments
 (0)