feat(chat): add AgentSessionType enum and filter chatbot history sessions

This commit is contained in:
yiling
2026-07-11 20:14:40 +08:00
parent 94a3ec0b9b
commit b5d52a4e56
10 changed files with 151 additions and 6 deletions
+12 -1
View File
@@ -202,7 +202,7 @@ describe('ChatService', () => {
expect(taskPayload?.agent?.imageUrls).toContain('doc_s3_key')
})
it('should list sessions of a user', async () => {
it('should list sessions of a user and only return chat type sessions', async () => {
const { user, project } = await setupBasicData()
await chatService.startOrContinueChat(user, {
@@ -215,6 +215,17 @@ describe('ChatService', () => {
projectId: project.id,
})
// Create a comment type session (which should be ignored by listSessions)
const defaultAgent = await prisma.agent.findFirst()
await prisma.agentSession.create({
data: {
agentId: defaultAgent ? defaultAgent.id : 'default',
userId: user.id,
cwd: process.cwd(),
type: 'comment',
},
})
const list = await chatService.listSessions(user.id, { first: 10 })
expect(list.data).toHaveLength(2)
})
+2
View File
@@ -278,6 +278,7 @@ export class ChatService {
userId: user.id,
cwd: process.cwd(),
assetId: asset.id,
type: 'chat',
},
})
activeSessionId = newSession.id
@@ -319,6 +320,7 @@ export class ChatService {
): Promise<PaginatedData<ChatSessionInfo[]>> {
const where: Prisma.AgentSessionWhereInput = {
userId,
type: 'chat',
}
return await paginateQuery(