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 <noreply@anthropic.com>
This commit is contained in:
2026-04-30 18:47:41 +02:00
parent d91072ed6b
commit 43f73a2ec7

View File

@@ -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])