                  (aget (.. js/goog -dependencies_ -nameToPath) name)))))))
     {:merge-opts {:output-dir webdav-mount-point}}))
 
-(defrecord JscEnv [host port socket response-promise webdav-mount-point]
+(defrecord JscEnv [host port socket response-promise webdav-mount-point choose-first-discovered]
   repl/IParseStacktrace
   (-parse-stacktrace [this stacktrace error opts]
     (raw-stacktrace->canonical-stacktrace stacktrace opts))

(defn setup
  [repl-env opts]
  (let [_ (set-logging-level "javax.jmdns" java.util.logging.Level/SEVERE)
        [webdav-endpoint-name webdav-endpoint] (discover-and-pick-ambly-instance)
        _ (println "\nConnecting to" (service-name->display-name webdav-endpoint-name) "...\n")
        ; Assuming IPv4 for now
        endpoint-address (.getHostAddress (:address webdav-endpoint))

(defn discover-and-pick-ambly-instance
  "Looks for Ambly WebDAV services advertised via Bonjour and presents
  a simple command-line UI letting user pick one."
  [choose-first-discovered?]
  (let [reg-type "_http._tcp.local."
        discovered-services (atom (sorted-map))
        mdns-service (JmDNS/create)
