fix: improve note interactions and markdown LaTeX support
## 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
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
# 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
|
||||
@@ -0,0 +1,47 @@
|
||||
# Story 3.2: Recherche Sémantique par Intention
|
||||
|
||||
Status: ready-for-dev
|
||||
|
||||
## Story
|
||||
|
||||
As a user,
|
||||
I want to search for notes using natural language concepts,
|
||||
So that I can find information even if I don't remember the exact words.
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
1. **Given** a search query in the search bar.
|
||||
2. **When** the search is executed.
|
||||
3. **Then** the system generates an embedding for the query via the AI Provider.
|
||||
4. **And** the system calculates the cosine similarity between the query embedding and all note embeddings in memory.
|
||||
5. **And** notes with high similarity (e.g., > 0.7) are returned even without keyword matches.
|
||||
|
||||
## Tasks / Subtasks
|
||||
|
||||
- [ ] Implémentation de la fonction de Similarité Cosinus (AC: 4)
|
||||
- [ ] Créer une fonction utilitaire `cosineSimilarity(vecA, vecB)`
|
||||
- [ ] Mise à jour de `searchNotes` dans `actions/notes.ts` (AC: 1, 2, 3, 4)
|
||||
- [ ] Générer l'embedding de la requête utilisateur
|
||||
- [ ] Récupérer toutes les notes avec leurs embeddings
|
||||
- [ ] Calculer le score sémantique pour chaque note
|
||||
- [ ] Logique de Ranking (AC: 5)
|
||||
- [ ] Filtrer les résultats par un seuil de similarité
|
||||
- [ ] Trier par score décroissant
|
||||
- [ ] Optimisation
|
||||
- [ ] Mettre en cache les embeddings des notes en mémoire pour éviter le parsing JSON répétitif
|
||||
|
||||
## Dev Notes
|
||||
|
||||
- **Algorithme :** La similarité cosinus est le produit scalaire divisé par le produit des normes.
|
||||
- **Hybridité :** Cette story se concentre sur la partie sémantique. La story 3.3 s'occupera de la fusion propre avec la recherche textuelle (SQL LIKE).
|
||||
- **Performance :** Le calcul de similarité pour 1000 notes prend environ 1ms en JS.
|
||||
|
||||
## Dev Agent Record
|
||||
|
||||
### Agent Model Used
|
||||
|
||||
### Debug Log References
|
||||
|
||||
### Completion Notes List
|
||||
|
||||
### File List
|
||||
@@ -37,9 +37,9 @@ development_status:
|
||||
2-3-validation-des-suggestions-par-l-utilisateur: backlog
|
||||
epic-2-retrospective: optional
|
||||
|
||||
epic-3: backlog
|
||||
3-1-indexation-vectorielle-automatique: backlog
|
||||
3-2-recherche-semantique-par-intention: backlog
|
||||
epic-3: in-progress
|
||||
3-1-indexation-vectorielle-automatique: done
|
||||
3-2-recherche-semantique-par-intention: in-progress
|
||||
3-3-vue-de-recherche-hybride: backlog
|
||||
epic-3-retrospective: optional
|
||||
|
||||
|
||||
Reference in New Issue
Block a user