-kd                     = require 'kd'
-React                  = require 'kd-react'
-ActivityFlux           = require 'activity/flux'
-EnvironmentFlux        = require 'app/flux/environment'
-KDReactorMixin         = require 'app/flux/base/reactormixin'
-SidebarChannelsSection = require 'app/components/sidebarchannelssection'
-SidebarMessagesSection = require 'app/components/sidebarmessagessection'
-SidebarStackSection    = require 'app/components/sidebarstacksection'
-Scroller               = require 'app/components/scroller'
+kd                            = require 'kd'
+React                         = require 'kd-react'
+ActivityFlux                  = require 'activity/flux'
+EnvironmentFlux               = require 'app/flux/environment'
+KDReactorMixin                = require 'app/flux/base/reactormixin'
+SidebarChannelsSection        = require 'app/components/sidebarchannelssection'
+SidebarMessagesSection        = require 'app/components/sidebarmessagessection'
+SidebarStackSection           = require 'app/components/sidebarstacksection'
+SidebarSharedMachinesSection  = require 'app/components/sidebarsharedmachinessection'
+Scroller                      = require 'app/components/scroller'
 
 module.exports = class Sidebar extends React.Component
 
   PREVIEW_COUNT = 10
 
   { getters, actions } = ActivityFlux
+
+
+  constructor: ->
+
+   super
+
+   @state =
+     renderedStacksCount : 0
+
 
   getDataBindings: ->
     return {

  render: ->
    <Scroller className={kd.utils.curry 'activity-sidebar', @props.className}>
      {@renderStacks()}
      {@renderSharedVMs()}
      {@renderChannels()}
      {@renderMessages()}
    </Scroller>

          selectedId={@state.selectedThreadId}
          stack={stack}
          machines={stack.get 'machines'}
          onStackRendered={@bound 'onStackRendered'}
          />

    return stackSections


  renderSharedMachines: ->

    machines =
      shared        : @state.sharedMachines
      collaboration : @state.collaborationMachines

    return null  if machines.shared.size is 0 and machines.collaboration.size is 0

    <SidebarSharedMachinesSection
      sectionTitle='Shared VMs'
      machines={machines}
      renderedStacksCount={@state.renderedStacksCount}
      />


