# Ticket 5.7 — Advanced Search (Files, Symbols, Text)

**Phase**: 5 — OpenCode-Specific Features
**Priority**: Medium
**Depends on**: 1.4, 4.4

## Description

Expose OpenCode's code search capabilities (`/find/files`, `/find/symbols`, `/find/text`) through the web UI. Allows users to search their project without using the agent.

## Acceptance Criteria

### AC1: Search bar in file browser

```gherkin
Given the file browser panel is open
When the user types in the search bar
Then a dropdown shows search modes: "Files", "Symbols", "Text"
And the default mode is "Files"
```

### AC2: File search

```gherkin
Given search mode is "Files"
When the user types "button"
Then it calls GET /find/files?query=button
And results show matching file paths
And clicking a result opens the file preview
```

### AC3: Symbol search

```gherkin
Given search mode is "Symbols"
When the user types "handleClick"
Then it calls GET /find/symbols?query=handleClick
And results show symbol name, type (function/class/variable), and file location
And clicking a result opens the file at that location
```

### AC4: Text search (grep)

```gherkin
Given search mode is "Text"
When the user types "TODO"
Then it calls GET /find/text?query=TODO
And results show matching lines with file path and line number
And matching text is highlighted
And clicking a result opens the file at that line
```

### AC5: Search results count

```gherkin
Given a search returns results
Then the result count is shown: "42 results"
And results are paginated if there are many (> 50)
```

## Testable Components

| Component | Test Type | What to Assert |
|-----------|-----------|----------------|
| Search result parsing | Unit | Parses /find, /find/file, /find/symbol responses correctly |
| Search mode selector | E2E | Toggle switches between Files, Symbols, Text modes |
| File search | E2E | Entering query calls correct endpoint, displays file paths |
| Symbol search | E2E | Entering query displays symbols with types and locations |
| Text search | E2E | Entering query displays matching lines with highlights |
| Result click | E2E | Clicking result opens file browser at correct location |
| Pagination | E2E | Shows "load more" after 50 results, loads next page |

## Reference

- OpenCode search: `GET /find/files`, `GET /find/symbols`, `GET /find/text`
- Integrates into file browser (ticket 4.4)
