It is terrible to hold back progress just to provide "make-work" jobs protected by unions. Should we still employ elevator operators?
In a scenario where my job is obsolete, a union would simply delay the inevitable. It might keep the company from replacing me with an AI, but the company would therefore eventually fail to competitors who could. In the meantime, the union would make people miserable and delay progress.
For what it's worth, I completely agree that developer jobs are on their way towards automation. Instead of trying to fight that trend with unionization, I focus on being part of it (building automation tools) and building a capital base.