In order to combat that worry, I'm trying to focus on gratitude that I have had a career where I got paid for doing fun things (programming), rather than worrying about what if my career stops being fun. Many people never get that chance, after all, and live their entire lives working menial jobs just to put food on the table. I'm also trying to make my career less important to my own mental happiness by focusing on other things that are good and will not go away even if my career stops being fun (for me, that means my marriage and my faith).
It's not easy to do, at all. And it also doesn't help the worry that I might even lose my job entirely because the industry abandons sense and fires people in favor of LLMs. But it does help a little, and I'm hoping that with practice the mental discipline will get easier and I can let go of the anxiety some.