Hi, I would extract as much as possible of the logic and put it into a (global) scope or an entity scope, passing JSRecords as parameters.
{JSRecord<db:/yourdbname/yourtablenamehere>}
Then rebuild the functionality of the UI using these functions. The code in the UI will become much shorter, reusing the elements needed by the batch processor.
This way you can debug and check the logic in the Developer, which is much much easier than trying to work out what is happening in a headless client.
Hope this helps,