Reading opencode source saw a few interesting designs:
1. Hono server framework, exposing HTTP and multi-client communication.
For CLI/TUI clients, no real HTTP needed—direct function call to hono service instance app.fetch. Same process front and back
2. Global event bus.
Supports multi-instance state sync—e.g. multiple browser tabs same session; any session window state change syncs to other instances. Including TUI!
Unlike most ChatApp designs, each instance has only one global/event interface receiving SSE streams.
User input new messages via POST, starting agent loop.
New messages go into GlobalBus; frontend only needs the global/event connection from page init to get the latest stream!
So one session has only one SSE connection! Not one per user message/runid!
