I tend to get a feel for where and if it is safe to retrofit. When refueling, you should see where they area heading once the order is given.
In my latest AAR I had my worst resource crunch ever, somewhat early on. When it started to ease a bit (I had some steel), I retrofitted my large destroyer fleet 5 ships at a time to avoid the entire 1st fleet being stuck.
How to judge if the retrofit is safe? Have there been resource issues lately, or did you recently lose your mines? Is the spaceport medium+ (smaller fleets can use a small one too). Has the spaceport been there a while, and without a lot of ship building/retrofitting? And are there other major colonies/spaceports somewhat nearby?
I usually spread my fleets around a bit, and keep a couple at home when at war. If I got 3 major fleets on my south flank, it could be a bad idea to send them all to the southern medium spaceport to retrofit, even if they go one at a time. In those cases I rotate fleets. Retrofit one at the "capital" and send it south. Then send a southern fleet to the capital area to retrofit, with the plan on having it stay in that general area.
Yes Bing, what you wrote here seems born out by my experiences as I play the game more. I know for example that sometimes the AI will send fleets to refuel/retrofit at places where resources are low. As you said though, you have to get a 'feel' for these things that comes from experience.