From d7980133e9abc127431a9ba76dced6eba80eb635 Mon Sep 17 00:00:00 2001 From: Accusys Date: Sat, 1 Aug 2026 02:12:43 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20update=20Studio=20handoff=20with=20Core?= =?UTF-8?q?=20API=E9=85=8D=E5=A5=97=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added Core API optimizations already deployed: - Thumbnail API uses pre-cached key_face.jpg (8ms vs 500ms) - Face-groups API supports ?include_trace_ids=false (-48% payload) Updated Studio instructions to use these new endpoints. --- ...-01_studio_face_group_perf_optimization.md | 100 ++++++++++++++++-- 1 file changed, 90 insertions(+), 10 deletions(-) diff --git a/docs_v1.0/M4_workspace/2026-08-01_studio_face_group_perf_optimization.md b/docs_v1.0/M4_workspace/2026-08-01_studio_face_group_perf_optimization.md index b6278306..97a72820 100644 --- a/docs_v1.0/M4_workspace/2026-08-01_studio_face_group_perf_optimization.md +++ b/docs_v1.0/M4_workspace/2026-08-01_studio_face_group_perf_optimization.md @@ -9,11 +9,60 @@ Loading face groups for large files (e.g., Charade with 153 groups, 2,451 traces **Estimated load time before: ~76 seconds** -## Changes Required +--- + +## Core API Changes (Already Deployed) + +These changes are already on the Core side. Studio just needs to use the new endpoints. + +### A. Thumbnail API Now Uses Pre-Cached key_face.jpg + +**Endpoint:** `GET /api/v1/face-thumbnail?uuid={uuid}&trace_id={tid}&frame={frame}` + +The API now checks `output/{uuid}/trace_{tid}/key_face.jpg` before falling back to ffmpeg. + +| Scenario | Before | After | +|----------|--------|-------| +| First request | ~500ms (ffmpeg) | **~8ms** (read file) | +| All traces have key_face.jpg | Yes | ✅ Used automatically | + +**Studio action:** No code change needed. Just pass `trace_id` in the thumbnail request. + +### B. Face-Groups API Supports Payload Reduction + +**Endpoint:** `GET /api/v1/file/{uuid}/face-groups?include_trace_ids=false` + +| Param | Payload Size | Response | +|-------|-------------|----------| +| Default (omit) | ~32KB (Charade) | Full data with `trace_ids` array | +| `include_trace_ids=false` | **~17KB** (-48%) | Groups without `trace_ids` | + +**Response when `include_trace_ids=false`:** +```json +{ + "face_groups": [ + { + "group_id": 1, + "name": "Person_5", + "trace_count": 248, + "representative_trace": 3725, + "editable": true + } + ] +} +``` + +Note: `trace_ids` field is **omitted** (not `null`, just not present). + +**Studio action:** Use `?include_trace_ids=false` for initial load. Fetch full data only when user clicks into a group. + +--- + +## Studio Changes Required ### 1. Increase Thumbnail Concurrency -**File:** `src/store.ts` +**File:** `/Users/accusys/momentry_studio/src/store.ts` ```typescript // Line ~327: Change from 16 to 32 @@ -24,13 +73,40 @@ const MAX_CONCURRENT = 32 // was 16 --- -### 2. Add Lazy Loading to Face Groups +### 2. Use Reduced Payload for Initial Load -**File:** `src/views/PeopleView.vue` +**File:** `/Users/accusys/momentry_studio/src/api/index.ts` (or wherever face-groups is fetched) + +**Before:** +```typescript +const resp = await apiCall('get_face_groups', { fileUuid: uuid }) +``` + +**After:** +```typescript +// Initial load: lightweight, no trace_ids +const resp = await fetch(`/api/v1/file/${uuid}/face-groups?include_trace_ids=false`, { + headers: { 'Authorization': `Bearer ${apiKey}` } +}) +``` + +When user clicks into a group to see members, fetch full data: +```typescript +const resp = await fetch(`/api/v1/file/${uuid}/face-groups`, { + headers: { 'Authorization': `Bearer ${apiKey}` } +}) +// Or fetch single group's traces if you add a per-group endpoint later +``` + +--- + +### 3. Add Lazy Loading to Face Groups + +**File:** `/Users/accusys/momentry_studio/src/views/PeopleView.vue` The `v-observe` directive (IntersectionObserver) is already used for unassigned traces. Apply the same pattern to face groups. -#### 2a. Main Face Groups Section (~line 53) +#### 3a. Main Face Groups Section (~line 53) **Before:** ```vue @@ -42,7 +118,7 @@ The `v-observe` directive (IntersectionObserver) is already used for unassigned
``` -#### 2b. Merge Target Modal (~line 303) +#### 3b. Merge Target Modal (~line 303) **Before:** ```vue @@ -54,7 +130,7 @@ The `v-observe` directive (IntersectionObserver) is already used for unassigned
``` -#### 2c. Merge Candidate Modal (~line 273) +#### 3c. Merge Candidate Modal (~line 273) **Before:** ```vue @@ -70,7 +146,7 @@ The `v-observe` directive (IntersectionObserver) is already used for unassigned ## How `v-observe` Works -The directive is already defined in `src/directives/vObserve.ts`: +The directive is already defined in `/Users/accusys/momentry_studio/src/directives/vObserve.ts`: - Uses `IntersectionObserver` with `rootMargin: '200px 0px'` - Only triggers when element enters viewport (+200px buffer) - Auto-disconnects after first trigger @@ -84,7 +160,9 @@ The directive is already defined in `src/directives/vObserve.ts`: |--------|--------|-------| | Concurrent loads | 16 | **32** | | Initial thumbnails | All 153 | **Only visible (~6-10)** | -| Charade load time | ~76s | **<2s** (first screen) | +| API payload | 32KB | **17KB** (-48%) | +| Thumbnail per request | ~500ms | **~8ms** | +| Charade load time | ~76s | **<1s** (first screen) | --- @@ -94,11 +172,13 @@ The directive is already defined in `src/directives/vObserve.ts`: 2. Verify face group thumbnails load as you scroll down 3. Verify merge dialogs also lazy-load thumbnails 4. Check browser Network tab — thumbnails should not all fire at once +5. Verify API response size is ~17KB (not 32KB) with `?include_trace_ids=false` --- ## Notes - `loadTraceThumb` and `faceThumbsCache` are already imported in PeopleView.vue -- The `v-observe` directive is already registered globally in `src/main.ts` +- The `v-observe` directive is already registered globally in `/Users/accusys/momentry_studio/src/main.ts` - No new dependencies required +- Core API changes are already deployed (commit `8a766799`)