Keep/_bmad-output/implementation-artifacts/3-2-recherche-semantique-par-intention.md
sepehr 640fcb26f7 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
2026-01-09 22:13:49 +01:00

1.7 KiB

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