@@ -5,7 +5,7 @@ import { generateTitleFromUserMessage } from '~/app/(main)/projects/[project]/ch
55import { generateUUID } from '~/components/chat/utils' ;
66import { getChatSystemPrompt , getModelInstance } from '~/lib/ai/agent' ;
77import { getTools } from '~/lib/ai/tools' ;
8- import { deleteChatById , getChatById , getChats , saveMessages , updateChat } from '~/lib/db/chats' ;
8+ import { deleteChatById , getChatById , getChatsByProject , saveMessages , updateChat } from '~/lib/db/chats' ;
99import { getConnection } from '~/lib/db/connections' ;
1010import { getUserSessionDBAccess } from '~/lib/db/db' ;
1111import { getProjectById } from '~/lib/db/projects' ;
@@ -16,11 +16,18 @@ export const maxDuration = 60;
1616
1717export async function GET ( request : NextRequest ) {
1818 const { searchParams } = new URL ( request . url ) ;
19+
20+ const project = searchParams . get ( 'project' ) ;
21+ if ( ! project ) {
22+ return new Response ( 'Project is required' , { status : 400 } ) ;
23+ }
24+
1925 const limit = parseInt ( searchParams . get ( 'limit' ) || '10' , 10 ) ;
26+ const offset = parseInt ( searchParams . get ( 'offset' ) || '0' , 10 ) ;
2027
2128 const dbAccess = await getUserSessionDBAccess ( ) ;
2229
23- const chats = await getChats ( dbAccess , { limit } ) ;
30+ const chats = await getChatsByProject ( dbAccess , { project , limit, offset } ) ;
2431
2532 return Response . json ( { chats } ) ;
2633}
0 commit comments