---
task_id: 2
depth: 1
parent: ../manifest.yaml
siblings: [0:Backend Abstraction Layer: Create src/cleave/tui/backends/ with base.py (abstract Backend class), claude.py (wrap existing SDKSession), and registry in __init__.py. Define Message types, BackendConfig, connection lifecycle, and query streaming interface., 1:OpenAI-Compatible Backend + Settings: Create backends/openai_compat.py for Ollama/vLLM/llama.cpp. Extend ~/.cleave/settings.yaml with backend/backends configuration. Add backend auto-detection.]
tdd: false
---

# Task 2: TUI Integration: Refactor SDKSession to use Backend interface. Update ControlPanel for backend/model selection. Add connection status indicator. Update pyproject.toml with optional deps.

## Mission

Integrate backend abstraction into TUI components and update dependency configuration.

## Scope

**In:**
- Update ControlPanel with backend selector dropdown
- Add connection status indicator
- Update CleaveParams to include backend info
- Update pyproject.toml with optional dependency groups
- Lazy imports in tui/__init__.py

**Out:**
- Full SDKSession refactor to use Backend interface (future work)
- Dynamic model list for non-Claude backends (future work)

**Depends on:**
- Task 0: Backend, BackendConfig, Message
- Task 1: Settings extension, detect_available_backends

**Provides:**
- `CleaveParams.backend` and `CleaveParams.backend_config` fields
- Backend selector in ControlPanel
- Connection status display
- Multiple install profiles: [tui], [local], [tui-local], [full]

## Result

**Status:** SUCCESS

**Summary:**
Updated ControlPanel to include backend selection dropdown with connection status indicator. Extended CleaveParams to include backend and backend_config fields. Updated pyproject.toml with optional dependency groups for different installation profiles (claude, local, tui-local, full).

**Artifacts:**
- `src/cleave/tui/widgets/control_panel.py` - Backend selector, status indicator
- `src/cleave/tui/__init__.py` - Lazy imports
- `pyproject.toml` - New optional dependency groups

**Decisions:**
- Backend selector uses Select widget with connection status indicators
- Model radio buttons disabled for non-Claude backends (use settings default)
- Connection status checks run on mount and backend change
- Created multiple install profiles: tui (Claude), local (OpenAI-compat), tui-local, full

**Verification:**
- Command: `PYTHONPATH=src python3 -c "from cleave.core.settings import detect_available_backends; print(detect_available_backends())"`
- Output: Shows available backends with status
- Edge cases: Works without textual (via lazy imports in tui/__init__.py)

**Alignment:** SUCCESS - TUI has backend selection with install flexibility
