Can you replicate the brake disconnection with the 5th wheel parked? This may be as simple as an intermittent connection.
FWIW, I was pulling hairs a few years back for a similar problem and found that a rock had probably hit the trailer connection wiring bundle under the truck. I had to separate the wire loom to find that a wire had parted inside it's jacket. There was enough stranded wire to make a connection most of the time but truck movement caused a disconnection of the brakes, intermittently.
Good luck, hope you find the problem and it is small.