improve Shiny document state management for restarts and source renders