ui: Cherry pick permalink fix to stable (#7252)

Cherry pick https://github.com/google/perfetto/pull/7248 onto stable