Patch Set 2:

I updated the commit message.
I think the current selection behavior makes sense. If a non repo resource is selected, staging view keeps the last selected repository. This saves CPU and I think it's also ok for the user. Even if there is no project left in the workspace it is ok to display a repository because staging vie w does not depend on the existence of a project.