# Ticket 5.10 — Session Diff Viewer

**Phase**: 5 — OpenCode-Specific Features
**Priority**: Low
**Depends on**: 2.3, 1.4

## Description

Display a consolidated view of all file changes made during a session. Uses OpenCode's `GET /session/:id/diff` endpoint to show a git-style unified diff.

## Acceptance Criteria

### AC1: Diff button on sessions

```gherkin
Given a session where the agent has modified files
When the user clicks "View Changes" in the session header
Then it fetches the diff from GET /session/:id/diff
And displays it in a modal or panel
```

### AC2: Diff rendering

```gherkin
Given the diff data is loaded
Then it renders as a unified diff with:
  - File headers showing file paths
  - Green highlights for added lines
  - Red highlights for removed lines
  - Line numbers for both old and new versions
  - Collapsible sections per file
```

### AC3: Summary statistics

```gherkin
Given the diff is displayed
Then it shows a summary:
  - Files changed: N
  - Lines added: +X
  - Lines removed: -Y
```

### AC4: Session with no changes

```gherkin
Given a session where only questions were asked (no file changes)
When the user clicks "View Changes"
Then it shows "No file changes in this session"
```

## Testable Components

| Component | Test Type | What to Assert |
|-----------|-----------|----------------|
| Diff API call | Unit | Constructs correct GET to /session/:id/diff |
| Diff parsing | Unit | Parses git-style diff into structured hunks |
| Diff rendering | E2E | Correct colours (green/red), line numbers, collapsible files |
| Summary stats | E2E | Shows correct files changed, insertions, deletions counts |
| No changes state | E2E | Shows "No changes" message when diff is empty |

## Reference

- OpenCode diff: `GET /session/:id/diff`
- OpenCode session summary field includes additions/deletions/files
