Skip to content

Commit f5a28bf

Browse files
grichaclaude
andcommitted
Add OpenCode integration tasks to TODO.md
- Load existing messages when reopening sessions - Implement OpenCode Server API for real-time SSE streaming Moved from considerations to active tasks. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 07bb33a commit f5a28bf

1 file changed

Lines changed: 32 additions & 9 deletions

File tree

TODO.md

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,38 @@ Two different `WorkspaceState` type definitions exist. Consolidate into single s
102102

103103
---
104104

105+
### OpenCode Integration
106+
107+
#### Load existing messages when reopening OpenCode session
108+
**Files**: `src/chat/opencode-handler.ts`, `web/src/pages/WorkspaceDetail.tsx`
109+
110+
When reopening an existing OpenCode session via `--session <id>`, the web UI shows an empty chat. Previous messages should be loaded and displayed before accepting new input.
111+
112+
**Fix**:
113+
1. When session ID is provided, first fetch session history from OpenCode storage
114+
2. Parse existing messages from session file (check `~/.local/share/opencode/storage/`)
115+
3. Send historical messages to web client before enabling input
116+
4. Use existing session parser logic from `src/sessions/parser.ts` if applicable
117+
118+
#### Implement OpenCode Server API for real-time streaming
119+
**Files**: `src/chat/opencode-handler.ts`, possibly new `src/chat/opencode-server.ts`
120+
121+
Current implementation uses `opencode run --format json` which works but spawns a new process per message. OpenCode has a built-in server (`opencode serve`) with SSE streaming that would provide:
122+
- Persistent sessions across page reloads
123+
- Real-time status updates
124+
- More efficient connection (single long-lived connection vs process-per-message)
125+
126+
**Fix**:
127+
1. Research: Check if `opencode serve` can run in container and expose API
128+
2. Start `opencode serve` on container startup or on-demand
129+
3. Create new handler that connects to OpenCode's HTTP API
130+
4. Use SSE for streaming responses instead of parsing stdout
131+
5. Keep CLI fallback for environments where server can't run
132+
133+
Reference: [docs/research/RESEARCH_AGENT_TERMINAL.md](./docs/research/RESEARCH_AGENT_TERMINAL.md)
134+
135+
---
136+
105137
### Performance
106138

107139
#### Virtualize long chat session rendering
@@ -137,15 +169,6 @@ This makes typecheck failures more visible in CI output.
137169
138170
> Add items here to discuss with project owner before promoting to tasks.
139171
140-
### OpenCode Server API Integration (Optional Enhancement)
141-
142-
Research document: [docs/research/RESEARCH_AGENT_TERMINAL.md](./docs/research/RESEARCH_AGENT_TERMINAL.md)
143-
144-
OpenCode chat is now implemented using CLI passthrough (`opencode run --format json`). This works well and matches the Claude Code integration pattern. Future enhancement could use OpenCode's built-in server API (`opencode serve`) for:
145-
- Persistent sessions across page reloads
146-
- Real-time status updates via SSE
147-
- More granular message streaming
148-
149172
### Design Document Updates (Pending Review)
150173
151174
- **Port range discrepancy**: Design says "starts at 4200" but implementation uses 2200-2400

0 commit comments

Comments
 (0)