Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion backend/chainlit/socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ async def resume_thread(session: WebsocketSession):
data_layer = get_data_layer()
if not data_layer or not session.user or not session.thread_id_to_resume:
return

if session.id not in user_sessions:
user_sessions[session.id] = {}

thread = await data_layer.get_thread(thread_id=session.thread_id_to_resume)
if not thread:
return
Expand All @@ -55,7 +59,17 @@ async def resume_thread(session: WebsocketSession):

if user_is_author:
metadata = thread.get("metadata") or {}
user_sessions[session.id] = metadata.copy()
if isinstance(metadata, str):
try:
metadata = json.loads(metadata)
except json.JSONDecodeError:
metadata = {}

if isinstance(metadata, dict):
user_sessions[session.id] = metadata.copy()
else:
user_sessions[session.id] = {}

if chat_profile := metadata.get("chat_profile"):
session.chat_profile = chat_profile
if chat_settings := metadata.get("chat_settings"):
Expand Down