     return panes
 
 
-  handleChange: (change) ->
-    return  unless @realTimeDoc
-
-    if change.type in [ 'NewPaneCreated', 'PaneRemoved' ]
-      if @amIHost
-        log 'change detected', change.context
-        @writeWorkspaceSnapshot()
+  writeChange: (change) ->
+    {context} = change
+
+    return  if not @realTimeDoc or not context or not @snapshot
+
+    return  if change.origin is KD.nick()
+
+    switch change.type
+
+      when 'NewPaneCreated'
+        @snapshot.set context.paneHash, change
+
+      when 'PaneRemoved'
+        @snapshot.delete context.paneHash

    @generatedPanes[view.hash] = yes

    view.on 'ChangeHappened', (change) =>
      @handleChange change


  forEachSubViewInIDEViews_: (callback = noop, paneType) ->
    if typeof callback is 'string'

    {workspaceData} = this
    @rtm = rtm      = new RealTimeManager

    rtm.auth()

    rtm.on 'ClientAuthenticated', =>
      hostName = if @amIHost then KD.nick() else @collaborationHost
      title    = "#{hostName}.#{machine.slug}.#{workspaceData.slug}"

      rtm.fetchFileByTitle title

      rtm.on 'FileQueryFinished', (file) =>
        {result} = file
        return if result.selfLink.indexOf(title) is -1

        if result.items.length > 0
          @loadCollaborationFile file
        else
          log 'acetz: FILE IS MISSING, HANDLE CREATE FILE...'


  loadCollaborationFile: (file) ->
    firstFile = file.result.items.first

    return unless firstFile

    @rtm.getFile firstFile.id

    @rtm.on 'FileLoaded', (doc) =>
      @realTimeDoc = doc

      @getWorkspaceSnaphot()
      @writeWorkspaceSnapshot()  if not @snapshot and @amIHost

    @rtm.on 'MapValueChanged', (map, v) =>
      @activeTabView.emit 'CollaborationDataUpdated', map.values()


  writeWorkspaceSnapshot: ->
