While it is not a simple Undo button, there are several ways to recover a deleted activity.
First: if you have not committed the pipeline change yet, you can close the tab and discard changes. This is probably the easiest way, but you will also lose any other changes you may have made, so just be aware of that.
Second: if you are working Git branches (and hopefully you are), you can open the main branch in another browser window and copy and paste the activity in the UI from main back into your working branch. Sometimes it is a little wonky, so YMMV.
Third: many people aren't aware, but you can edit the pipeline code directly:

This will bring up a JSON code editor:

If you have access to the Git repo, you can copy and paste the missing JSON from the file in Git (again, most likely in main) into this UI and click "OK" to save the changes. This will bring the activity back into your pipeline.
BE WARNED: this approach can be very powerful, but messing around in this JSON can have unintended consequences, so be very sure about what you are doing if you go this route.