I struggle with this too. I find making detailed notes helps a lot. Just writing them helps me understand better. Then later they help me get back to where I last left off. The fog part I‘m still working on. One trick is to take mini-breaks to think/meditate on some un-related mechanical project. After a minute or two my brain (most times) is ready to get back to coding.
Seconding this comment. https://healthchecks.io/ has a free tier for one test.
Oh Danielle…. You seem to be obsessed with the sex life of others. Is everything OK at home?