From 6f2b0279ff0f800c894d2a76cb2f2a2c5cf729d9 Mon Sep 17 00:00:00 2001 From: sepehr Date: Tue, 28 Apr 2026 22:24:05 +0200 Subject: [PATCH] fix: wrong title suggestion API URL (404) + per-note history check Co-Authored-By: Claude Opus 4.7 --- memento-note/app/actions/title-suggestions.ts | 9 ++++++--- memento-note/components/note-inline-editor.tsx | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/memento-note/app/actions/title-suggestions.ts b/memento-note/app/actions/title-suggestions.ts index 41dff0e..a55c58f 100644 --- a/memento-note/app/actions/title-suggestions.ts +++ b/memento-note/app/actions/title-suggestions.ts @@ -4,7 +4,7 @@ import { auth } from '@/auth' import { titleSuggestionService } from '@/lib/ai/services/title-suggestion.service' import { prisma } from '@/lib/prisma' import { revalidatePath } from 'next/cache' -import { createNoteHistorySnapshot, isNoteHistoryEnabledForUser } from '@/lib/note-history' +import { createNoteHistorySnapshot } from '@/lib/note-history' export interface GenerateTitlesResponse { suggestions: Array<{ @@ -84,8 +84,11 @@ export async function applyTitleSuggestion( }) try { - const historyEnabled = await isNoteHistoryEnabledForUser(session.user.id) - if (historyEnabled) { + const note = await prisma.note.findUnique({ + where: { id: noteId, userId: session.user.id }, + select: { historyEnabled: true }, + }) + if (note?.historyEnabled) { await createNoteHistorySnapshot({ noteId, userId: session.user.id, diff --git a/memento-note/components/note-inline-editor.tsx b/memento-note/components/note-inline-editor.tsx index 2470aed..f464b10 100644 --- a/memento-note/components/note-inline-editor.tsx +++ b/memento-note/components/note-inline-editor.tsx @@ -676,7 +676,7 @@ export function NoteInlineEditor({ e.preventDefault() setIsProcessingAI(true) try { - const res = await fetch('/api/ai/suggest-title', { + const res = await fetch('/api/ai/title-suggestions', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ content }),