adds the ability to rename chats

This commit is contained in:
2026-05-28 22:22:55 -07:00
parent f79e5e02c5
commit cb8ea935fa
10 changed files with 455 additions and 59 deletions

View File

@@ -754,9 +754,13 @@ export async function registerRoutes(app: FastifyInstance) {
const suggestedRaw = await generateChatTitle(body.content);
const title = normalizeSuggestedTitle(suggestedRaw, fallback);
const chat = await prisma.chat.update({
where: { id: body.chatId },
await prisma.chat.updateMany({
where: { id: body.chatId, title: existing.title },
data: { title },
});
const chat = await prisma.chat.findUnique({
where: { id: body.chatId },
select: {
id: true,
title: true,
@@ -768,6 +772,7 @@ export async function registerRoutes(app: FastifyInstance) {
lastUsedModel: true,
},
});
if (!chat) return app.httpErrors.notFound("chat not found");
return { chat: serializeProviderFields(chat) };
});