The HI virus is very slow (not called "Lentivirus" for nothing) and invests itself in the very stemcells of the cells that would be fighting it. This means it can hide from the immune system, and even the antiviral drugs can only push it back. But by the same token, if it is pushed back into the deepest refuge, it can't really "flood" back into the rest of the body, it has to do so at a a trickle.
If there is a viable vaccine around, even if the virus manages to hide from total extinction in a host at first, it will get squashed whenever it tries to come back into the "light" of the immune system.
At least I hope it will work that way...
So... if HIV has already damaged your immune system, can it take advantage of the vaccine?
Perhaps figuring out that is what the tests are for.
There have even be experimental treatments where HIV infected patients who also got Leukemia got treated with radiation, and then a stemcell donation from someone with such an immunity. And they are indeed cured (for practical purposes, there are some details...). Unfortunately, those donors are rare and the radiation therapy etc is probably worse than the chronic antiviral therapy, which is why this is not a more common treatment for HIV.
Of course, inducing these particular antibodies has been the goal of various immunization efforts. Unfortunately this proved more challenging than it might seem.
It takes the virus years to reach the viral loads necessary to damage the immune system to a noticeable degree. Sure, HIV has some tricks before that point, but patients are generally not immunocompromised until AIDS enters the picture.