# Bug Report: Chunk Responses Missing start_frame / end_frame / fps

**發現者**：M4  
**日期**：2026-05-06  

---

## 問題

多個 endpoint 的 chunk response 缺少 `start_frame`、`end_frame`、`fps` 欄位，導致前端無法進行 frame-level 的時間定位。

---

## 1. Universal Search Chunk ❌ 缺 fps

`POST /api/v1/search/universal` → `SearchResult::Chunk`

**檔案**：`src/api/universal_search.rs`

```rust
pub enum SearchResult {
    Chunk {
        chunk_id: String,
        chunk_type: String,
        start_frame: i64,      // ✅
        end_frame: i64,        // ✅
        start_time: f64,       // ✅
        end_time: f64,         // ✅
        score: f64,
        text: Option<String>,
        speaker_id: Option<String>,
        metadata: Option<Value>,
        // ❌ fps: f64 缺失
    },
```

## 2. Identity Chunk Item ❌ 缺 frame 欄位

`GET /api/v1/identity/{uuid}/chunks` → `IdentityChunkItem`

**檔案**：`src/api/identity_api.rs`

```rust
pub struct IdentityChunkItem {
    pub id: i64,
    pub file_uuid: String,
    pub chunk_id: String,
    pub chunk_type: String,
    pub start_time: Option<f64>,    // ✅
    pub end_time: Option<f64>,      // ✅
    pub text_content: Option<String>,
    // ❌ 無 start_frame
    // ❌ 無 end_frame
    // ❌ 無 fps
}
```

---

## 對比：正常範例

`POST /api/v1/search/smart` → `SearchResult`（正常 ✅）

```rust
pub struct SearchResult {
    pub start_frame: i64,    // ✅
    pub end_frame: i64,      // ✅
    pub fps: f64,            // ✅
    pub start_time: f64,
    pub end_time: f64,
    ...
}
```

---

## 建議修復

| File | Struct | 補上欄位 |
|------|--------|---------|
| `universal_search.rs` | `SearchResult::Chunk` | `fps: f64` |
| `identity_api.rs` | `IdentityChunkItem` | `start_frame: i64`, `end_frame: i64`, `fps: f64` |

在組裝 response 時，從 `chunks` 表或 `videos` 表 lookup fps 填入。
