   (println (format "on-event{id: %s args: %s}" event-id args)))
 
 (defn- app [config view]
-  {:config config
-   :worker (agent nil)
-   :state  (atom {:ui    {:view  view
-                          :model {:input-values {}
-                                  :dirty-marks  0
-                                  :locked?      false
-                                  :rendering?   false}}
-                  :model {}})})
+  (let [blank-config (config/validate nil)
+        invalid-ids  (config/invalid-ids blank-config)]
+    {:config config
+     :worker (agent nil)
+     :state  (atom {:ui    {:view  view
+                            :model {:enabled-actions #{:open-config} 
+                                    :input-values    {}
+                                    :invalid-values  invalid-ids
+                                    :dirty?          false
+                                    :locked?         false
+                                    :rendering?      false}}
+                    :model {:config blank-config}})}))
 
 (defn- event-handler [app]
   (fn [& args]

  ([{app-state :state :as app} update unlock?]
    (swap! app-state update)
    (gui/gui-do
      (let [dirty-marks (start-rendering! app)]
        (when (pos? dirty-marks) 
          (try
            (let [{:keys [view model]} (:ui @app-state)]
              (io! "Do not update the ui in a transaction!"
                (view/render view model)))
            (finally
              (stop-rendering! app dirty-marks unlock?))))))))

(defn- apply-config [app-state config]
  (-> app-state
      (update-in [:ui :model :input-values] merge config)
      mark-dirty))

(defn- open-config [{app-state :state :as app} widget file]

(defn- run-task [{worker :worker :as app} task & args]
  (send-off worker 
            (fn [_ &]
              (try
                (apply task app args)
                nil
                (catch Exception task-failed
                  (.printStackTrace task-failed)
                  nil)))))

(defn- mark-dirty [app-state]
  (assoc-in app-state [:ui :model :dirty?] true))

(defn- start-rendering [app-state]
  (if (-> app-state :ui :model :dirty?)
    (update-in app-state [:ui :model] assoc :rendering? true :dirty? false)
    app-state))

(defn- start-rendering! [{app-state :state}]
  (swap! app-state start-rendering))

(defn- stop-rendering [app-state unlock?]
  (let [app-state (assoc-in app-state [:ui :model :rendering?] false)]
    (if unlock?
      (assoc-in app-state [:ui :model :locked?] false) 
      app-state)))

(defn- stop-rendering! [{app-state :state} unlock?]
  (swap! app-state stop-rendering unlock?)
  (when unlock?
    (view/unlock (-> @app-state :ui :view))))

