feat: mobile app complet + flashcards fixes + drag handle améliorations
Some checks failed
CI / Lint, Unit Tests & Build (push) Failing after 1m32s
CI / Deploy production (on server) (push) Has been skipped

Mobile app:
- Révision flashcards : liste decks, session flip-card SM-2, couleurs harmonisées web
- Génération flashcards depuis note (FlashcardSheet + route /api/mobile/flashcards/generate)
- Audio Whisper : hook useAudioRecorder reécrit, MicButton avec erreurs
- IA : AISheet (améliorer/clarifier/résumer), TitleSheet (titre automatique)
- Suppression note (soft delete + confirmation Alert)
- Note du jour : titre lisible + HTML (plus JSON TipTap brut)
- Parser TipTap→HTML côté mobile (tipTapToHtml)
- Icône 🎓 dans header note → génération flashcards
- Endpoint flashcardGenerate dans config.ts

Web fixes:
- Bug flashcards groupées par carnet → deck par note (migration + schema)
- Bug filtre 'cartes dues' ignoré (suppression fallback buildSessionQueue)
- Suppression UI création deck manuelle (inutile)
- Fix setViewType is not defined dans home-client.tsx

Drag handle menu:
- Fix : clearNodes() avant transformation (heading→liste/code/citation)
- Ajout : option 'Texte' (paragraphe) dans Transformer en
- Ajout : Monter / Descendre le bloc
- Ajout : Copier le contenu du bloc
- Fix : sous-menu hover stable (délai 200ms)
- Fix : Supprimer en rouge via classe --danger (plus :first-child)
- i18n : nouvelles clés dans 15 locales

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Antigravity
2026-05-29 18:49:40 +00:00
parent 1121b8c345
commit 0fa8978395
54 changed files with 2648 additions and 245 deletions

View File

@@ -0,0 +1,41 @@
import { NextRequest, NextResponse } from 'next/server'
import { getMobileUserId } from '@/lib/mobile-auth'
import { paragraphRefactorService } from '@/lib/ai/services/paragraph-refactor.service'
import { checkEntitlementOrThrow, QuotaExceededError, incrementUsageAsync } from '@/lib/entitlements'
const MODE_MAP: Record<string, 'clarify' | 'shorten' | 'improveStyle' | 'fix_grammar'> = {
improve: 'improveStyle',
shorten: 'shorten',
clarify: 'clarify',
fix_grammar: 'fix_grammar',
}
export async function POST(req: NextRequest) {
const userId = getMobileUserId(req)
if (!userId) return NextResponse.json({ error: 'Non autorisé' }, { status: 401 })
const { text, mode = 'improve' } = await req.json().catch(() => ({}))
if (!text?.trim()) return NextResponse.json({ error: 'Texte requis' }, { status: 400 })
const refactorMode = MODE_MAP[mode]
if (!refactorMode) {
return NextResponse.json({ error: 'Mode invalide. Valeurs: improve, shorten, clarify, fix_grammar' }, { status: 400 })
}
const validation = paragraphRefactorService.validateWordCount(text)
if (!validation.valid) return NextResponse.json({ error: validation.error }, { status: 400 })
try {
await checkEntitlementOrThrow(userId, 'reformulate')
} catch (err) {
if (err instanceof QuotaExceededError) {
return NextResponse.json({ error: 'quota_exceeded' }, { status: 402 })
}
throw err
}
const result = await paragraphRefactorService.refactor(text, refactorMode, 'markdown', undefined)
incrementUsageAsync(userId, 'reformulate')
return NextResponse.json({ improved: result.refactored, original: result.original })
}

View File

@@ -0,0 +1,38 @@
import { NextRequest, NextResponse } from 'next/server'
import { getMobileUserId } from '@/lib/mobile-auth'
import { runLaneWithBillingUser } from '@/lib/ai/provider-for-user'
import { getSystemConfig } from '@/lib/config'
import { checkEntitlementOrThrow, QuotaExceededError, incrementUsageAsync } from '@/lib/entitlements'
export async function POST(req: NextRequest) {
const userId = getMobileUserId(req)
if (!userId) return NextResponse.json({ error: 'Non autorisé' }, { status: 401 })
const { content } = await req.json().catch(() => ({}))
if (!content?.trim()) return NextResponse.json({ error: 'Contenu requis' }, { status: 400 })
const wordCount = content.split(/\s+/).length
if (wordCount < 5) return NextResponse.json({ error: 'Contenu trop court (min 5 mots)' }, { status: 400 })
try {
await checkEntitlementOrThrow(userId, 'auto_title')
} catch (err) {
if (err instanceof QuotaExceededError) {
return NextResponse.json({ error: 'quota_exceeded' }, { status: 402 })
}
throw err
}
const config = await getSystemConfig()
const prompt = `Génère 3 titres concis pour ce texte. Réponds UNIQUEMENT avec un tableau JSON: [{"title":"titre1"},{"title":"titre2"},{"title":"titre3"}]\n\nTexte: ${content.slice(0, 400)}`
const { result: titles, usedByok } = await runLaneWithBillingUser(
'tags',
config,
userId,
(provider) => provider.generateTitles(prompt),
)
if (!usedByok) incrementUsageAsync(userId, 'auto_title')
return NextResponse.json({ suggestions: (titles ?? []).map((t: any) => t.title ?? t) })
}

View File

@@ -0,0 +1,40 @@
import { NextRequest, NextResponse } from 'next/server'
import { getMobileUserId } from '@/lib/mobile-auth'
import { getSystemConfig } from '@/lib/config'
export async function POST(req: NextRequest) {
const userId = getMobileUserId(req)
if (!userId) return NextResponse.json({ error: 'Non autorisé' }, { status: 401 })
const formData = await req.formData().catch(() => null)
if (!formData) return NextResponse.json({ error: 'Fichier audio requis' }, { status: 400 })
const file = formData.get('audio')
if (!file || !(file instanceof Blob)) {
return NextResponse.json({ error: 'Fichier audio manquant' }, { status: 400 })
}
const config = await getSystemConfig()
const apiKey = config.OPENAI_API_KEY
if (!apiKey) return NextResponse.json({ error: 'Service non disponible' }, { status: 503 })
const whisperForm = new FormData()
whisperForm.append('file', file, 'audio.m4a')
whisperForm.append('model', 'whisper-1')
whisperForm.append('response_format', 'json')
const whisperRes = await fetch('https://api.openai.com/v1/audio/transcriptions', {
method: 'POST',
headers: { Authorization: `Bearer ${apiKey}` },
body: whisperForm,
})
if (!whisperRes.ok) {
const err = await whisperRes.text()
console.error('[mobile/ai/transcribe] Whisper error:', err)
return NextResponse.json({ error: 'Erreur transcription' }, { status: 500 })
}
const { text } = await whisperRes.json()
return NextResponse.json({ text: text ?? '' })
}