I think I know exactly what you're talking about! But luckily, I've found some hacks to keep my focus. The first thing I changed was how I set up my work space. So I designed a corner just with my writing essentials which are my typewriter, a stack of paper, and a small lamp. I keep my phone and any other gadgets in another room entirely when it's my writing period! Second, I find it helps to have a specific goal for the session, whether it's a certain number of pages or a chapter completed. Having that clear target in mind helps me stay on task. And finally, don't be afraid to take a short break if you feel your mind starting to wander. A minute or two away from the machine can be enough to reset and get back into the rhythm.