# 🎙️ InsuWiki Voice Features Consolidation Meeting
> **Date**: 2026-02-18
> **Topic**: Technical Debt Analysis & Consolidation Strategy for Voice Features
> **Participants**: PM(Jay), Tech Lead, Frontend(React), UX Designer, Mobile Specialist, QA, Security, Data, Core Architect

---

## 1. Current State Analysis (The Chaos 🌪️)

**Tech Lead**: "We've scanned the codebase and found significant redundancy. We currently have **2 distinct technical stacks** and **4 different user interfaces** for voice interaction."

### 🚩 Duplicated Hooks (Technical Redundancy)
| Hook | Purpose | Implementation | Status |
| :--- | :--- | :--- | :--- |
| `useSpeechRecognition.ts` | **STT Only** (Dictation, Search, Commands) | Web Speech API | ✅ Core (Flexible) |
| `useVoiceRecorder.ts` | **STT + File** (AI Whispers) | **Web Speech API (Duplicate)** + MediaStream | ⚠️ Redundant (Hybrid) |
| `useAudioRecorder.ts` | **File Only** (Daily Note Recording) | MediaRecorder (Blob) | ✅ Core (File) |
| `useVoiceCommand.ts` | **Command Logic** | Wraps `useSpeechRecognition` | ✅ Logic Layer |

**Core Architect**: "`useVoiceRecorder` is the main offender. It re-implements `useSpeechRecognition` logic inside itself instead of importing it. This means if we fix a bug in one STT engine (like the duplicate word issue), the other one remains broken."

### 📱 Fragmented UI (UX Inconsistency)
| Component | Feature | Hook Used | Location |
| :--- | :--- | :--- | :--- |
| `SearchInput.tsx` | Voice Search | `useSpeechRecognition` | Top Search Bar |
| `VoiceDictation.tsx` | Editor Dictation | `useSpeechRecognition` | PC Bottom-Right FAB |
| `MobileAIBar.tsx` (AIWhispers) | STT Display (No Save) | `useVoiceRecorder` | Mobile Bottom Sheet |
| `AudioRecorderButton.tsx` | File Recording | `useAudioRecorder` | Daily Note (Bottom-Right) |

**UX Designer**: "Users are confused. We have a 'Red Microphone' for dictation on PC, a 'Red Microphone' for file recording on Daily Notes, and a 'Blue Button' for AI Whispers on Mobile. They look similar but do completely different things."

---

## 2. The "9-Agent" Verdict 👨‍⚖️

### 👮‍♂️ PM (Jay)
"We need to stop adding new voice features until we clean this up. **One unified voice engine** should handle everything. If I speak, the app should know contextually whether to 'Type it', 'Search it', or 'Record it'."

### 👨‍💻 Frontend (React)
"Agreed. `useVoiceRecorder.ts` should be deleted or refactored to specific use-cases. `AIWhispers` should just use the standard `useSpeechRecognition` hook like everyone else."

### 📱 Mobile Specialist
"The `MobileAIBar` overlap with `AudioRecorderButton` was just a symptom. The real issue is that we have two 'floating' voice buttons fighting for space. We need a **Unified Action Button** on mobile."

### 🔓 Security
"Currently `AIWhispers` says 'data is encrypted' but it's just ephemeral text. If we actually save it, we must ensure PII compliance. The current implementation is safe purely because it deletes everything immediately."

---

## 3. Consolidation Strategy (The Fix 🛠️)

### Step 1: Unify the Hook Layer (Refactor)
- **Delete** `useVoiceRecorder.ts` (The hybrid monster).
- **Update** `AIWhispers.tsx` to use the standard `useSpeechRecognition.ts`.
- **Result**: Single source of truth for Web Speech API handling.

### Step 2: Clarify the UX (Rename & Iconography)
| Feature | New Name | Icon | Persistence |
| :--- | :--- | :--- | :--- |
| **Voice Search** | Voice Search | 🔍 + 🎤 | Transient |
| **Dictation (PC)** | **"Type with Voice"** | ⌨️ + 🎤 | Editor Content |
| **AI Whispers** | **"Live Transcribe"** | ✨ + 📝 | Session Only |
| **Daily Record** | **"Meeting Record"** | 🔴 (Rec) | **File Saved** |

### Step 3: Mobile UI Unification
- Instead of showing both `MobileAIBar` button and `AudioRecorderButton` (which overlap), leverage the **Mobile AI Bar** as the central hub.
- Move the "Meeting Record" function *into* the Mobile AI Bar as a primary action.

---

## 4. Immediate Action Items
1.  **Refactor**: Modify `AIWhispers` to use `useSpeechRecognition`.
2.  **Delete**: Remove the redundant `useVoiceRecorder`.
3.  **UI Decision**: Decide if we want to merge "Recording" into the AI Bar.

> **Consensus**: We will proceed with **Step 1 (Refactor)** immediately to fix the code redundancy. Step 3 (UI Merge) requires design approval.
