Skip to content

Conversation

@louis030195
Copy link
Collaborator

@louis030195 louis030195 commented Jan 30, 2026

Summary

Adds OpenCode as a dedicated feature in the screenpipe app. OpenCode is an agentic coding AI that can be spawned as a sidecar process.

Important: OpenCode is NOT an OpenAI-compatible API, so it cannot be a simple AI preset. Instead, this PR creates a dedicated OpenCode chat interface at /opencode.

Architecture

┌─────────────────┐     invoke()      ┌──────────────────┐
│  OpenCodeChat   │ ──────────────────▶│  Tauri Rust      │
│  (React)        │                    │  (opencode_*)    │
└────────┬────────┘                    └────────┬─────────┘
         │                                      │
         │  @opencode-ai/sdk                    │ spawn sidecar
         │  (HTTP + Basic Auth)                 ▼
         │                            ┌──────────────────┐
         └────────────────────────────▶│  opencode serve  │
                                       │  :random_port    │
                                       └──────────────────┘

Changes

Rust Backend (src-tauri/src/opencode.rs)

  • opencode_start(projectDir) - Spawns OpenCode on a random port with:
    • UUID-based HTTP Basic Auth credentials
    • Health check polling (waits for server to be ready)
    • Proper error messages with install instructions
  • opencode_stop() - Kills the sidecar (supports macOS, Linux, Windows)
  • opencode_info() - Returns current sidecar state
  • opencode_check() - Checks if OpenCode is available
  • cleanup_opencode() - Called on app exit to clean up

Frontend

  • /opencode route - Dedicated OpenCode chat page
  • OpenCodeChat component - Full chat UI with:
    • Project directory selection
    • Session management (create, list, select)
    • Message display with markdown rendering
    • Install instructions if OpenCode not available
  • useOpencode hook - React hook for sidecar management with event listeners

Dependencies

  • Added @opencode-ai/sdk for proper API integration

What's NOT included

  • OpenCode is NOT added to AI presets (incompatible API)
  • No changes to existing chat functionality

Test plan

  • Navigate to /opencode
  • Verify install instructions shown if OpenCode not installed
  • Install OpenCode and refresh
  • Select a project directory
  • Start OpenCode
  • Verify server starts (status shown in header)
  • Create a new session
  • Send a message
  • Verify AI response appears
  • Stop OpenCode
  • Close app and verify no orphaned processes

🤖 Generated with Claude Code

louis030195 and others added 8 commits January 30, 2026 07:50
Adds OpenCode as an AI provider option in the screenpipe app. OpenCode is an
agentic coding AI that can be spawned as a sidecar process, similar to how
Openwork integrates it.

Changes:
- Add opencode.rs with sidecar management (spawn, stop, info, check commands)
- Register OpenCode commands in main.rs
- Add OpencodeState to manage the sidecar process
- Add "opencode" to AIProviderType enum in Rust and TypeScript
- Add OpenCode provider card in AI presets settings
- Add OpenCode option in AI presets selector
- Create use-opencode.tsx React hook for frontend integration
- Add placeholder opencode.png icon

The OpenCode sidecar exposes an HTTP server that the app can communicate with
for AI chat functionality. It supports authentication via random UUID
credentials and dynamic port allocation.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Major rework of OpenCode integration:

- OpenCode is NOT an OpenAI-compatible provider, so it cannot be added
  as a simple AI preset. Instead, create a dedicated OpenCode chat UI.

Changes:
- Remove OpenCode from AIProviderType enum (not OpenAI-compatible)
- Remove OpenCode from AI presets UI
- Create dedicated /opencode route with OpenCodeChat component
- Update opencode.rs with:
  - Proper Windows cleanup support
  - App exit cleanup via cleanup_opencode()
  - Health check polling before returning from start
  - Better error messages with install instructions
- Add @opencode-ai/sdk dependency for proper API integration
- Use session.promptAsync with parts for sending messages
- Add event listeners for opencode_log, opencode_terminated, opencode_error

The OpenCode integration now:
1. Starts OpenCode sidecar on demand
2. Uses OpenCode's native SDK for communication
3. Shows proper install instructions if not available
4. Cleans up properly on app exit

Co-Authored-By: Claude Opus 4.5 <[email protected]>
…loud proxy

- Add Chat/Code tab switcher in global chat dialog header
- OpenCodeChat component uses @opencode-ai/sdk for proper API integration
- Bundle opencode as sidecar (added to tauri.macos.conf.json externalBin)
- Auto-configure opencode to use screenpipe-cloud AI proxy (Vertex AI credits)
- Pass user's screenpipe token for authentication (zero friction)
- Support Windows/Linux/macOS with proper process cleanup
- Health check polling before returning from start

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add OpenCode as AI provider type (openai, ollama, custom, screenpipe-cloud, opencode)
- OpenCode shows as preset option in settings alongside other providers
- Auto-start OpenCode sidecar when preset is selected
- Use OpenCode SDK for messaging when provider is opencode
- Remove tab-based UI - single unified chat experience
- Requires login (uses screenpipe user token for auth)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add opencode to Windows and Linux externalBin configs
- Delete unused opencode-chat.tsx and opencode page
- Add project directory picker with localStorage persistence
- Improve message polling with smart completion detection
- Show project name in header when OpenCode is active
- Allow changing project folder from header button
- Better loading states and error messages

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add OpenCode download to pre_build.js for macOS (arm64, x86_64) and Linux
- Download from GitHub releases (v0.0.55)
- Remove opencode from Windows config (no Windows binary available)
- Add availability check in global chat
- Show "not available on Windows" message when OpenCode preset selected on Windows

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Update to new OpenCode repo (anomalyco/opencode v1.1.45)
- Add Windows binary download in pre_build.js
- Add opencode back to Windows externalBin config
- All platforms now supported: macOS, Linux, Windows

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Remove bundled OpenCode binary from externalBin configs. Instead, install
OpenCode via bun in the background when the app starts. If installation
fails, the OpenCode preset is simply hidden from the UI.

- Remove opencode from externalBin in all platform configs
- Remove download code from pre_build.js
- Add opencode_install command that runs bun add -g opencode-ai
- Add background availability check and install in AIPresets component
- Emit opencode_installed event when installation completes
- Conditionally render OpenCode card only when available

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants