This commit is contained in:
Timothy Jaeryang Baek committed 2026-07-11 23:33:10 -05:00
1 parent 10ecaae589
commit ba32b68412
7 files changed
+201 -40

No files matched your search

+26
View File
@@ -381,6 +381,17 @@ def start_task(
)
_tasks[message_id] = task
_task_chat[message_id] = chat_id
asyncio.create_task(
emit_to_user(
user_id,
{
"type": "chat:active",
"chat_id": chat_id,
"workspace": workspace,
"active": True,
},
)
)
async def cancel_task(message_id: str) -> bool:
@@ -2625,6 +2636,21 @@ async def run_chat_task(
_tasks.pop(message_id, None)
_task_state.pop(message_id, None)
_task_chat.pop(message_id, None)
if chat_id not in get_active_chat_ids():
try:
chat = await Chat.get_by_id(chat_id)
await emit_to_user(
user_id,
{
"type": "chat:active",
"chat_id": chat_id,
"workspace": workspace,
"active": False,
"updated_at": chat.updated_at if chat else None,
},
)
except Exception:
logger.debug("[task %s] active-state emit failed", message_id[:8], exc_info=True)
try:
await export_chat_to_file(chat_id)
except Exception: