 
         dataProvider.ensureDefaultWorkspace ->
 
-          if machine
-            username = machine.getOwner()
-            data = machineUId: machine.uid, workspaceSlug: params.workspaceSlug
+          dataProvider.fetchWorkspaceByMachineUId data, (workspace) =>
+            if workspace
+              loadIDE { machine, workspace, username }
+            else
+              routeToMachineWorkspace machine
 
             dataProvider.fetchWorkspaceByMachineUId data, (workspace) =>
               if workspace then loadIDE { machine, workspace, username }


  return no if not machine or not workspace

  kd.singletons.mainView.activitySidebar.selectWorkspace data
  storage = kd.singletons.localStorageController.storage 'IDE'

  workspaceData    =

actions         = require 'app/flux/environment/actions'
globals         = require 'globals'
Machine         = require 'app/providers/machine'
isKoding        = require 'app/util/isKoding'
lazyrouter      = require 'app/lazyrouter'
dataProvider    = require 'app/userenvironmentdataprovider'
registerRoutes  = require 'app/util/registerRoutes'
