         current-pr (when (= (get components 3) "pull") {:repo repo :pr pr})]
     (swap! state assoc :current-pr current-pr)))
 
-(defn ^:export watch []
+(defn ^:export watch
+  "Run `main` once, then watch for DOM mutations in the PJAX container and run `main` when
+  it changes"
+  []
   (let [is-valid-mutation? #(and (= (.-type %) "childList") (not-empty (.-addedNodes %)))
         observer (js/MutationObserver. #(when (some is-valid-mutation? %) (main)))]
     (.observe observer pjax-wrapper #js{:childList true :attributes false :characterData false})

(defn- add-icons! []
  (doseq [element (js/document.querySelectorAll ".commit-id")] (add-icon! element)))

(defn- find-commit [commit-id]
  (.-parentElement (.-parentElement (js/document.querySelector (str ".commit-id[href$='" commit-id "']")))))

(defn- update-icon! [commit-id new-class new-title]

   (let [auth-token (js/localStorage.getItem token-key)
         headers (if auth-token {"Authorization" (str "token " auth-token)} {})]
     (xhr/send url xhr-handler "GET" nil headers)))
  ([repo [from to]]
   (when (and from to)
     (get-new-commits! (str "https://api.github.com/repos/" repo "/compare/" from "..." to)))))

(defn- add-icon! [element]
  (let [parent (.-parentElement (.-parentElement element))]
