This might be a dumb question: are there shells that have a HTML-based front and passes commands into the background? Seems like something like that would be far more flexible than this – which feels like a Jenga tower of hacks.
TermKit[1] was built in this way a few years ago. It was novel at the time and the demo[2] seemed promising, but looks like it hasn't been updated in ~2 years now.