# InsuWiki Floating 용어감지 — ai_suggestions 데이터 생성

## Lv.2 작업

## 문제
FloatingTermDetection 컴포넌트가 배포되어 있으나 (`nextapp/src/components/FloatingTermDetection.tsx`), Firestore의 `documents/{docId}/ai_suggestions` 서브컬렉션에 데이터가 없어서 floating 버튼이 안 보임.

코드 226줄: `if (loading || terms.length === 0) return null;` → 데이터 없으면 렌더링 자체 안 됨.

## 원인
Cloud Functions (`staticMatching.ts`, `embeddingMatching.ts`)가 문서에 대해 실행되지 않았거나, `insurance_terms` 컬렉션 데이터 부족으로 매칭 결과 0건.

## 수정 범위

### 1. insurance_terms 데이터 확인
- Firestore `insurance_terms` 컬렉션에 데이터가 있는지 확인
- 없으면 seed 스크립트 실행: `/home/jay/projects/insuwiki/scripts/seedInsuranceTerms.ts`

### 2. Cloud Function 상태 확인
- `staticMatching` Function이 배포되어 있는지 확인: `firebase functions:list`
- 배포 안 되어 있으면: `cd /home/jay/projects/insuwiki && firebase deploy --only functions:staticMatching`

### 3. 기존 문서에 대해 매칭 실행
- 이미 Firestore에 있는 문서들에 대해 staticMatching을 수동 트리거
- 스크립트: `/home/jay/projects/insuwiki/scripts/seed-and-evaluate-embeddings.ts` 참고
- 또는 각 문서를 업데이트(빈 필드 추가)하여 Function 트리거

### 4. 검증
- InsuWiki 서비스에서 아무 문서 열기 → 오른쪽 하단에 amber 색상 floating 버튼 표시 확인
- 버튼 클릭 → 용어 매칭 리스트 표시 확인

## 참조
- FloatingTermDetection: `/home/jay/projects/insuwiki/nextapp/src/components/FloatingTermDetection.tsx`
- staticMatching: `/home/jay/projects/insuwiki/functions/src/staticMatching.ts`
- embeddingMatching: `/home/jay/projects/insuwiki/functions/src/embeddingMatching.ts`
- seedInsuranceTerms: `/home/jay/projects/insuwiki/scripts/seedInsuranceTerms.ts`
- Firebase 키: `/home/jay/.config/gcloud/service-accounts/insuwiki-j2h-fa603f4f75f5.json`

## 보고서
`/home/jay/workspace/memory/reports/task-{TASK_ID}.md`