Parse a sturdyref URI, stand up a websocket netlayer, enliven the
chatroom, join, and subscribe. Errors are caught: the failure is
recorded in the log panel and the phase falls back to menu with
a connect failed status — the returned promise itself never
rejects.
Politely tear down the active session (unsubscribe → leave →
client.shutdown()), reset the room slice of state, and return
to the menu phase. Safe to call when no session is active.
Send a message into the joined room. Errors are caught and surfaced in the log panel.
Drive the high-level phase transition. The TUI uses this to move
between menu, name-input, uri-input, host-name-input, and
recent-list.
Synchronous polite teardown for process exit: unsubscribe
(eventual), leave (eventual), client.shutdown() (sync). Safe to
call multiple times. The same function is wired into
shutdownHandle.run for signal-handler use.
Push an
infosystem event onto the chat events stream. Used by the host-a-new-chat flow to render the freshly minted sturdyref URI inline with the chat (so the user sees what landed on their clipboard, even with the diagnostic log panel hidden).