Skip to content

feat(vscode): Add ACP Chat Participant for VS Code#15501

Closed
rudironsoni wants to merge 45 commits intoanomalyco:devfrom
rudironsoni:feature/vscode-acp-chat-participant
Closed

feat(vscode): Add ACP Chat Participant for VS Code#15501
rudironsoni wants to merge 45 commits intoanomalyco:devfrom
rudironsoni:feature/vscode-acp-chat-participant

Conversation

@rudironsoni
Copy link
Copy Markdown

@rudironsoni rudironsoni commented Feb 28, 2026

Issue for this PR

Implements a VS Code chat participant using ACP (Agent Client Protocol) for native VS Code Chat integration.

Type of change

  • New feature

What does this PR do?

This PR adds a VS Code extension that integrates OpenCode as a native chat participant using the ACP (Agent Client Protocol).

Key features:

  • ACP Protocol: Uses JSON-RPC over stdio for communication (not HTTP)
  • Chat Participant: Registers opencode in VS Code's chat UI
  • On-Demand Activation: OpenCode process starts only when user sends first message
  • Microsoft-Style Storage: JSON files in storageUri/transcripts/, max 50 sessions
  • Streaming Responses: Real-time streaming of AI responses
  • Session Persistence: Sessions survive VS Code restarts
  • 50+ Tests: Full test coverage for all major components

The implementation follows Microsoft's best practices for VS Code extensions and uses stable Chat Participant APIs (no proposed APIs).

How did you verify your code works?

  • Unit tests: 50+ tests for ACP process, connection, client, handler, session, storage, activation
  • Integration tests: Mock ACP server for testing
  • TypeScript: All types compile without errors

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Feb 28, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Copilot AI review requested due to automatic review settings March 1, 2026 00:04
@rudironsoni rudironsoni force-pushed the feature/vscode-acp-chat-participant branch from eca00bd to af0930d Compare March 1, 2026 00:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new VS Code extension feature set to integrate OpenCode as a native VS Code Chat participant backed by an ACP (JSON-RPC over stdio) client/process layer, with accompanying storage/session plumbing and extensive tests.

Changes:

  • Introduces ACP protocol/client/connection/process implementations for stdio JSON-RPC communication.
  • Adds VS Code-side components for activation, chat participant registration, request handling, and storage/session persistence.
  • Adds unit + integration test suites and CI workflow coverage for the VS Code SDK package.

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
sdks/vscode/src/vscode/storage.ts Implements transcript + session index persistence under storageUri, plus workspaceState caching.
sdks/vscode/src/vscode/storage.test.ts Unit tests for storage behaviors (index, transcripts, retention, flush).
sdks/vscode/src/vscode/session.ts Adds a session manager that stores session metadata in workspaceState and uses ACP sessions.
sdks/vscode/src/vscode/session.test.ts Unit tests for session creation/reuse/title update/delete logic.
sdks/vscode/src/vscode/participant.ts Registers the @opencode chat participant and defines its request handler.
sdks/vscode/src/vscode/participant.test.ts Unit tests for participant metadata, commands, mentions, and activation integration.
sdks/vscode/src/vscode/handler.ts Implements a chat request handler that builds ACP prompts from VS Code chat history and streams updates.
sdks/vscode/src/vscode/handler.test.ts Unit tests for prompt building, streaming, cancellation, and error mapping.
sdks/vscode/src/vscode/activation.ts Adds on-demand ACP process startup/stop logic with lifecycle tracking.
sdks/vscode/src/vscode/activation.test.ts Unit tests for activation state transitions, concurrency, and disposal behavior.
sdks/vscode/src/integration/chat.test.ts Adds basic integration test scaffolding for chat API availability.
sdks/vscode/src/integration/activation.test.ts Adds basic integration test scaffolding for activation and progress APIs.
sdks/vscode/src/fixtures/mockAcpServer.ts Introduces a mock ACP server intended for integration testing.
sdks/vscode/src/extension.ts Wires activation controller + chat participant registration into extension activation.
sdks/vscode/src/core/types.ts Re-exports storage-related types via a core types module.
sdks/vscode/src/core/session/key.ts Placeholder for future session key management.
sdks/vscode/src/core/prompt/builder.ts Placeholder for future prompt builder.
sdks/vscode/src/acp/protocol.ts Defines ACP protocol types and error codes.
sdks/vscode/src/acp/process.ts Implements spawning/monitoring of the opencode acp subprocess with restart logic.
sdks/vscode/src/acp/process.test.ts Unit tests for process spawn/stdio/healthcheck/restart/stop logic.
sdks/vscode/src/acp/connection.ts Implements JSON-RPC request/response + notification handling over streams.
sdks/vscode/src/acp/connection.test.ts Unit tests for connection buffering, timeouts, notifications, and disposal.
sdks/vscode/src/acp/client.ts Implements high-level ACP client APIs over the JSON-RPC connection.
sdks/vscode/src/acp/client.test.ts Unit tests for client initialization, session APIs, streaming updates, cancel, and disposal.
sdks/vscode/package.json Contributes the chatParticipants entry for @opencode and retains extension commands/scripts.
sdks/vscode/PLAN.md Documents the intended architecture/phases for ACP-based chat integration.
sdks/vscode/.vscode-test.mjs Updates VS Code test-cli configuration to separate unit vs integration suites.
.github/workflows/vscode-test.yml Adds CI workflow to build + run VS Code extension tests on Linux/Windows.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

thdxr and others added 26 commits March 8, 2026 15:32
Implements a first-class VS Code chat participant using Agent Client Protocol (ACP) that integrates natively with VS Code's chat UI.

## Core Features
- ACP process management with JSON-RPC over stdio
- Native @OpenCode chat participant integration
- Session management with on-demand activation
- Microsoft-style storage with JSON file transcripts

## Architecture
- : Process spawning, connection handling, protocol types
- : Chat participant, request handler, session management
- : Unit and integration tests with mock ACP server

## Storage Pattern
- JSON files in storageUri/transcripts/
- Workspace state for metadata
- Max 50 sessions with auto-cleanup

Implements stable Chat Participant API (no proposed APIs).
- Uses system screenshot tools (scrot, ImageMagick import, gnome-screenshot)
- Automatically starts Xvfb on free display if DISPLAY not set
- Organizes screenshots by feature (01-extension, 02-chat, 03-failures)
- Captures full window screenshots during test execution
- Includes helper utilities for test integration
- Fix connection.ts: update ACP connection handling
- Fix process.ts/process.test.ts: correct process management and tests
- Fix activation.test.ts (integration): improve integration activation tests
- Fix chat.test.ts: expand and fix chat integration tests
- Fix screenshot.ts: fix screenshot output path and enhance utilities
- Fix testHelpers.ts: improve test helper utilities
- Fix activation.test.ts (vscode): update vscode activation tests
- Fix handler.test.ts: refactor handler tests
- Fix session.test.ts/session.ts: fix session management and tests
- Fix storage.test.ts/storage.ts: fix storage implementation and tests
- Add .vscode-test/ and out/ to .gitignore to exclude large test artifacts
- Fixed all unit/integration tests (181/181 passing)
- Added Playwright E2E tests for chat participant UI (4 tests)
  - playwright.config.ts: Playwright configuration for E2E tests
  - tsconfig.e2e.json: TypeScript config for E2E tests
  - src/e2e/fixtures.ts: Electron launch fixture
  - src/e2e/chat-participant.e2e.ts: E2E test suite with 4 tests
  - src/e2e/helpers/chat.ts: ChatPanel page object
- Enhanced MockAcpServer with session/prompt handler
- Added screenshot infrastructure with env var support
- Updated package.json with Playwright dependencies
- Updated tsconfig.json with E2E exclude patterns
- Remove console.log statements, use output channel
- Add comprehensive .gitignore (40+ patterns)
- Create Microsoft-compliant test architecture
- Add channel detection (stable vs insiders)
- Create test utilities (channel, assertions)
- Create E2E test suites (chat-core, session-target)
- Add documentation (ARCHITECTURE, CONTRIBUTING, TROUBLESHOOTING)
- Add CI workflow with 6-job matrix (3 OS × 2 channels)
- Fix activation.ts bug (preserve ERROR state)
- Configure mochawesome reporter for HTML reports

Work in progress - tests compile but need verification
…activation event

- Remove Insiders guard from extension registration to enable standard VS Code
- Fix participant ID mismatch in chatSession.ts
- Add onStartupFinished activation event for better startup handling
- Fix E2E tests to work with session targets
- Configure E2E tests to use VS Code Insiders
- Update .gitignore to exclude .vscode-test/ and out/ directories
Adds test helper and bootstrap to capture artifacts on failure; updates .vscode-test.mjs to require bootstrap and updates CI workflow to capture runner stdout/stderr and upload test-results.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ture\n\nAdd src/test/bootstrap.ts and evidence helper plus a small e2e smoke test to exercise failure artifact capture.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…nce generation\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Make the smoke e2e test pass to avoid intentional CI failure while preserving evidence capture.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Temporary test to validate evidence capture; will be removed after verification.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…table evidence capture

Improve attach retry loop and mirror artifacts into package test-results so screenshots can be captured and discovered during CI.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ctron capture APIs

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…vidence capture

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…t handling

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@rudironsoni rudironsoni force-pushed the feature/vscode-acp-chat-participant branch from ad68e71 to 18a7973 Compare March 8, 2026 14:43
@rudironsoni rudironsoni closed this Mar 9, 2026
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.

5 participants