The sunroof on these trucks has 2 functions (tilt and open), and 2 buttons (forward and back). From closed if you press "forward" it tilts up, pressing "back" from the tilt up position closes the sunroof. From closed if you press "back", the sunroof slides open, from there pressing "forward" closes the sunroof.
If power has been disconnected, you may need to reinitialize the switch, which just involves manually moving the sunroof to fully open, and then closed positions by holding the switch, same as you have to do with the power windows after disconnecting the battery.