      "Get started by selecting your GitHub username or organization on the left."]
     [:li "Choose a repo you want to test and we'll do the rest!"]]])
 
+(defn start-first-build-after-follow
+  "Starts first build by tapping the API channel and starting a build when we successfully follow"
+  [repo-id controls-ch api-ch]
+  (let [api-tap (chan (sliding-buffer 10))
+        timeout (async/timeout 30000)]
+    (async/tap (async/mult api-ch) api-tap)
+    (go-loop []
+             (alt! api-tap ([v]
+                              (condp = v
+                                [:followed-repo :success repo-id]
+                                (do (put! controls-ch [:start-first-build {:repo-id repo-id}])
+                                    (close! api-tap))
+
+                                [:followed-repo :failed repo-id] (close! api-tap)
+
+                                nil (println "not recurring on closed channel")
+
+                                (recur)))
+
+                   timeout (do (close! api-tap)
+                               (print "gave up on first build after 30 seconds"))))))
+
+(defn start-first-build-after-follow-watcher
+  "Starts first build by watching app-state noticing when we successfully follow"
+  [app repo-id controls-ch]
+  (let [listener-id (utils/uuid)]
+    (add-watch app listener-id (fn [_ _ _ new-state]
+                                 (when (->> new-state
+                                            :current-repos
+                                            (filter #(= repo-id (repo-model/id %)))
+                                            first
+                                            :following)
+                                   (remove-watch app listener-id)
+                                   (put! controls-ch [:start-first-build {:repo-id repo-id}]))))
+    (js/setTimeout #(remove-watch app listener-id) 30000)))
+
 (defn repo-item [data owner opts]
   (reify
     om/IRender

            [sablono.core :as html :refer-macros [html]]
            [clojure.string :as string]
            [goog.string :as gstring]
            [goog.string.format]))

(defn missing-scopes-notice [current-scopes missing-scopes]
  [:div

      (let [repo (:repo data)
            repo-id (repo-model/id repo)
            controls-ch (:controls-ch data)
            api-ch (:api-ch data)
            settings (:settings data)
            should-build? (repo-model/should-do-first-follower-build? repo)]
        (html
         (cond (repo-model/can-follow? repo)
               [:li.repo-follow {:class (when should-build? "repo-1stfollow")}
                [:div.proj-name
                 [:span {:title (str (vcs-url/project-name (:vcs_url repo))
                                     (when (:fork repo) " (forked)"))}
                  (:name repo)]
                 (when (:fork repo)
                   [:span.forked (str " (" (vcs-url/org-name (:vcs_url repo)) ")")])]
                [:button {:on-click #(do (when should-build?
                                           (start-first-build-after-follow repo-id controls-ch api-ch))
                                         (put! controls-ch [:followed-repo repo-id]))
                          ;; XXX implement data-spinner
                          :data-spinner "true"}
                 [:span "Follow"]]]
