From 43f73a2ec7b92ec2a52fe493f83c4a4ec2ac8fe3 Mon Sep 17 00:00:00 2001 From: sepehr Date: Thu, 30 Apr 2026 18:47:41 +0200 Subject: [PATCH] fix: auto-generated title not visible in tabs view after note creation The sync effect in notes-tabs-view was always preferring local.title over fresh.title from the DB. When a note was created with an AI-generated title, triggerRefresh() fetched the note with its title from DB, but the merge overwrote it with the empty local title. Now uses local.title || fresh.title so fresh titles show through when local is empty. Co-Authored-By: Claude Opus 4.7 --- memento-note/components/notes-tabs-view.tsx | 28 +++++++++------------ 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/memento-note/components/notes-tabs-view.tsx b/memento-note/components/notes-tabs-view.tsx index 82c20a6..7087af8 100644 --- a/memento-note/components/notes-tabs-view.tsx +++ b/memento-note/components/notes-tabs-view.tsx @@ -613,31 +613,27 @@ export function NotesTabsView({ setItems((prev) => { const prevIds = prev.map((n) => n.id).join(',') const incomingIds = notes.map((n) => n.id).join(',') + const merge = (fresh: Note, local: Note) => { + const labelsChanged = JSON.stringify(fresh.labels?.sort()) !== JSON.stringify(local.labels?.sort()) + return { + ...fresh, + title: local.title || fresh.title, + content: local.content, + checkItems: local.checkItems, + labels: labelsChanged ? fresh.labels : local.labels + } + } if (prevIds === incomingIds) { return prev.map((p) => { const fresh = notes.find((n) => n.id === p.id) if (!fresh) return p - const labelsChanged = JSON.stringify(fresh.labels?.sort()) !== JSON.stringify(p.labels?.sort()) - return { - ...fresh, - title: p.title, - content: p.content, - checkItems: p.checkItems, - labels: labelsChanged ? fresh.labels : p.labels - } + return merge(fresh, p) }) } return notes.map((fresh) => { const local = prev.find((p) => p.id === fresh.id) if (!local) return fresh - const labelsChanged = JSON.stringify(fresh.labels?.sort()) !== JSON.stringify(local.labels?.sort()) - return { - ...fresh, - title: local.title, - content: local.content, - checkItems: local.checkItems, - labels: labelsChanged ? fresh.labels : local.labels - } + return merge(fresh, local) }) }) }, [notes])