If you haven’t already, I’d recommend checking out the book deep work by cal newport. It talks about stuff like being productive when you have a job that involves a lot of complicated problem solving.
Anyways there’s a part that calls it something like “attention residue” and how there was a study done and how it is hard to switch to a new task after you’ve been working on one for a long period of time. There’s some other interesting stuff about scheduling your work, avoiding multitasking, and how even the most highly educated people are only able to focus intensely for about 4 hours a day and then the rest of the time they are working less efficiently and that the amount that you are able to focus in a day is limited.
I haven’t really meditated that much but I’ve heard the whole cycle of focusing on breathing, getting distracted, and then refocusing is supposed to help with things like focus, willpower, and decision making among other things. For refocusing napping might be the best option if possible, otherwise if possible, I would try to set aside time to work with very few breaks and then take a break at the end of the day. I also find that to be productive I have to start working on things as soon as I wake up before I do anything else so that I will be able to stay focused throughout the day.