         store.syncdb = syncdb
         @syncdb      = syncdb
         @_client     = client
-        @_is_project = client.is_project()
+        @_is_manager = client.is_project()  # the project client is designated to manage execution/conflict, etc.
         @_project_id = project_id
         @_path       = path
         @_directory  = misc.path_split(path)?.head
 
-        #dbg = @_client.dbg("JupyterActions._init")
+        #dbg = @dbg("JupyterActions._init")
 
         f = () =>
             @setState(has_unsaved_changes : @syncdb?.has_unsaved_changes())

                @setState(obj)
        else
            # change or add cell
            current = cells.get(id)
            if record.equals(current)
                return # nothing to do
            obj = {cells: cells.set(id, record)}
            if not current? or current.get('pos') != record.get('pos')
                cell_list_needs_recompute = true
            @setState(obj)
            if @_is_project and record.get('state') == 'start'
                @project_run_cell(id)
        return cell_list_needs_recompute

    _syncdb_change: (changes) =>
        #console.log 'changes', changes, changes?.toJS()
        #@_client.dbg("_syncdb_change")(JSON.stringify(changes?.toJS()))
        @set_has_unsaved_changes()
        cell_list_needs_recompute = false
        changes?.forEach (key) =>

        console.warn 'not implemented'
        return

    ###
    MANAGE:

    Code that manages execution and conflict resolution/sanity.
    This must run in exactly ONE client.   For now, that client
    will be the project itself.
    ###

    # Called when the manager first starts up after the store is initialized.
    # Here we ensure everything is in a consistent state so that we can react
    # to changes later.
    initialize_manager: =>
        dbg = @dbg("initialize_manager")
        dbg("cells at manage_init = #{JSON.stringify(@store.get('cells')?.toJS())}")


    # _manage_cell_change is called after a cell change has been
    # incorporated into the store by _syncdb_cell_change.
    # It should do things like ensure any cell with a compute request
    # gets computed, that all positions are unique, that there is a
    # cell, etc.  Only one client will run this code.
    manage_on_cell_change: (id, new_cell, old_cell) =>
        if not new_cell?
            # delete cell -- if it was running, stop it.
            # TODO
            return
        if new_cell.get('state') == 'start'
            @manager_run_cell(id)

    # Runs only on the backend
    manager_run_cell: (id) =>
        dbg = @dbg("manager_run_cell")
        dbg()
        cell = @store.get('cells').get(id)

        try
            out = "#{eval(cell.get('input'))}"
        catch e
            out = "#{e}"
        @_set
            type  : 'cell'
            id    : id
            state : 'done'
            output : [out]
