OpenCode
Render an OpenCode session with its questions, permissions, and tool results.
Load an OpenCode session
Install Ghost UI and its view dependencies, then add the OpenCode SDK.
Use the SDK’s /v2 client with your authenticated OpenCode server. Keep the connection, workspace, and session in your app.
This first integration is request/response: load the session, render it, then replace the records after sending. For streaming, subscribe through native client.event.subscribe in the application session owner and update its cache by native session/message/part IDs. Project that cache; do not start a second Ghost event reducer or refetch every child session for each token.
Native controls
Answer questions through OpenCode’s question API and use its permission API for permission requests. Your app decides whether to offer “always.” Keep fork, revert, and unrevert on the native session.
Extension and troubleshooting
The projection preserves tool call IDs, errors and native message metadata. Patch, subtask and future parts stay explicit unknown content until you provide a deliberate renderer. Read child sessions only when your product needs them; normalization performs no network reads.
If events from another workspace appear, fix native subscription/cache scope before normalizing. If the UI never streams, confirm you implemented the event owner rather than only the first request/response recipe. See OpenCode SDK documentation for event types and the external-store bridge for connecting an existing cache.