Use an advanced theme to override the sidepanel(...) function. In your version, check if $this->content['navigation']['cat'] is empty. If so it means that a category list hasn't been passed through to the theme, and you need to create one. In that case you want to set it up as follows:
Then your overriding function should call the default sidepanel(...) one as usual.