feat(acp): Add Claude Code as coding agent provider#49
Conversation
- 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
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (20)
📝 WalkthroughWalkthroughThis 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
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
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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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. Comment |
Summary
AnySessionConnectionenum dispatching commands to either provider backendprovidercolumn to sessions DB with migration and validationTest plan
cargo checkpasses (1 dead_code warning only)npm test— 115 tests pass🤖 Generated with Claude Code
Summary by CodeRabbit