mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-25 00:39:25 +00:00
feat(chat): add AgentSessionType enum and filter chatbot history sessions
This commit is contained in:
@@ -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)
|
||||
})
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user