Part of that is meticulous notes on what I’m currently doing and planning to do, lots of “todo” comments and comments in general, etc.
The other part is just learning to live with interruptions through experience.
Some people might not have the same success, your mileage may vary.