"Without junior engineers how will there be senior software engineers in the future?" If I were an AI fan, my answer would be this: By that time, AI will have improved enough that it can replace senior software engineers as well.
Disclaimer: I am not a fan of AI, and I am currently writing software without any help from AI, as I prefer.
Right, that's a possibility. When that happens we won't need senior software engineers. We won't need a "thriving mathematical community" either.
Would we need doctors, accountants or analysts? Probably not. At some point farming will be fully automated too, and so will grocery distribution and food preparation. At that point we will have arrived in the post-scarcity world. This is the promise of AI.
The problem is that the post-scarcity world will arrive gradually, not suddenly. Some jobs will be automated sooner than others. The ones that are not yet automated will expect payment for services. People who just lost jobs to automation won't have income to pay for those not-yet-automated services. But that's only until all jobs are automated.
There will be tremendous social upheaval and unrest during the transition to post-scarcity world.
I'll add that as a retired person myself, I have found things to do with my time that seem (reasonably) useful. At the moment that includes writing a computer program, substitute teaching at the high school level, and occasionally writing a sci-fi novel. How much of that the average person could or would do if they had no employment in the post-scarcity world, I don't know---and for that matter, most (maybe all) of these would be replaced by AI. The point: what are people going to do to make their lives seem worthwhile? Which will add to the social upheaval and unrest you rightly predict.
Disclaimer: I am not a fan of AI, and I am currently writing software without any help from AI, as I prefer.