                                              (when (re-find #"^/" url)
                                                {:X-CSRFToken (utils/csrf-token)})
                                              headers)
-                             :handler #(put! channel (assoc % :status :success :scopes (scopes-from-response %)))
+                             :handler #(put! channel (assoc % :status :success))
                              ;; TODO: clean this up
                              :error-handler #(put! channel (normalize-error-response % {:url url}))
                              :finally #(close! channel)}))

   :content-type "application/xml"
   :write identity})

(defn scopes-from-response [api-resp]
  (if-let [scope-str (get-in api-resp [:response-headers "X-Circleci-Scopes"])]
    (->> (str/split scope-str #"[,\s]+")
         (map #(str/replace % #"^:" ""))
         (map keyword)
         (set))))

(defn normalize-error-response [default-response props]
  (-> default-response
      (merge props)

                                               {:X-CSRFToken (utils/csrf-token)})
                                             headers)
                             :handler #(binding [frontend.async/*uuid* uuid]
                                         (put! channel [message :success (assoc % :context context)]))
                             :error-handler #(binding [frontend.async/*uuid* uuid]
                                               (put! channel [message :failed (normalize-error-response % {:url url :context context})]))}
                      :edn {:format (clj-ajax/edn-format)
                            :params params
                            :handler #(binding [frontend.async/*uuid* uuid]
                                        (put! channel [message :success {:resp % :context context}]))
                            :error-handler #(binding [frontend.async/*uuid* uuid]
                                              (put! channel [message :failed (normalize-error-response % {:url url :context context})]))}

                      ;; TODO: use a custom reader or similar for raw to handle more like json
                      :raw {:format (clj-ajax/raw-format)
                            :handler #(binding [frontend.async/*uuid* uuid]
                                        (put! channel [message :success {:resp (utils/inspect %) :context context}]))
                            :error-handler #(binding [frontend.async/*uuid* uuid]
                                       (put! channel [message :failed {:resp % :url url :context context :status :failed}]))})]
    (clj-ajax/ajax-request url method
                           (clj-ajax/transform-opts format-opts))))

;; This is all very mess, it should be cleaned up at some point
(defn managed-ajax [method url & {:keys [params keywords? headers format response-format]
