 
   ideApps       = kd.singletons.appManager.appControllers.IDE
   machineUId    = machine.uid
-  workspaceId   = workspace.getId()
-  workspaceSlug = workspace.slug
+  workspaceId   = workspace?.getId()
+  workspaceSlug = workspace?.slug
 
   for instance in ideApps.instances
     isSameMachine   = instance.mountedMachineUId is machineUId
-    isSameWorkspace = instance.workspaceData?.getId() is workspaceId
+    isSameWorkspace = workspace and instance.workspaceData?.getId() is workspaceId
 
     if isSameMachine
       if isSameWorkspace then ideInstance = instance


  ideInstance = findInstance machine, workspace

  if ideInstance
    appManager.showInstance ideInstance
    selectWorkspaceOnSidebar data # should not be required
  else


loadIDE = (data, done = kd.noop) ->

  { machine, workspace, username, channelId, showInstance = yes } = data

  if showInstance

    selectWorkspaceOnSidebar data
    actions.setSelectedMachineId machine._id

    actions.setSelectedTemplateId if machine.data?.generatedFrom?
    then machine.data.generatedFrom.templateId
    else null

  appManager = kd.getSingleton 'appManager'
  ideApps    = appManager.appControllers.IDE
  machineUId = machine.uid

  callback   = ->
    appManager.open 'IDE', { forceNew: yes, showInstance }, (app) ->
      app.mountedMachineUId   = machineUId
      app.workspaceData       = workspace

