               (async/close! ws-in))))))
 
 (defn ^:dev/before-load stop []
+  (remove-watch state-ref ::render)
   (rd/unmountComponentAtNode (dom/by-id "root"))
   (when-let [ws (:ws @state-ref)]
     (.close ws)

   :padding-left 10})

(defstyled editor-container :div [_]
  {:height 200})

(defstyled html-toolbar :div [_]
  {:padding 10
   :font-weight "bold"})

(defn ui []
  (html-container
    (html-toolbar
      "[ALPHA] shadow-cljs REPL")

    (term-container {:ref attach-terminal})
    (editor-container
      (html/input {:ref attach-codemirror}))))

(defn ^:dev/after-load start []
  (let [cmd-in

    (let [term
          (doto (xterm/Terminal. #js {:disableStdin true
                                      :convertEol true
                                      :fontFamily "monospace"
                                      :fontSize 12
                                      :theme #js {:foreground "#000000"
                                                  :background "#FFFFFF"
                                                  :selection "rgba(0,0,0,0.3)"}})
