diff --git a/src/pages/Index.tsx b/src/pages/Index.tsx index c83dff3..0a0164e 100644 --- a/src/pages/Index.tsx +++ b/src/pages/Index.tsx @@ -288,13 +288,9 @@ Keep tags concise, use lowercase, and separate words with hyphens if needed.`); addDebugInfo('Auto-generating tags...'); const tags = await generateTags(content, noteIndex); if (noteIndex !== undefined) { - // For existing notes - const note = noteCache[noteIndex]; - if (note) { - const updatedNote = { ...note, tags }; - setPreviousNote(updatedNote); - setIsPreviousNoteModified(true); - } + // For existing notes - preserve current content from state + setPreviousNote(prev => prev ? { ...prev, tags } : null); + setIsPreviousNoteModified(true); } else { // For current note setCurrentNoteTags(tags); @@ -303,7 +299,7 @@ Keep tags concise, use lowercase, and separate words with hyphens if needed.`); console.error('Auto tag generation failed:', error); } } - }, 200); + }, 300); setTagGenerationTimeout(timeout); }; @@ -2059,7 +2055,10 @@ ${content}${context}`; const updatedNote = { ...previousNote, content: newContent }; setPreviousNote(updatedNote); setIsPreviousNoteModified(true); - debouncedGenerateTags(newContent, currentNoteIndex); + // Debounced tag generation for previous notes + if (autoGenerateTags) { + debouncedGenerateTags(newContent, currentNoteIndex); + } if (newContent.trim() === '') { deleteNote(previousNote.id); }