ChatGPT for example is nothing but a more advanced and opinionated search engine, it is a tool for you to use or discard. ChatGPT is not the threat in any case, Copilot was a much bigger threat but we have all learned to live with it now. It is true that soon some AI can become advanced enough to replace developers, but ask yourself this, why? It isn't because the bots can do our job that much better than us, it is because our fields are stagnating and the bots can be trained, but their models are trained on outdated datasets before they reach public availability.
If you want to keep your job, stay ahead of the game. Use the tools available to you. And stop worrying about all the 'what-ifs'