feat(dashboard): tableau de bord Second Brain configurable avec chargement progressif
Briefing granulaire, pistes rapides puis enrichissement async, layout persisté v5, suggestions agents, intégration Gmail et navigation sidebar alignée sur /home. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -20,8 +20,54 @@ export async function GET(request: NextRequest) {
|
||||
|
||||
// Check for stored results (even if stale/périmés)
|
||||
const stored = await clusteringService.getStoredClusters(userId)
|
||||
const lite = request.nextUrl.searchParams.get('lite') === '1'
|
||||
|
||||
if (stored) {
|
||||
const cached = stored.clusters
|
||||
|
||||
if (lite) {
|
||||
const [bridgeNotesData, totalNotes] = await Promise.all([
|
||||
prisma.bridgeNote.findMany({
|
||||
where: { userId },
|
||||
orderBy: { bridgeScore: 'desc' },
|
||||
take: 5,
|
||||
select: { noteId: true, bridgeScore: true, clustersConnected: true },
|
||||
}),
|
||||
prisma.note.count({ where: { userId, trashedAt: null } }),
|
||||
])
|
||||
|
||||
let enrichedBridgeNotes: object[] = []
|
||||
if (bridgeNotesData.length > 0) {
|
||||
const bridgeNoteDetails = await prisma.note.findMany({
|
||||
where: { id: { in: bridgeNotesData.map(b => b.noteId) } },
|
||||
select: { id: true, title: true },
|
||||
})
|
||||
const bridgeNoteDetailsMap = new Map(bridgeNoteDetails.map(n => [n.id, n]))
|
||||
|
||||
enrichedBridgeNotes = bridgeNotesData.map(b => {
|
||||
const clustersConnected = JSON.parse(b.clustersConnected) as number[]
|
||||
return {
|
||||
noteId: b.noteId,
|
||||
bridgeScore: b.bridgeScore,
|
||||
clustersConnected,
|
||||
clusterNames: clustersConnected.map(
|
||||
cid => cached.find(c => c.clusterId === cid)?.name || `Cluster ${cid}`,
|
||||
),
|
||||
note: bridgeNoteDetailsMap.get(b.noteId),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
clusters: cached,
|
||||
bridgeNotes: enrichedBridgeNotes,
|
||||
cached: true,
|
||||
stale: stored.stale,
|
||||
lastCalculated: stored.lastCalculated,
|
||||
totalNotes,
|
||||
})
|
||||
}
|
||||
|
||||
// Fetch notes with their cluster assignments
|
||||
const notes = await prisma.note.findMany({
|
||||
where: { userId, trashedAt: null },
|
||||
|
||||
Reference in New Issue
Block a user