On Mac's iTerm app, when I ssh into remote machines and the connection is terminated by either power loss or connection failure, some of the time, readline in the terminal fails. At least, I think it's readline - the main symptom is that history-search-backward and history-search-forward no longer function. The part I can't understand is that it is broken on both the local and remote machines even after establishing a new connection. The other strange part is that the failure only happens some of the time, not every time I get disconnected.
I think this could be a problem with ssh, mac's terminal, or just the iTerm app, but I have no idea where to start looking. Any ideas would be appreciated, but with such a convoluted problem I can't really expect any solutions.