This is a problem that I was never able to solve and I always try to switch on another editor when I am coding on my remote machine.
However, I think that I solution should be somewhere for this kind of problem and that I am the only one that is finding this problem.
MY doom configuration with emacs 29.1 on my host machine
but the same configuration on the same file in a ssh session shows the following error
What did you expect to happen?
I think the two configurations should be shown the same. I also try to use
export TERM='xterm-256color' or
export TERM='xterm' but this do not work for me.
I was also thinking of using TRAMP but this is not working very well for me.