I wish TERM would contain a list of terminal types in decreasing order of specificity, like 'ghostty:xterm-256color', so a system that doesn't know what ghostty is would fall back to xterm-256color, but that ship has sailed long ago.
You can in theory set TERMINFO with the terminfo definition, and you could skip faffing with terminfo files but it isn't passed or accepted by openssh by default.
I've personally given up on using the various "modern" terminals, they end up missing too many features (and then try to claim xterm compatibility), and especially if you use devices outside the standard linux systems (e.g. old/embedded hardware, switches), they have too many rendering issues.
You can in theory set TERMINFO with the terminfo definition, and you could skip faffing with terminfo files but it isn't passed or accepted by openssh by default.
I've personally given up on using the various "modern" terminals, they end up missing too many features (and then try to claim xterm compatibility), and especially if you use devices outside the standard linux systems (e.g. old/embedded hardware, switches), they have too many rendering issues.