Add CLI instance proxy and route UI traffic through it

This commit is contained in:
Shantur Rathore
2025-11-19 02:03:15 +00:00
parent defa637dbc
commit 146eae5220
15 changed files with 592 additions and 84 deletions

View File

@@ -104,6 +104,12 @@ CodeNomad is a cross-platform desktop application built with Electron that provi
- Event type routing
- Reconnection logic
**CLI Proxy Paths:**
- The CLI server terminates all HTTP/SSE traffic and forwards it to the correct OpenCode instance.
- Each `WorkspaceDescriptor` exposes `proxyPath` (e.g., `/workspaces/<id>/instance`), which acts as the base URL for both REST and SSE calls.
- The renderer never touches the random per-instance port directly; it only talks to `window.location.origin + proxyPath` so a single CLI port can front every session.
## Data Flow
### Instance Creation Flow
@@ -144,6 +150,7 @@ instances: Map<instanceId, {
folder: string
port: number
pid: number
proxyPath: string // `/workspaces/:id/instance`
status: 'starting' | 'ready' | 'error' | 'stopped'
client: OpenCodeClient
eventSource: EventSource