# Ticket 10.6 — Compaction Status Display

**Phase**: 10 — Feature Parity Enhancements
**Priority**: Medium
**Depends on**: None

## Description

Detect and display when OpenCode is compacting (summarizing) the conversation to fit within the context window. claude-relay detects compaction by parsing `<local-command-stdout>` tags in user messages and broadcasts a compacting status to the UI. During compaction, the user sees a mysterious pause with no feedback — this ticket provides a clear "Compacting conversation..." indicator.

OpenCode may emit specific events or status changes during compaction. The relay should:

- Detect compaction state from SSE events or session status changes
- Display a non-intrusive status indicator (e.g., system message or header status text)
- Show approximate progress if available
- Clear the indicator when compaction completes

## Acceptance Criteria

### AC1: Compaction indicator appears when compaction begins
```gherkin
Given a session is active and the conversation exceeds the context window
When OpenCode begins compacting the conversation
Then a "Compacting conversation..." indicator appears in the UI
  And the indicator is visible within 500ms of the compaction event
```

### AC2: Indicator is non-intrusive
```gherkin
Given the compaction indicator is displayed
When the user views the chat interface
Then the indicator does not block the input area
  And the indicator does not obscure existing messages
  And the indicator is displayed as a subtle banner or inline system message
```

### AC3: Indicator disappears when compaction completes
```gherkin
Given the compaction indicator is currently displayed
When OpenCode finishes compacting the conversation
Then the indicator disappears
  And the chat interface returns to its normal state
  And the compacted summary message (if any) is rendered in the message list
```

### AC4: Messages queued during compaction
```gherkin
Given OpenCode is currently compacting the conversation
When the user types and sends a message
Then the message is queued locally
  And a visual hint indicates the message is pending (e.g., "Sending after compaction...")
  And the message is sent to OpenCode after compaction completes
```

### AC5: Status dot reflects compaction state
```gherkin
Given the header displays a status dot indicating connection state
When OpenCode enters compaction state
Then the status dot changes to a distinct colour (e.g., yellow/amber)
  And hovering the dot shows a tooltip "Compacting conversation..."

When compaction completes
Then the status dot returns to its normal connected colour (e.g., green)
```

## Testable Components

| Component | Test Type | What to Assert |
|-----------|-----------|----------------|
| Compaction event detection from SSE | Unit | Given an SSE event stream containing compaction-related events, correctly identifies compaction start and end; returns boolean compaction state |
| Compaction state in event translator | Unit | Translates OpenCode compaction events into relay-internal `session.compacting` status messages with correct payload |
| Status indicator rendering and dismissal | E2E | Indicator appears when compaction starts; disappears when compaction ends; does not block input area |
| Status dot colour change during compaction | E2E | Dot changes to amber during compaction; returns to green when compaction ends; tooltip text updates accordingly |

## Reference

- claude-relay compaction detection: `../claude-relay/lib/sdk-bridge.js` (compacting status broadcast)
- Event translator: `conduit/src/lib/event-translator.ts` (session.status event handling)
- Header status dot: `conduit/src/lib/public/components/layout/Header.svelte`
