 
 ; --------------------------------------------
 
-(defn prog-event [f]
+(defn prog-event [label f]
   (swap! prog-history #(let [ph (f %)]
                          (update-in ph [:prog-events]
                                     conj [(count (:prog-events ph))
-                                          :event
-                                          (:prog-peers ph)]))))
+                                          label
+                                          {:prog-peers (:prog-peers ph)}]))))
 
 (defn kv-server [server-addr & ports]
   (let [world (:world @prog-base)

                   [server-addr port listen-result-ch])
             (when-let [[accept-ch close-accept-ch] (atake server-init listen-result-ch)]
               (cbfg.world.net/server-accept-loop world accept-ch close-accept-ch)
               (prog-event #(update-in % [:prog-peers :servers server-addr]
                                       conj port)))))
         (reset! done true))
    (wait-done done)))

                          ;   :res-ch => ch }

(def prog-history
  (atom {:prog-peers {:servers {}  ; { server-addr => ports }.
                      :clients {}} ; { client-addr => client-info }.
         :prog-events []})) ; Each event is [ts label args].

(def run-world       (atom nil))
(def run-world-hover (atom nil))

; -------------------------------------------------------------------

(defn render-world [app owner]
  (apply dom/ul nil
         (map (fn [[k v]] (dom/li nil (str k ":" v)))
              (:prog-peers app))))

(defn on-event-focus [ts label args]
  (reset! run-world-hover args)
  (.add gdom/classes (gdom/getElement "world-container") "hover"))

(defn on-event-blur []
  (reset! run-world-hover nil)
  (.remove gdom/classes (gdom/getElement "world-container") "hover"))

(defn render-events [app owner]
  (apply dom/ul nil
         (map (fn [[ts label args]]
                (dom/li #js {:onMouseEnter #(on-event-focus ts label args)
                             :onMouseLeave #(on-event-blur)}
                        (str ts label args)))
              (:prog-events app))))

(defn render-clients [app owner]
  (apply dom/select #js {:id "client"}
