Skip to content

feat(acp): Add Claude Code as coding agent provider#49

Merged
wilcorrea merged 5 commits intomainfrom
feat/support-claude
Mar 9, 2026
Merged

feat(acp): Add Claude Code as coding agent provider#49
wilcorrea merged 5 commits intomainfrom
feat/support-claude

Conversation

@wilcorrea
Copy link
Copy Markdown
Contributor

@wilcorrea wilcorrea commented Mar 9, 2026

Summary

  • Add per-session provider selection (Copilot or Claude Code) with UI dropdown in session creation dialog
  • Implement AnySessionConnection enum dispatching commands to either provider backend
  • Add Claude message persistence (streaming buffer, tool calls, user messages) matching Copilot's SQLite pattern
  • Add provider column to sessions DB with migration and validation
  • Add session/load fallback to session/new on reconnection failure
  • Show provider badge in session header and session cards

Test plan

  • cargo check passes (1 dead_code warning only)
  • npm test — 115 tests pass
  • TypeScript compiles without errors
  • Manual: create session with Copilot provider → verify connects and messages persist
  • Manual: create session with Claude provider → verify connects, messages persist, reload shows history
  • Manual: verify reconnection fallback works when session/load fails
  • Manual: verify provider badge shows correctly on SessionCard and ActiveSessionView

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added Claude as an alternative AI provider option alongside Copilot
    • New provider selection in Settings to switch between Copilot and Claude
    • Claude-specific configuration options including model selection, permission controls, and usage budget limits
    • Session provider now visible on session cards and active session view
    • Enhanced system diagnostics with provider authentication status information

- Add `AnyConnection` enum to dispatch between `AcpConnection` (Copilot)
  and `ClaudeConnection` (Claude)
- Add `Provider` enum, `HeartbeatEvent`, and `ConnectionLogEntry` types
- Add `emit_log`, `send_request_with_timeout` to `AcpConnection`
- Add `emit_log_raw` free function used by reader/heartbeat tasks
- Smarter reconnection: check `is_alive()` before reusing existing conn
- Add `acp_connect` params: `provider`, `model`, `skip_permissions`, `max_budget_usd`
- Add diagnostics for Claude binary (version, latency, auth status)
- Update `GeneralSettings` and `DiagnosticsSettings` with Claude options
- Add `@radix-ui/react-checkbox` dependency
- Update i18n strings (pt-BR, en) for new provider settings
- Add migration to ALTER TABLE with default 'copilot'
- Update schema with CHECK constraint for copilot/claude
- Add provider field to `SessionRecord` and CRUD operations
- Validate provider in `session_create` command
- Create `AnySessionConnection` enum dispatching to Copilot/Claude
- Expand `SessionConnectionConfig` with Claude-specific fields
- Branch `acp_session_connect` for Copilot vs Claude providers
- Update all per-session commands to work with either provider
- Add streaming buffer and `save_to_db` to Claude reader task
- Add user-message persistence to `ClaudeConnection::send_prompt`
- Add `AcpProvider` type and provider field to `SessionRecord`
- Create `ConnectOptions` interface in `useSessionConnection`
- Add provider dropdown to `NewSessionForm` dialog
- Show provider badge in `ActiveSessionView` and `SessionCard`
- Load provider-specific settings from localStorage in `doInit`
- Add i18n keys for provider label
- Update tests for new `ConnectOptions` signature
- If session/load fails on reconnect (expired/unknown session),
  automatically fall back to session/new instead of propagating error
- Propagate real backend errors to UI instead of generic message
- Change `connect()` to throw on failure instead of returning null
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 9, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b385ad54-c90d-4f76-8143-f90125ed242c

📥 Commits

Reviewing files that changed from the base of the PR and between e5ede18 and bf6d49d.

⛔ Files ignored due to path filters (1)
  • apps/tauri/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (20)
  • apps/tauri/package.json
  • apps/tauri/src-tauri/src/acp/commands.rs
  • apps/tauri/src-tauri/src/acp/connection.rs
  • apps/tauri/src-tauri/src/acp/types.rs
  • apps/tauri/src-tauri/src/comments.rs
  • apps/tauri/src-tauri/src/lib.rs
  • apps/tauri/src-tauri/src/sessions.rs
  • apps/tauri/src/__tests__/hooks/useSessionConnection.test.ts
  • apps/tauri/src/components/ActiveSessionView.tsx
  • apps/tauri/src/components/DirectoryWorkspace.tsx
  • apps/tauri/src/components/NewSessionForm.tsx
  • apps/tauri/src/components/SessionCard.tsx
  • apps/tauri/src/components/settings/DiagnosticsSettings.tsx
  • apps/tauri/src/components/settings/GeneralSettings.tsx
  • apps/tauri/src/hooks/useAcpConnection.ts
  • apps/tauri/src/hooks/useLocalSessions.ts
  • apps/tauri/src/hooks/useSessionConnection.ts
  • apps/tauri/src/locales/en.json
  • apps/tauri/src/locales/pt-BR.json
  • apps/tauri/src/types/index.ts

📝 Walkthrough

Walkthrough

This PR introduces comprehensive support for Claude as an alternative AI provider alongside the existing Copilot integration. Changes span a unified provider abstraction layer (Rust backend), provider-aware connection and session management, UI provider selection and settings, database schema extensions, and localization for new provider-specific configuration options.

Changes

Cohort / File(s) Summary
Package & Dependencies
apps/tauri/package.json
Added @radix-ui/react-checkbox dependency for UI components.
Rust Core Types & Enums
apps/tauri/src-tauri/src/acp/types.rs
Introduced Provider enum (Copilot/Claude), extended ConnectionConfig with provider field, and added comprehensive Claude NDJSON event types (ClaudeEvent, ClaudeSystemEvent, ClaudeAssistantEvent, etc.) for parsing Claude protocol messages.
Rust Connection Management
apps/tauri/src-tauri/src/acp/connection.rs
Implemented ClaudeConnection struct with spawn constructor, async IO handling (reader/writer/heartbeat tasks), send_prompt with timeout, session tracking, and health monitoring; extended AcpConnection with emit_log method.
Rust Command Orchestration
apps/tauri/src-tauri/src/acp/commands.rs
Refactored all ACP commands to support dual-provider routing via AnyConnection/AnySessionConnection enums; updated acp_connect, acp_new_session, acp_send_prompt, acp_set_mode, acp_cancel, acp_session_connect, acp_session_status and others to dispatch to Copilot JSON-RPC or Claude-specific implementations; extended config structures with provider context.
Rust Database & Persistence
apps/tauri/src-tauri/src/comments.rs, apps/tauri/src-tauri/src/sessions.rs
Added provider column to sessions table with NOT NULL DEFAULT 'copilot' and CHECK constraint; extended SessionRecord with provider field; updated session creation flow to accept and validate provider parameter.
Rust Diagnostics
apps/tauri/src-tauri/src/lib.rs
Extended run_diagnostics to accept provider parameter, added Claude-specific connection testing via test_claude_connection, integrated Claude auth status collection (auth status --json), and updated binary path resolution to respect CLAUDE_PATH for Claude provider.
TypeScript Hooks - Connection Wiring
apps/tauri/src/hooks/useAcpConnection.ts, apps/tauri/src/hooks/useSessionConnection.ts, apps/tauri/src/hooks/useLocalSessions.ts
Updated connection hooks to read provider and Claude-specific config from localStorage; refactored useSessionConnection.connect to accept ConnectOptions object with provider, model, skipPermissions, maxBudgetUsd fields; changed error handling from returning null to throwing errors; extended createSession to accept provider parameter.
TypeScript React Components - Session Management
apps/tauri/src/components/NewSessionForm.tsx, apps/tauri/src/components/SessionCard.tsx, apps/tauri/src/components/DirectoryWorkspace.tsx, apps/tauri/src/components/ActiveSessionView.tsx
Added provider selector UI in NewSessionForm; updated session creation callbacks to pass provider; added provider badge display in SessionCard and ActiveSessionView; refactored connect logic to build provider-aware options from localStorage.
TypeScript React Components - Settings
apps/tauri/src/components/settings/GeneralSettings.tsx, apps/tauri/src/components/settings/DiagnosticsSettings.tsx
Introduced provider mode switcher and conditional rendering of provider-specific settings (copilot: GH token + copilot path; claude: claude path, model, skip permissions, max budget); extended DiagnosticsResult interface with auth_status and auth_method fields; updated diagnostics UI and copy-report logic to reflect provider-aware output.
TypeScript Test Updates
apps/tauri/src/__tests__/hooks/useSessionConnection.test.ts
Updated tests to reflect new connect(opts) signature requiring options object with workspacePath and optional acpSessionId; adjusted error assertions to catch thrown errors instead of checking for null returns.
TypeScript Types & Localization
apps/tauri/src/types/index.ts, apps/tauri/src/locales/en.json, apps/tauri/src/locales/pt-BR.json
Added AcpProvider type definition ("copilot" | "claude"); extended SessionRecord with provider field; added comprehensive i18n keys for provider selection, Claude-specific settings (path, model, max budget, skip permissions), Claude auth status, and updated diagnostic labels to be provider-agnostic.

Sequence Diagram(s)

sequenceDiagram
    participant UI as React Component
    participant Hook as useSessionConnection
    participant Tauri as Tauri Runtime
    participant RS as Rust Backend
    participant Process as Copilot/Claude Process
    
    UI->>Hook: connect({ workspacePath, provider, model, ... })
    Hook->>Hook: Read provider config from localStorage
    Hook->>Tauri: invoke acp_session_connect({ workspacePath, provider, ... })
    Tauri->>RS: acp_session_connect command
    
    alt Provider = Copilot
        RS->>Process: Spawn Copilot (AcpConnection)
        RS->>Process: Initialize via JSON-RPC
        Process-->>RS: Ready
    else Provider = Claude
        RS->>Process: Spawn Claude (ClaudeConnection)
        RS->>Process: Resume or init session
        Process-->>RS: session_id
    end
    
    RS->>RS: Store connection in AnyConnection enum
    RS->>RS: Emit status event to frontend
    RS-->>Tauri: Return providerSessionId
    Tauri-->>Hook: Success with session ID
    Hook->>UI: Return session ID / Set connected status
    
    Note over Process: Heartbeat/health checks running
    Process-->>RS: Emit status updates
    RS-->>Tauri: Forward events to frontend
Loading
sequenceDiagram
    participant UI as React Component (NewSessionForm)
    participant Hook as useLocalSessions
    participant Tauri as Tauri Runtime
    participant RS as Rust Backend
    participant DB as SQLite Database
    
    UI->>UI: Select provider (copilot/claude)
    UI->>Hook: createSession(name, prompt, provider)
    Hook->>Hook: Resolve provider from param or localStorage
    Hook->>Tauri: invoke session_create({ workspace_id, name, prompt, provider })
    Tauri->>RS: session_create command
    
    RS->>RS: Validate provider in ["copilot", "claude"]
    RS->>DB: INSERT INTO sessions (name, prompt, provider, ...) VALUES (...)
    DB-->>RS: row_id
    RS->>RS: Map result to SessionRecord with provider field
    RS-->>Tauri: Return SessionRecord { provider, ... }
    Tauri-->>Hook: SessionRecord
    Hook-->>UI: SessionRecord with provider
    UI->>UI: Display session with provider badge
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Poem

🐰 A rabbit hops between two paths,
One blazed by Copilot's wrath,
The other Claude's swift refrain—
Two providers, one abstraction plain,
Sessions bloom with choices bright,
Backend routing left and right! 🎯

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/support-claude

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@wilcorrea wilcorrea merged commit 6718f2c into main Mar 9, 2026
1 check was pending
@wilcorrea wilcorrea deleted the feat/support-claude branch March 9, 2026 13:32
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.

1 participant