   ptk/UpdateEvent
   (update [_ state]
     (let [page-id (get-in state [:workspace :page])
-          undo (get-in state [:undo page-id])
-          stack (:stack undo)
-          selected (:selected undo 0)]
+          undo-state (get-in state [:undo page-id])
+          stack (:stack undo-state)
+          selected (:selected undo-state 0)]
       (if (>= selected (dec (count stack)))
         state
         (let [pointer (inc selected)
               page (get-in state [:pages page-id])
-              data (nth stack pointer)
-              packed (assoc page :data data)]
+              undo (nth stack pointer)
+              data (:data undo)
+              metadata (:metadata undo)
+              packed (assoc page :data data :metadata metadata)]
 
           ;; (println "Undo: pointer=" pointer)
           ;; (println "Undo: packed=")

                       (rx/take 1))]
      (->> stream
           (rx/take-until stopper)
           (rx/filter #(satisfies? udp/IPageUpdate %))
           (rx/filter #(not (undo? %)))
           (rx/filter #(not (redo? %)))
           (rx/debounce 500)

(defrecord SaveUndoEntry [id]
  ptk/UpdateEvent
  (update [_ state]
    (let [page (udp/pack-page state id)
          undo {:data (:data page)
                :metadata (:metadata page)}]
      (-> state
          (update-in [:undo id :stack] #(cons undo %))
          (assoc-in [:undo id :selected] 0)))))


(defn save-undo-entry
  [id]
