 
     KD.mixpanel "Teamwork tab browser, click"
 
+  switchToPane: (paneIndexKey) ->
+    for pane in @tabView.panes
+      if pane.getOptions().indexKey is paneIndexKey
+        debugger
+
   createChat: ->
     pane = new KDTabPaneView title: "Chat"
     chat = new ChatPane

    super options, data

    @createElements()
    @keysRef    = @workspaceRef.child "keys"
    @indexRef   = @workspaceRef.child "index"
    @requestRef = @workspaceRef.child "request"
    @stateRef   = @workspaceRef.child "state"

    @listenChildRemovedOnKeysRef()
    @listenRequestRef()

        indexKey  : indexKey

    @registerPaneRemoveListener_ pane
    @openIndexes[FSHelper.plainPath file.path] = indexKey

    KD.mixpanel "Teamwork tab editor, click"

  handlePaneHandleClicked: (paneOptions) ->
    {title, indexKey} = paneOptions
    @workspace.addToHistory
      message    : "$0 switched to #{title}"
      by         : KD.nick()
      data       :
        title    : title
        indexKey : indexKey

    @indexRef.set { indexKey, by: KD.nick() }

  openFile: (file, content) ->
    plainPath    = FSHelper.plainPath file.path
    paneIndexKey = @openIndexes[plainPath]

    if paneIndexKey
      for pane in @tabView.panes
        paneOptions = pane.getOptions()
        if paneOptions.indexKey is paneIndexKey
          @handlePaneHandleClicked paneOptions
    else
      @createEditor file, content

  createTerminal: (sessionKey, indexKey) ->
    indexKey = indexKey or @createSessionKey()
