I’m all for a whole-bike replacement in most cases. Unless you get some screaming deal on parts & labor, you are paying a fair bit more to make improvements to a frameset.
There are usually good enough improvements in bikes from about 3 years old. This is subject to the particular models in question (relative price points and tech era), but you can often expect to get better results, even if you get the “same” level of gear. Looking at your case of stepping up, you get that base plus a higher level of parts.
If you have the option to keep the 2nd bike for dedicate trainer use and/or a backup/bad weather bike, it makes more sense.
In general, I think upgrades are best kept to wheels in most cases. If you want a new group, you are better to go with the bike route.