Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

docs: add local semantic search to CLAUDE.md

Gabriel Stein4353f75337d5
diff --git a/CLAUDE.md b/CLAUDE.md
index b556ee40a..92c74dbff 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -104,6 +104,9 @@ OpenWhispr is an Electron-based desktop dictation application that uses whisper.
- **whisper.js**: Local whisper.cpp integration and model management
- **parakeet.js**: NVIDIA Parakeet model management via sherpa-onnx
- **parakeetServer.js**: sherpa-onnx CLI wrapper for transcription
+- **qdrantManager.js**: Qdrant vector DB sidecar process lifecycle (spawn, health check, shutdown)
+- **localEmbeddings.js**: Local text embedding via ONNX Runtime + all-MiniLM-L6-v2 (384-dim vectors)
+- **vectorIndex.js**: Qdrant collection management — upsert, delete, search, batch reindex
- **windowConfig.js**: Centralized window configuration
- **windowManager.js**: Window creation and lifecycle management
@@ -161,6 +164,33 @@ OpenWhispr is an Electron-based desktop dictation application that uses whisper.
- **Download URLs**: Models from sherpa-onnx ASR models release on GitHub
+### Local Semantic Search (Qdrant + MiniLM)
+
+Offline semantic search that finds notes by meaning, not just keywords. Gated behind a settings toggle (Settings → Privacy & Data → Local Semantic Search). Only used by the AI agent's `search_notes` tool — not the manual note search UI.
+
+**Architecture**:
+- **Qdrant sidecar**: Rust binary spawned as child process (`qdrantManager.js`), port 6333–6350
+- **Embedding model**: `all-MiniLM-L6-v2` via ONNX Runtime (`localEmbeddings.js`), 384-dim vectors
+- **Vector index**: Qdrant collection management (`vectorIndex.js`), cosine distance
+- **Hybrid search**: FTS5 + Qdrant in parallel → Reciprocal Rank Fusion (K=60) with 0.3 cosine score threshold
+
+**Pipeline**:
+1. User enables toggle → `semantic-search-enable` IPC → starts Qdrant → reindexes all notes
+2. Note create/update/delete → SQLite write → background vector upsert/delete via `_asyncVectorUpsert()`/`_asyncVectorDelete()`
+3. Agent searches → `db-semantic-search-notes` IPC → parallel FTS5 + vector search → RRF merge → ranked results
+
+**Search fallback chain** (in `searchNotesTool.ts`): cloud search → local semantic → FTS5 keyword
+
+**Storage**:
+- Qdrant data: `~/.cache/openwhispr/qdrant-data/`
+- Qdrant binary: `resources/bin/qdrant-{platform}-{arch}`
+- Embedding model: `~/.cache/openwhispr/embedding-models/all-MiniLM-L6-v2/`
+- Setting persisted as `LOCAL_SEMANTIC_SEARCH=true` in `.env`
+
+**Dependencies**: `@qdrant/js-client-rest`, `onnxruntime-node`
+
+**Dev setup**: Run `npm run download:qdrant` and `npm run download:embedding-model` before testing. The Qdrant binary is also downloaded automatically during `prebuild`.
+
### Build Scripts (scripts/)
- **download-whisper-cpp.js**: Downloads whisper.cpp binaries from GitHub releases
@@ -169,6 +199,8 @@ OpenWhispr is an Electron-based desktop dictation application that uses whisper.
- **download-windows-key-listener.js**: Downloads prebuilt Windows key listener binary
- **download-windows-mic-listener.js**: Downloads prebuilt Windows mic listener binary
- **download-sherpa-onnx.js**: Downloads sherpa-onnx binaries for Parakeet support
+- **download-qdrant.js**: Downloads Qdrant vector DB binary for local semantic search
+- **download-minilm.js**: Downloads all-MiniLM-L6-v2 ONNX model + tokenizer for local embeddings
- **build-globe-listener.js**: Compiles macOS Globe key listener from Swift source
- **build-macos-mic-listener.js**: Compiles macOS mic listener from Swift source
- **build-windows-key-listener.js**: Compiles Windows key listener (for local development)
@@ -240,10 +272,12 @@ Settings stored in localStorage with these keys:
- `hotkey`: Custom hotkey configuration
- `hasCompletedOnboarding`: Onboarding completion flag
- `customDictionary`: JSON array of words/phrases for improved transcription accuracy
+- `localSemanticSearchEnabled`: Boolean for local semantic search (Qdrant + MiniLM)
Environment variables persisted to `.env` (via `saveAllKeysToEnvFile()`):
- `LOCAL_TRANSCRIPTION_PROVIDER`: Transcription engine (`nvidia` for Parakeet)
- `PARAKEET_MODEL`: Selected Parakeet model name (e.g., `parakeet-tdt-0.6b-v3`)
+- `LOCAL_SEMANTIC_SEARCH`: Set to `true` to auto-start Qdrant sidecar on app launch
### 6. Language Support
@@ -520,7 +554,8 @@ const { t } = useTranslation();
2. **New Setting**: Update useSettings.ts and SettingsPage.tsx
3. **New UI Component**: Follow shadcn/ui patterns in src/components/ui
4. **New Manager**: Create in src/helpers/, initialize in main.js
-5. **New UI Strings**: Add translation keys to all 9 language files (see i18n section above)
+5. **New UI Strings**: Add translation keys to all 10 language files (see i18n section above)
+6. **New Sidecar Binary**: Add download script in `scripts/`, add to `prebuild*` scripts in package.json, add manager in `src/helpers/`, initialize in `main.js`, shutdown in `will-quit` handler
### Testing Checklist
@@ -539,6 +574,10 @@ const { t } = useTranslation();
- [ ] Verify meeting detection works with event-driven mode (check debug logs for "event-driven")
- [ ] Test meeting notification suppression during recording
- [ ] Test post-recording cooldown (notifications shouldn't flash immediately)
+- [ ] Enable local semantic search in Settings → Privacy & Data
+- [ ] Create a note about "quarterly revenue projections", search via agent for "financial forecast"
+- [ ] Disable local semantic search — verify Qdrant process stops
+- [ ] Verify FTS5 keyword search still works when semantic search is disabled
### Common Issues and Solutions
@@ -583,6 +622,15 @@ const { t } = useTranslation();
- Linux: Verify `pactl` is installed (`pulseaudio-utils` or `pipewire-pulse` package)
- If event-driven binary is missing, detection falls back to polling automatically
+7. **Local Semantic Search Not Working**:
+ - Run `npm run download:qdrant` to download the Qdrant binary for your platform
+ - Run `npm run download:embedding-model` to download the MiniLM ONNX model
+ - Check that `resources/bin/qdrant-{platform}-{arch}` exists
+ - Check that `~/.cache/openwhispr/embedding-models/all-MiniLM-L6-v2/model.onnx` exists
+ - Check debug logs for "qdrant" entries (port, health check, errors)
+ - If Qdrant fails to start, search still works via FTS5 keyword fallback
+ - Semantic search is only available through the AI agent's `search_notes` tool, not the manual search UI
+
### Platform-Specific Notes
**macOS**: