                  (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))

      (loop [current-discovered-services @discovered-services]
        (println)
        (print-services current-discovered-services)
        (println "\n[r] Refresh\n")
        (print "Choice: ")
        (flush)
        (let [choice (read-line)]
          (if (= "r" choice)
            (recur @discovered-services)
            (let [choices (service-map->choice-list current-discovered-services)

(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)
