       isSameMachine   = instance.mountedMachineUId is machineUId
       isSameWorkspace = instance.workspaceData is workspace
 
-      if isSameMachine and isSameWorkspace
-        ideInstance   = instance
-      else if workspace.slug is 'my-workspace'
-        if instance.workspaceData?.isDefault
-          ideInstance = instance
+      if isSameMachine
+        if isSameWorkspace then ideInstance = instance
+        else if workspace.slug is 'my-workspace'
+          if instance.workspaceData?.isDefault
+            ideInstance = instance
 
     if ideInstance
       appManager.showInstance ideInstance

    mainView.activitySidebar.selectWorkspace data


  getMachineByUId = (uid) ->
    machine = m  for m in KD.userMachines when m.uid is uid
    return machine or null



do ->

  loadWorkspace = (machineLabel, workspaceSlug) ->
    workspace = ws  for ws in KD.userWorkspaces when ws.slug is workspaceSlug
    machine   = getMachineByLabel machineLabel

    if workspace
      loadIDE { machine, workspace }
    else
      if workspaceSlug is 'my-workspace'
        workspace = isDefault: yes, slug: 'my-workspace', machineLabel: machine.label
        loadIDE { machine, workspace }
      else
        routeToLatestWorkspace()


  selectWorkspaceOnSidebar = (data) ->
