WIP: panel support4

Supercedes PR #321.  Rebased against master, various fixes.

Gets the sidebar code working in panels, a la:

https://trello.com/c/lX521lFu/304-2-as-a-user-i-can-use-talkilla-in-a-panel-rather-than-a-sidebar

A few more things before this is ready for review; see the Trello card for details.