I do not think this will ever happen, we do not have true AI (or AGI), current models are just parroting the training set code. they do not really analyze or think about code over human capabilities.
There are also huge ethical and legal issues about AI systems for code, since they were trained on large datasets of open source software, with different licenses, and again models do not output licenses for their code, so you cannot use it commercially.
Not even humans know how to make software properly, there are huge issues in terms of scalability, proper software development practices, and integration with other systems. Current AI models do not know anything about this.
So nobody can tell you how many years left, because it is an event that nobody knows if will ever happen, same for autonomous driving, it is always "two years away".