Learn not to have some flow state that takes a half hour to get into.
That flow state is bullshit. You get so absorbed into the work that you do stupid things a mile a minute. Sometimes it takes an interruption to get you to see it. Let's see, where was I. Ah I was doing that, for such and such reason, and ... wait what? That's stupid. Let's scrap 75% of it and do it in this better way ...
If it takes a long time to get into flow states, it could indicate that you have some problem in the project. To be able to do anything, you have to boostrap various bits of information into your head, and keep juggling it. Then have it all vaporize upon interruption. Maybe there are better ways. Some tooling or documentation strategy, or automation of this or that. Try to have it so that someone with anterograde amnesia could use your environment to get stuff done.