Being a programmer is a lot like being a tradesperson. A tradesperson has a lot of flexibility in what they can do. They can work for a company, work freelance, or start their own business.
Programming gives you the same flexibility, the most important bit being that you can do it for yourself.
AI is going to struggle with larger complex tasks for a long time coming. While you can go to it and say 'write me a script to convert a png to a jpg' you can't go to it and say 'Write me a suite of tools to support business X' or 'make me a fun and creative game' A good programmer isn't going to be out of work for a long time.
Most of the work software developers do is comprehending the problem, formulating a solution that addresses the problem, and doing it in a maintainable, performant, and security conscious manner.
I think AI can write a killer isEven() method, I think it's shit at everything I listed... it's extremely shit at being security conscious, any dev can tell you that it's easier to write code and confirm it's following best security practices then it is to review someone's code and confirm it's following best security practices... I think AI actively makes it harder to have confidence in security.
The first real part of my job I think AI will help with is performance tuning. We're not there yet but I think we're not unimaginably far from being able to give an AI a working but slow function and have a computer spin up a million randomized test inputs and outputs... then start scrambling the algorithm in a plethora of ways and testing the performance while confirming that the test cases pass.
Then again, you'll need to confirm the algorithm is still secure - but I think the realm of performance is the first place we'd see a tool that I'd demand a license for.
All the AI does is match the request to solutions it was trained in.
It just stackoverflow in your ide. It has a little more flexibility in answering and isn't as corrupted by SEO result when googling the equivalent answer. Its not informed and thinking.
The optimisation problems you are talking about is the process that is used to make AI models in the first place. I think you want an AI to configure optimisation routines for you rather than build the test cases and variables yourself. Or you want some system that implement all the individual components better, but an AI that can optimise the entire thing isn't coming about soon. It would need to trained on very similar software. In which case you should just use that better software.
I want AGI to be a thing. I see little evidence that OpenAI et al are going that way. Pretty sure it's mostly hype to distract from wholesale theft of IP for profit.