opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat(ide): IDE integration with Cursor/VSCode and improved UX

Open tofunori opened this issue 1 week ago • 2 comments

Summary

Complete IDE integration for OpenCode, enabling live text selection from Cursor/VSCode/Windsurf with improved UX.

Features

  • IDE Connection: WebSocket-based connection to IDE extensions via lock files
  • Live Selection: Real-time text selection from editor
  • Footer Display: Shows IDE status and selection in footer (not cluttering input)
  • Synthetic Context: Selection sent invisibly to model (doesn't pollute chat history)
  • Home Screen: IDE/selection visible from launch, not just in sessions

Changes

Core IDE Integration

  • src/ide/index.ts - IDE connection management, status, events
  • src/ide/connection.ts - WebSocket client with JSON-RPC 2.0
  • src/mcp/ws.ts - WebSocket transport for MCP

UX Improvements

  • local.tsx - Selection state with formatted() helper showing line count
  • home.tsx - IDE/selection display in home footer
  • footer.tsx - Selection display in session footer
  • prompt/index.tsx - Synthetic parts for invisible context

Configuration

Add to opencode.json:

{
  "ide": {
    "lockfile_dir": "~/.claude/ide/",
    "auth_header_name": "x-claude-code-ide-authorization"
  }
}

Testing

  1. Install the OpenCode extension in Cursor/VSCode
  2. Launch OpenCode in terminal
  3. Connect to IDE via /status
  4. Select text in editor
  5. Verify footer shows: [] 6 lines
  6. Send message - selection content is included invisibly

Related

Based on initial work from #5447, with additional UX improvements:

  • Selection displayed in footer instead of input area
  • Synthetic parts so selection doesn't clutter chat history
  • Home screen shows IDE connection status

tofunori avatar Dec 21 '25 00:12 tofunori

@thdxr Would love your thoughts on IDE integration for OpenCode.

What this enables:

  • Live text selection from Cursor/VSCode/Windsurf via WebSocket
  • Selection displayed in footer (not cluttering the input)
  • Synthetic context - selection sent to model without polluting chat history

Status:

  • Based on @tcdent's work in #5447, with UX improvements
  • Already tested and adopted by shuvcode fork
  • Copilot review addressed

This brings OpenCode closer to Claude Code's IDE integration experience. Happy to make any changes needed for merge.

tofunori avatar Dec 21 '25 14:12 tofunori

@thdxr Would love your thoughts on IDE integration for OpenCode.

What this enables:

  • Live text selection from Cursor/VSCode/Windsurf via WebSocket
  • Selection displayed in footer (not cluttering the input)
  • Synthetic context - selection sent to model without polluting chat history

Status:

This brings OpenCode closer to Claude Code's IDE integration experience. Happy to make any changes needed for merge.

For what it's worth, this is merged but not yet working in shuvcode. It looks like it will require a fork of the vscode extension to target the shuvcode binary instead of opencode. We will get it tested over the next few days and will provide feedback here.

shuv1337 avatar Dec 22 '25 06:12 shuv1337