while I can't yet provide any news about running key sequences and command tasks in ad hoc connections you might want to think about switching to iTerm2 triggers instead.
These provide more control and also run in ad-hoc scenarios. See here for more details: https://www.iterm2.com/documentation-triggers.html
I would like to run sudo su - or other commands after login also on ad-hoc connections....
Thanks and regards,