                       (reset! retained-input (.getText input-widget)))
                     (doto input-widget
                       (.setText (@history (dec (- (count @history) @current-step))))
-                      cursor-at-end))))]
+                      cursor-at-end))))
+        session (repl/client-session repl-client)
+        responses-promise (promise)]
     (.setHistoryActionFn repl-view history-action-fn)
-    (comp (partial eval-expression repl-view log-panel (repl/client-session repl-client))
+    (future (echo-responses repl-view log-panel responses-promise))
+    (comp
+      #(when-not (realized? responses-promise)
+         (deliver responses-promise %))
+      (partial eval-expression repl-view log-panel session)
       (fn [expr add-to-log?]
         (reset! retained-input nil)
         (reset! current-step -1)

      (str (when (> (count s) 30) "..."))
      (.replaceAll "\\n|\\r" " "))))

(defn eval-expression
  [repl-view log-component client expr]
  (let [responses (repl/message client (if (map? expr)
                                         expr
                                         {:op :eval :code expr :ns (.getCurrentNamespace repl-view)}))]
    (future (try
              (doseq [{:keys [out err value ns status] :as resp} responses]
                (ui-sync
                  (when ns (.setCurrentNamespace repl-view ns))
                  (doseq [[k v] (dissoc resp :id :ns :status :session)]
                    (if (log-styles k)
                      (log log-component v k)
                      (CCWPlugin/log (str "Cannot handle REPL response: " k (pr-str resp)))))
                  ;(CCWPlugin/log (str resp))
                  (doseq [status status]
                    (case status
                      "interrupted" (log log-component (eval-failure-msg status expr) :err)
                      "need-input" (ui-sync (.getStdIn repl-view))
                      nil))))
              (catch Throwable t
                (CCWPlugin/logError (eval-failure-msg nil expr) t)
                (log log-component (eval-failure-msg nil expr) :err))))))

(defn configure-repl-view
  [repl-view log-panel repl-client]

(ns ccw.repl.view-helpers
  (:require [clojure.tools.nrepl :as repl]
    [ccw.repl.cmdhistory :as history])
  (:use [clojure.core.incubator :only (-?>)]
        [clojure.tools.nrepl.misc :only (uuid)])
  (:import ccw.CCWPlugin
    org.eclipse.ui.PlatformUI
    org.eclipse.swt.SWT
