Skip to content

Commit 4777795

Browse files
committed
fix: ensure prior message attachments are fetched based on owning thread
1 parent 63c77db commit 4777795

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

  • apps/chat/src/app/api/chatbots/[chatbotId]/chat

apps/chat/src/app/api/chatbots/[chatbotId]/chat/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,12 +999,13 @@ export async function POST(
999999
m.role === 'user' && !(imageDescription && m.id === lastMessage?.id) // skip current
10001000
)
10011001
.map((m) => m.id)
1002-
if (priorMessageIds.length > 0) {
1002+
if (owningThread && priorMessageIds.length > 0) {
10031003
try {
10041004
const priorAttachments = await prisma.chatAttachment.findMany({
10051005
where: {
10061006
messageId: { in: priorMessageIds },
10071007
imageDescription: { not: null },
1008+
message: { threadId: owningThread.id },
10081009
},
10091010
select: { messageId: true, imageDescription: true },
10101011
})

0 commit comments

Comments
 (0)