       @selectedTool = @model
     window.selectedTool = @selectedTool
 
-    @toolInstances = @model.get('views').visible()
     app.tools().on 'add', @addToolArchetype, @
     @model.on 'update:tool', @addToolInstance, @
     @model.get('views').on 'update:tool', @addToolInstance, @

    , 0

  addToolInstance: (instance) ->
    id = "instance-#{instance.get 'box'}"
    l = $("##{id}", @$el)
    if not instance.isVisible()
      # Don't show "hidden" tool instances
      return
    if l.length > 0
      # Already added as a menu item; don't add again.
      return
    if not instance.get 'tool'

    v = new Cu.View.ToolMenuItem model: instance
    el = v.render().el
    $('a', el).addClass('active') if instance is @selectedTool
    if instance is @model
      # This is the dataset's main tool instance! Put it first.
      $('.tools', @$el).prepend el
    else
      $('.tools', @$el).append el
