refactor(agent): optimize ULID id sorting and exclude __CHAT__ placeholder comments

This commit is contained in:
yiling
2026-07-29 14:59:48 +08:00
parent a756f7dc2a
commit 1c7a87488b
4 changed files with 41 additions and 6 deletions
+3 -3
View File
@@ -547,14 +547,14 @@ export async function initializeAgentSessionActivity(params: {
})
}
// 1. Fetch top-level comments up to rootComment.createdAt
// 1. Fetch top-level comments up to rootComment.createdAt sorted by id
const topLevelComments = await prisma.assetComment.findMany({
where: {
assetId: userComment.assetId,
replyToId: null,
createdAt: { lte: rootComment.createdAt },
},
orderBy: { createdAt: 'asc' },
orderBy: { id: 'asc' },
include: { creator: true },
})
@@ -566,7 +566,7 @@ export async function initializeAgentSessionActivity(params: {
createdAt: { lte: userComment.createdAt },
id: { not: userComment.id },
},
orderBy: { createdAt: 'asc' },
orderBy: { id: 'asc' },
include: { creator: true },
})
: []