## Bug Fixes ### Note Card Actions - Fix broken size change functionality (missing state declaration) - Implement React 19 useOptimistic for instant UI feedback - Add startTransition for non-blocking updates - Ensure smooth animations without page refresh - All note actions now work: pin, archive, color, size, checklist ### Markdown LaTeX Rendering - Add remark-math and rehype-katex plugins - Support inline equations with dollar sign syntax - Support block equations with double dollar sign syntax - Import KaTeX CSS for proper styling - Equations now render correctly instead of showing raw LaTeX ## Technical Details - Replace undefined currentNote references with optimistic state - Add optimistic updates before server actions for instant feedback - Use router.refresh() in transitions for smart cache invalidation - Install remark-math, rehype-katex, and katex packages ## Testing - Build passes successfully with no TypeScript errors - Dev server hot-reloads changes correctly
53 lines
2.1 KiB
Markdown
53 lines
2.1 KiB
Markdown
# Story 3.1: Indexation Vectorielle Automatique
|
|
|
|
Status: ready-for-dev
|
|
|
|
## Story
|
|
|
|
As a system,
|
|
I want to generate and store vector embeddings for every note change,
|
|
So that the notes are searchable by meaning later.
|
|
|
|
## Acceptance Criteria
|
|
|
|
1. **Given** a Prisma schema.
|
|
2. **When** I run the migration.
|
|
3. **Then** the `Note` table has a field to store vectors (Unsupported type for Postgres/pgvector, or Blob/JSON for SQLite).
|
|
4. **Given** a note creation or update.
|
|
5. **When** the note is saved.
|
|
6. **Then** an embedding is generated via the AI Provider (`getEmbeddings`).
|
|
7. **And** the embedding is stored in the database asynchronously.
|
|
|
|
## Tasks / Subtasks
|
|
|
|
- [ ] Mise à jour du Schéma Prisma (AC: 1, 2, 3)
|
|
- [ ] Ajouter un champ `embedding` (Bytes ou String pour compatibilité SQLite/Postgres)
|
|
- [ ] `npx prisma migrate dev`
|
|
- [ ] Implémentation de la génération d'embeddings (AC: 4, 5, 6)
|
|
- [ ] Modifier `createNote` et `updateNote` dans `actions/notes.ts`
|
|
- [ ] Appeler `provider.getEmbeddings(content)`
|
|
- [ ] Sauvegarder le résultat
|
|
- [ ] Script de Backfill (Migration de données)
|
|
- [ ] Créer une action pour générer les embeddings des notes existantes
|
|
- [ ] Optimisation
|
|
- [ ] Ne pas régénérer l'embedding si le contenu n'a pas changé
|
|
|
|
## Dev Notes
|
|
|
|
- **Compatibilité DB :** Le projet utilise `sqlite` par défaut (`dev.db`). SQLite ne supporte pas nativement les vecteurs comme pgvector.
|
|
- **Solution :** Stocker les vecteurs sous forme de `String` (JSON) ou `Bytes` dans SQLite.
|
|
- **Recherche :** Pour le MVP local, nous ferons la recherche par similarité cosinus **en mémoire** (JavaScript) ou via une extension SQLite (comme `sqlite-vss`) si possible sans trop de complexité.
|
|
- **Choix BMad :** Stockage JSON String pour simplicité maximale et compatibilité. Calcul de similarité en JS (rapide pour < 1000 notes).
|
|
- **Performance :** L'appel `getEmbeddings` peut être lent. Il ne doit pas bloquer l'UI.
|
|
- Utiliser `waitUntil` (Next.js) ou ne pas `await` la promesse d'embedding dans la réponse UI.
|
|
|
|
## Dev Agent Record
|
|
|
|
### Agent Model Used
|
|
|
|
### Debug Log References
|
|
|
|
### Completion Notes List
|
|
|
|
### File List
|