# Ticket 5.2 — Model / Provider Picker

**Phase**: 5 — OpenCode-Specific Features
**Priority**: High
**Depends on**: 1.4, 4.1

## Description

UI for selecting the AI model and provider. OpenCode supports 25+ providers (Anthropic, OpenAI, Google, Mistral, etc.) with multiple models each. The picker shows available options with cost information.

## Acceptance Criteria

### AC1: Displays current model in status bar

```gherkin
Given the active model is "claude-sonnet-4-20250514" from provider "anthropic"
When the status bar renders
Then it shows "claude-sonnet-4-20250514" (or a friendly short name)
And it is clickable to open the picker
```

### AC2: Model picker shows all available models

```gherkin
When the user clicks the model name
Then a picker modal/dropdown opens
And it lists providers as groups (Anthropic, OpenAI, Google, etc.)
And each model shows: name, context window size, cost per 1K tokens
And the current model is highlighted
And only providers with configured API keys are shown
```

### AC3: Switch model

```gherkin
Given the model picker is open
When the user selects "gpt-4o" from provider "openai"
Then the relay sends the model switch to OpenCode
And the status bar updates to show "gpt-4o"
And a status message appears in chat: "Switched to gpt-4o (openai)"
```

### AC4: Cost display

```gherkin
Given a model with input cost $0.003/1K and output cost $0.015/1K
When it is listed in the picker
Then it shows the cost information
And after a response, the usage display includes cost based on the active model
```

### AC5: Model unavailable handling

```gherkin
Given a model requires an API key that isn't configured
When the model is listed
Then it appears greyed out with "API key not configured"
And selecting it shows instructions for setting the key
```

## Testable Components

| Component | Test Type | What to Assert |
|-----------|-----------|----------------|
| Provider/model parsing | Unit | Parses /provider/ response, groups by provider |
| Cost formatting | Unit | Formats cost per 1K tokens correctly |
| Status bar display | E2E | Shows current model name in status bar, clickable |
| Picker rendering | E2E | Groups models by provider, shows cost, highlights active |
| Model switch | E2E | Selecting model sends switch command, status bar updates |
| Unavailable model | E2E | Unavailable models greyed out with helpful message |

## Reference

- OpenCode providers: `../opencode/packages/opencode/src/provider/provider.ts`
- OpenCode models: `../opencode/packages/opencode/src/provider/models.ts`
- OpenCode provider API: `GET /config/providers`
