As the title suggest to keep Root and TWRP with OTA update
Download oxygen updater
Download full stable build on your OnePlus phone version
Once downloaded go to your setting and system update
Select local upgrade, wait til the update finishes but DO NOT RESTART
Once the update reaches to 100% go to Magisk
Magisk Module install TWRP A/B Retention script again DO NOT REBOOT
Go to Magisk 1st page select Magisk install
Select install to inactive slot (after ota)
Watch magisk load and NOW YOU CAN REBOOT