feat: hierarchical notebook system - trash, selectors, breadcrumb, sidebar tree
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 2m9s

- Schema: soft delete with trashedAt on Notebook model
- API: PATCH/GET notebooks support trashedAt filtering with cascade
- Sidebar: recursive tree rendering with collapse/expand, visual guides, hover actions
- HierarchicalNotebookSelector: portal-based dropdown with search, breadcrumbs, dropUp support
- AI chat: context selector with Toutes mes notes + notebook selector
- Agent detail: flat selects replaced with HierarchicalNotebookSelector
- Breadcrumb: notebook path display on home page
- Trash view: card grid with countdown, restore/permanent delete
- CSS: design tokens (ink, paper, blueprint, concrete, etc.)
- Types: parentId, trashedAt added to Notebook interface
This commit is contained in:
Antigravity
2026-05-10 10:52:26 +00:00
parent 539c72cf6d
commit 916fb78dfb
20 changed files with 1319 additions and 391 deletions

View File

@@ -1053,7 +1053,6 @@ export async function emptyTrash() {
if (!session?.user?.id) throw new Error('Unauthorized');
try {
// Fetch trashed notes with images before deleting
const trashedNotes = await prisma.note.findMany({
where: {
userId: session.user.id,
@@ -1069,7 +1068,6 @@ export async function emptyTrash() {
}
})
// Clean up image files for all deleted notes
for (const note of trashedNotes) {
const imageUrls = parseImageUrls(note.images)
if (imageUrls.length > 0) {
@@ -1077,6 +1075,13 @@ export async function emptyTrash() {
}
}
await prisma.notebook.deleteMany({
where: {
userId: session.user.id,
trashedAt: { not: null }
}
})
await syncLabels(session.user.id, [])
revalidatePath('/trash')
revalidatePath('/')
@@ -1137,14 +1142,44 @@ export async function getTrashCount() {
if (!session?.user?.id) return 0;
try {
return await prisma.note.count({
const [noteCount, notebookCount] = await Promise.all([
prisma.note.count({
where: {
userId: session.user.id,
trashedAt: { not: null }
}
}),
prisma.notebook.count({
where: {
userId: session.user.id,
trashedAt: { not: null }
}
})
])
return noteCount + notebookCount
} catch {
return 0
}
}
export async function getTrashedNotebooks() {
const session = await auth();
if (!session?.user?.id) return [];
try {
return await prisma.notebook.findMany({
where: {
userId: session.user.id,
trashedAt: { not: null }
}
},
include: {
_count: { select: { notes: true } }
},
orderBy: { trashedAt: 'desc' }
})
} catch {
return 0
} catch (error) {
console.error('Error fetching trashed notebooks:', error)
return []
}
}