I forget who wrote this, but there was a famous CS-related paper from a while back that made the point that when we automate the easy stuff, the only remaining problems are the really hard ones that require human expertise and domain knowledge to solve. So there will always need to be human software engineers.
AI being able to code is going to be like what happened when construction workers started using power tools: now that one man can saw boards as fast as 5 others with handsaws, wouldn't we see a lot less demand for carpenters? What happened is that per-worker productivity went up because of the new tools and the construction materials and techniques they use were adapted to take advantage of that, there was still plenty of work, and we can build better things faster than before.
In software, imagine how much more effective engineers can be if the grunt work could be more automated. People loved autocomplete and smart IDE features and graphical debuggers because they made coding more productive. A lot of those things already do write some code. AI provides a much better version of that.
People whose only contribution to software is the grunt work of writing simple code might need to worry, but there is a lot more to working as a software engineer than grinding code. These AIs are also repeaters of existing solutions -- maybe they can solve simple problems that have pre-existing solutions in their training corpus, but an AI is not going to be able to create the next Redis or Kubernetes or AWS simply by recombining existing text.
Regarding layoffs:
Even after all the layoffs most companies still have more employees than they did in 2020. Many of the people being laid off today joined since then. They will get other jobs, maybe not in a few weeks like what used to be possible, but still. This is not like 2001 when entire companies were going out of business and laying off 100% of their employees.
A lot of the the American tech industry developed when interest rates were higher than they are now. What we had in the past decade was not normal, and in some ways it was pretty crazy -- investors didn't care if companies were sustainably operated, and now they do, and that's good for the long-term health of the industry.
Tech is not immune from the business cycle, because nothing really is, but this really is not as bad as previous downturns. Even if it gets worse before it gets better, the tech industry is fundamentally strong and will handle it.