Remove hard timeouts and fallback paths in chat flow

This commit is contained in:
Ruslan Bakiev
2026-02-20 10:05:33 +07:00
parent d49b00d688
commit b3602d142e
10 changed files with 49 additions and 99 deletions

View File

@@ -69,24 +69,7 @@ export async function getAuthContext(event: H3Event): Promise<AuthContext> {
});
if (!conv) {
// Recover from stale conversation cookie after rebuild/reset:
// reuse latest available conversation (or recreate default one) and refresh cookie.
const fallback =
(await prisma.chatConversation.findFirst({
where: { teamId: team.id, createdByUserId: user.id },
orderBy: { updatedAt: "desc" },
})) ||
(await prisma.chatConversation.create({
data: { id: `pilot-${team.id}`, teamId: team.id, createdByUserId: user.id, title: "Pilot" },
}));
setSession(event, {
teamId: team.id,
userId: user.id,
conversationId: fallback.id,
});
return { teamId: team.id, userId: user.id, conversationId: fallback.id };
throw createError({ statusCode: 401, statusMessage: "Unauthorized" });
}
return { teamId: team.id, userId: user.id, conversationId: conv.id };