     return null
 
 
-  reloadIDE: (machineSlug) ->
-
-    route   = '/IDE'
-    if machineSlug
-      route = "/IDE/#{machineSlug}"
-
-    kd.singletons.appManager.quitByName 'IDE', ->
-      kd.singletons.router.handleRoute route
+  reloadIDE: (machine) ->
+
+    route = '/IDE'
+    { appManager, router } = kd.singletons
+
+    if machine
+
+      route = "/IDE/#{machine.slug}"
+      ideApp = appManager.getInstance 'IDE', 'mountedMachineUId', machine.uid
+      ideApp?.quit()
+
+      if router.currentPath is route
+        return IDERoutes.loadIDE { machine, username: nick() }
+
+    router.handleRoute route
 
 
   makeTeamDefault: (stackTemplate, revive) ->

SidebarFlux          = require 'app/flux/sidebar'
whoami               = require 'app/util/whoami'
ComputeStorage       = require './computestorage'

TestMachineMiddleware = require './middlewares/testmachine'



    if change.method is 'apply'
      stack = @findStackFromStackId change.payload.stackId
      @reloadIDE stack.machines.first

    console.log '[Kloud:API]', change
