fix: restore brainstorming feature with missing socket server and real-time events
This commit is contained in:
@@ -15,7 +15,9 @@ import {
|
||||
resolveAiContextUserId,
|
||||
sanitizeNotesForGuest,
|
||||
captureSnapshot,
|
||||
logActivity,
|
||||
} from '@/lib/brainstorm-collab'
|
||||
import { emitToSession } from '@/lib/socket-emit'
|
||||
|
||||
const expandSchema = z.object({
|
||||
ideaId: z.string().min(1),
|
||||
@@ -332,6 +334,17 @@ export async function POST(
|
||||
for (const idea of updatedSession?.ideas || []) { (idea as any).creator = (idea as any).createdBy ? cm.get((idea as any).createdBy) || null : null }
|
||||
}
|
||||
|
||||
await logActivity(sessionId, 'wave_generated', session.user.id, { count: newIdeas.length, parentIdeaId: ideaId })
|
||||
|
||||
await emitToSession(sessionId, 'activity:new', {
|
||||
action: 'wave_generated',
|
||||
userId: session.user.id,
|
||||
userName: session.user.name || 'Guest',
|
||||
details: { count: newIdeas.length, parentIdeaId: ideaId }
|
||||
})
|
||||
// Trigger refetch for all participants
|
||||
await emitToSession(sessionId, 'idea:added', {})
|
||||
|
||||
await captureSnapshot(sessionId, `Wave expanded: ${parentIdea.title}`).catch(() => {})
|
||||
|
||||
return NextResponse.json({ success: true, data: updatedSession })
|
||||
|
||||
Reference in New Issue
Block a user