My daily driver is Android + Samsung DeX, and I've tried doing this a couple different ways. In the end, the only thing that didn't make me pull me hair out in the long run was proper VSCode (arm64 build) inside termux/Ubuntu (installed via Andronix). Crucially, the only VNC client that works well with this (and I've tried all the paid ones too) is AVNC from FDroid. I had too many issues with code-server and vscodium…
Can you elaborate on how you use DeX specifically? I recently bought my first Samsung - and was a bit curious about it, surprised to hear that it is a powerful tool.
My termux session runs permanently in the background out of laziness (though this does noticeably shorten your battery life, but it's been mostly manageable) so all I need to do is start AVNC.
There are a lot of little configurations and quality of life things that I tweaked over the past year or so of doing this; happy to write all those up somewhere if you're interested.