feat: brainstorm sessions, PDF document Q&A, embedding fixes, and UI improvements
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 7s
All checks were successful
Deploy to Production / Build and Deploy (push) Successful in 7s
- Add brainstorm feature with collaborative canvas, AI idea generation, live cursors, playback, and export - Add PDF upload/extraction/ingestion pipeline with pgvector document search (RAG) - Add document Q&A overlay with streaming chat and PDF preview - Add note attachments UI with status polling, grid layout, and auto-scroll - Add task extraction AI tool and agent executor improvements - Fix NoteEmbedding missing updatedAt column, re-index 66 notes with 1536-dim embeddings - Fix brainstorm 'Create Note' button: add success toast and redirect to created note - Fix memory echo notification infinite polling - Fix chat route to always include document_search tool - Add brainstorm i18n keys across all 14 locales - Add socket server for real-time brainstorm collaboration - Add hierarchical notebook selector and organize notebook dialog improvements - Add sidebar brainstorm section with session management - Update prisma schema with brainstorm tables, attachments, and document chunks
This commit is contained in:
126
architectural-grid11/server.ts
Normal file
126
architectural-grid11/server.ts
Normal file
@@ -0,0 +1,126 @@
|
||||
import express from "express";
|
||||
import path from "path";
|
||||
import { createServer as createViteServer } from "vite";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
interface BrainstormIdea {
|
||||
id: string;
|
||||
sessionId: string;
|
||||
waveNumber: number;
|
||||
title: string;
|
||||
description: string;
|
||||
connectionToSeed: string;
|
||||
noveltyScore: number;
|
||||
parentIdeaId?: string;
|
||||
convertedToNoteId?: string;
|
||||
status: 'active' | 'dismissed' | 'converted';
|
||||
position?: { x: number; y: number };
|
||||
}
|
||||
|
||||
interface BrainstormSession {
|
||||
id: string;
|
||||
seedIdea: string;
|
||||
sourceNoteId?: string;
|
||||
contextNoteIds?: string[];
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
// In-memory store (Simulating Postgres for now)
|
||||
const sessions: BrainstormSession[] = [];
|
||||
const ideas: BrainstormIdea[] = [];
|
||||
|
||||
async function startServer() {
|
||||
const app = express();
|
||||
const PORT = 3000;
|
||||
|
||||
app.use(express.json());
|
||||
|
||||
// API Routes
|
||||
app.get("/api/health", (req, res) => {
|
||||
res.json({ status: "ok" });
|
||||
});
|
||||
|
||||
// 1. Create session
|
||||
app.post("/api/brainstorm/sessions", (req, res) => {
|
||||
const { seedIdea, sourceNoteId, contextNoteIds } = req.body;
|
||||
|
||||
const session: BrainstormSession = {
|
||||
id: uuidv4(),
|
||||
seedIdea,
|
||||
sourceNoteId,
|
||||
contextNoteIds,
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString()
|
||||
};
|
||||
sessions.unshift(session);
|
||||
res.json(session);
|
||||
});
|
||||
|
||||
// 2. Add ideas to session
|
||||
app.post("/api/brainstorm/:sessionId/ideas", (req, res) => {
|
||||
const { sessionId } = req.params;
|
||||
const { ideas: newIdeasData } = req.body;
|
||||
|
||||
const session = sessions.find(s => s.id === sessionId);
|
||||
if (!session) return res.status(404).json({ error: "Session not found" });
|
||||
|
||||
const newIdeas = newIdeasData.map((item: any) => ({
|
||||
id: item.id || uuidv4(),
|
||||
sessionId,
|
||||
waveNumber: item.waveNumber,
|
||||
title: item.title,
|
||||
description: item.description,
|
||||
connectionToSeed: item.connectionToSeed,
|
||||
noveltyScore: item.noveltyScore,
|
||||
parentIdeaId: item.parentIdeaId,
|
||||
status: 'active'
|
||||
}));
|
||||
|
||||
newIdeas.forEach((i: any) => ideas.push(i));
|
||||
res.json(newIdeas);
|
||||
});
|
||||
|
||||
// 3. Get all sessions
|
||||
app.get("/api/brainstorm/sessions", (req, res) => {
|
||||
res.json(sessions);
|
||||
});
|
||||
|
||||
// 4. Get session with ideas
|
||||
app.get("/api/brainstorm/:sessionId", (req, res) => {
|
||||
const session = sessions.find(s => s.id === req.params.sessionId);
|
||||
if (!session) return res.status(404).json({ error: "Session not found" });
|
||||
const sessionIdeas = ideas.filter(i => i.sessionId === session.id);
|
||||
res.json({ session, ideas: sessionIdeas });
|
||||
});
|
||||
|
||||
// 5. Update idea (position, status)
|
||||
app.patch("/api/brainstorm/ideas/:ideaId", (req, res) => {
|
||||
const index = ideas.findIndex(i => i.id === req.params.ideaId);
|
||||
if (index === -1) return res.status(404).json({ error: "Idea not found" });
|
||||
|
||||
ideas[index] = { ...ideas[index], ...req.body };
|
||||
res.json(ideas[index]);
|
||||
});
|
||||
|
||||
// Vite middleware for development
|
||||
if (process.env.NODE_ENV !== "production") {
|
||||
const vite = await createViteServer({
|
||||
server: { middlewareMode: true },
|
||||
appType: "spa",
|
||||
});
|
||||
app.use(vite.middlewares);
|
||||
} else {
|
||||
const distPath = path.join(process.cwd(), 'dist');
|
||||
app.use(express.static(distPath));
|
||||
app.get('*', (req, res) => {
|
||||
res.sendFile(path.join(distPath, 'index.html'));
|
||||
});
|
||||
}
|
||||
|
||||
app.listen(PORT, "0.0.0.0", () => {
|
||||
console.log(`Server running on http://localhost:${PORT}`);
|
||||
});
|
||||
}
|
||||
|
||||
startServer();
|
||||
Reference in New Issue
Block a user