diff --git a/memento-note/app/actions/notes.ts b/memento-note/app/actions/notes.ts index b65cde0..1af17da 100644 --- a/memento-note/app/actions/notes.ts +++ b/memento-note/app/actions/notes.ts @@ -11,6 +11,7 @@ import { embeddingService } from '@/lib/ai/services/embedding.service' import { syncNoteLinksForNote } from '@/lib/notes/sync-note-links' import { getSystemConfig, getConfigNumber, getConfigBoolean, SEARCH_DEFAULTS } from '@/lib/config' import { contextualAutoTagService } from '@/lib/ai/services/contextual-auto-tag.service' +import { incrementUsageAsync } from '@/lib/entitlements' import { semanticSearchService } from '@/lib/ai/services/semantic-search.service' import { getAISettings } from '@/app/actions/ai-settings' import { @@ -508,6 +509,8 @@ export async function createNote(data: { } const merged = [...new Set([...existingNames, ...appliedLabels])] await syncNoteLabels(noteId, merged, notebookId ?? null, userId) + // Incrémenter le quota une seule fois par sauvegarde où des labels IA sont appliqués + incrementUsageAsync(userId, 'auto_tag') if (!data.skipRevalidation) { revalidatePath('/home') } diff --git a/memento-note/app/api/ai/tags/route.ts b/memento-note/app/api/ai/tags/route.ts index 6e40ef8..70eeeb2 100644 --- a/memento-note/app/api/ai/tags/route.ts +++ b/memento-note/app/api/ai/tags/route.ts @@ -83,7 +83,8 @@ export async function POST(req: NextRequest) { session.user.id, (provider) => provider.generateTags(content, language), ); - if (!usedByok) incrementUsageAsync(session.user.id, 'auto_tag'); + // Ne pas incrémenter ici — ce sont des suggestions UI (déclenchées à chaque keystroke) + // Le quota est compté uniquement lors de l'application réelle des labels (voir notes.ts) return NextResponse.json({ tags }); } catch (err) { console.error('[/api/ai/tags] legacy tagging failed:', err) diff --git a/memento-note/lib/entitlements.ts b/memento-note/lib/entitlements.ts index 7bc896b..352d80f 100644 --- a/memento-note/lib/entitlements.ts +++ b/memento-note/lib/entitlements.ts @@ -84,7 +84,7 @@ const TIER_LIMITS: Record }, PRO: { semantic_search: 100, - auto_tag: 200, + auto_tag: 500, auto_title: 200, reformulate: 50, chat: 50,