Thanks for the report! I reproduced the missing returned items on Factorio 2.1.24, including upgrading red belts to blue belts and fast inserters to bulk inserters while seated in a train in remote/map view.
I found a remaining issue in the 5.9.10 development build: passing both the player and the physical character to fast-replace still routes the operation through the remote player controller. A corrected local build now passes only the physical character for the replacement and restores last_user separately.
The corrected build passed nine automated tests in the game engine, checking that each replacement consumes exactly one new item and returns exactly one old item. These cover on-foot use, cars, spidertrons, trains, remote view, materials taken from a car trunk or cargo wagon, and remote view beyond the AFK timeout. The train tests used a stationary train; your moving-train/save setup still needs confirmation.
This corrected build has not been published yet, so I am leaving the thread open. Could you share your Factorio and Nanobots3 versions, and whether the replacement materials were in your character inventory or the train? Thanks again for helping track this down!