Merge pull request #16284 from silentoplayz/fix-clone-chat-tags

fix: also clone the chat's tags, folder stats, and pinned status when cloning a chat
This commit is contained in:
Tim Jaeryang Baek 2025-08-06 14:33:04 +04:00 committed by GitHub
commit 1ba8c3389e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 3 deletions

View File

@ -296,6 +296,9 @@ class ChatTable:
"user_id": f"shared-{chat_id}", "user_id": f"shared-{chat_id}",
"title": chat.title, "title": chat.title,
"chat": chat.chat, "chat": chat.chat,
"meta": chat.meta,
"pinned": chat.pinned,
"folder_id": chat.folder_id,
"created_at": chat.created_at, "created_at": chat.created_at,
"updated_at": int(time.time()), "updated_at": int(time.time()),
} }
@ -327,7 +330,9 @@ class ChatTable:
shared_chat.title = chat.title shared_chat.title = chat.title
shared_chat.chat = chat.chat shared_chat.chat = chat.chat
shared_chat.meta = chat.meta
shared_chat.pinned = chat.pinned
shared_chat.folder_id = chat.folder_id
shared_chat.updated_at = int(time.time()) shared_chat.updated_at = int(time.time())
db.commit() db.commit()
db.refresh(shared_chat) db.refresh(shared_chat)

View File

@ -617,7 +617,18 @@ async def clone_chat_by_id(
"title": form_data.title if form_data.title else f"Clone of {chat.title}", "title": form_data.title if form_data.title else f"Clone of {chat.title}",
} }
chat = Chats.insert_new_chat(user.id, ChatForm(**{"chat": updated_chat})) chat = Chats.import_chat(
user.id,
ChatImportForm(
**{
"chat": updated_chat,
"meta": chat.meta,
"pinned": chat.pinned,
"folder_id": chat.folder_id,
}
),
)
return ChatResponse(**chat.model_dump()) return ChatResponse(**chat.model_dump())
else: else:
raise HTTPException( raise HTTPException(
@ -646,7 +657,17 @@ async def clone_shared_chat_by_id(id: str, user=Depends(get_verified_user)):
"title": f"Clone of {chat.title}", "title": f"Clone of {chat.title}",
} }
chat = Chats.insert_new_chat(user.id, ChatForm(**{"chat": updated_chat})) chat = Chats.import_chat(
user.id,
ChatImportForm(
**{
"chat": updated_chat,
"meta": chat.meta,
"pinned": chat.pinned,
"folder_id": chat.folder_id,
}
),
)
return ChatResponse(**chat.model_dump()) return ChatResponse(**chat.model_dump())
else: else:
raise HTTPException( raise HTTPException(