fix(portal): harden scoped history and cleanup