I created the atom-domterm terminal emulator package, which delegates all the complications of terminal emulation and session (pty) management to a separate 'domterm` backend (server). The basic functionality of atom-domterm works well, but are problems with session/lifetime management.
Atom seems to call “serialize” at times when I wouldn’t expect it to - for example when resizing by dragging a splitter. I’m having difficulties understanding when the serialized state is used, and when it is discarded. Note that for a terminal emulator there is external state that must be managed: The process id and the pty. (You can’t depend on garbage collecting the serialized state.) In atom-domterm this is managed by the domterm backend - which does know how to request and restore serialized sessions. However, it is essential that the backend know when a session is serialized and detached - vs when the session exits. The latter can happen because the user clicks on a close button - or because the shell process exits.
Bottom line: I (and presumably other Atom terminal emulators) support 3 operations: serialize and detach; deserialize and attach; and exit session. I haven’t figured out the correct way to map Atom events to these 3 operations. Part of the problem may be that I probably haven’t hooked up deserialization properly - even though dragging domterm panes does (sometime) work.