The client opens a WebSocket to /ws with an optional sid query parameter
and an optional view flag.
The server resolves an existing session or creates a new one. If sid is
provided but not found, the connection is closed with code 4404.
The server sends 0x10 with the session UUID. The client enters replay
mode (input suppressed, terminal reset).
The server sends 0x13 with the current PTY window size. View-mode clients
use this to match their terminal dimensions to the interactive session
before scrollback replay.
The server replays the scrollback event log as a sequence of 0x00 (output)
and 0x13 (window size) frames — one per stored event. The subscription
is established atomically so no messages are lost between the replay and
live streaming.
The server sends 0x14 (replay end). The client exits replay mode, shows
the cursor, and sends its initial resize.
The main loop begins: output is forwarded as 0x00 frames, input and resize
commands are read from the client. In view mode, client input is ignored.
When an interactive client sends a resize (0x01), the server updates the
PTY and broadcasts 0x13 to all connected clients.
When the shell process exits, the server sends 0x12 and the connection
closes.