Show a client error if the WebSocket connection closes

Instead of automatically reconnecting when the WebSocket connection dies for whatever reason, we show an error asking that the user refresh.

This PR also DRYs out our existing error handling a bit.
Establishing the connection requires the CSRF token, which is only available once the page has loaded. (CSRF meta tags are included after JS.)