From aabb63f9471721cac4b35de77cf8760e213c2b19 Mon Sep 17 00:00:00 2001 From: debu-2 Date: Tue, 6 Oct 2026 01:57:15 +0530 Subject: [PATCH] backend fixes --- backend/app/routers/agent_handoff.py | 3 ++- backend/app/routers/threads.py | 6 ++++-- backend/app/services/human_handoff_service.py | 6 ++++-- frontend/src/components/DashboardPage.jsx | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/backend/app/routers/agent_handoff.py b/backend/app/routers/agent_handoff.py index 9845d3b..adaf7eb 100644 --- a/backend/app/routers/agent_handoff.py +++ b/backend/app/routers/agent_handoff.py @@ -255,7 +255,8 @@ async def get_handoff_conversation( }, {"$unwind": "$message"}, ] - rows = [row async for row in database.mailbox_entries.aggregate(pipeline)] + cursor = await database.mailbox_entries.aggregate(pipeline) + rows = [row async for row in cursor] human_email = handoff.get("human_email", "").lower() messages: list[HandoffMessageRead] = [] for row in rows: diff --git a/backend/app/routers/threads.py b/backend/app/routers/threads.py index ac5020f..dee18fe 100644 --- a/backend/app/routers/threads.py +++ b/backend/app/routers/threads.py @@ -214,7 +214,8 @@ async def list_threads( } } ) - rows = [row async for row in database.mailbox_entries.aggregate(pipeline)] + cursor = await database.mailbox_entries.aggregate(pipeline) + rows = [row async for row in cursor] has_more = len(rows) > limit rows = rows[:limit] items = [thread_summary_from_group(row, mailbox) for row in rows] @@ -298,7 +299,8 @@ async def get_thread( }, {"$unwind": "$message"}, ] - rows = [row async for row in database.mailbox_entries.aggregate(pipeline)] + cursor = await database.mailbox_entries.aggregate(pipeline) + rows = [row async for row in cursor] if not rows: raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Thread not found.") diff --git a/backend/app/services/human_handoff_service.py b/backend/app/services/human_handoff_service.py index f15f809..6fa04a8 100644 --- a/backend/app/services/human_handoff_service.py +++ b/backend/app/services/human_handoff_service.py @@ -136,7 +136,8 @@ async def _latest_external_message(database, account_id: str, external_thread_id }, {"$unwind": "$message"}, ] - rows = [row async for row in database.mailbox_entries.aggregate(pipeline)] + cursor = await database.mailbox_entries.aggregate(pipeline) + rows = [row async for row in cursor] return rows[0]["message"] if rows else None @@ -161,7 +162,8 @@ async def _latest_handoff_message(database, account_id: str, handoff_thread_id: }, {"$unwind": "$message"}, ] - rows = [row async for row in database.mailbox_entries.aggregate(pipeline)] + cursor = await database.mailbox_entries.aggregate(pipeline) + rows = [row async for row in cursor] return rows[0]["message"] if rows else None diff --git a/frontend/src/components/DashboardPage.jsx b/frontend/src/components/DashboardPage.jsx index 0d5cede..cd63445 100644 --- a/frontend/src/components/DashboardPage.jsx +++ b/frontend/src/components/DashboardPage.jsx @@ -62,10 +62,10 @@ const labels = [ ]; const agentItems = [ + [HandHelping, "Human Handoff", "handoff"], [Sparkles, "Ask Agent", "ask"], [ListChecks, "Action Items", "actions"], [Sparkles, "Summaries", "summaries"], - [HandHelping, "Human Handoff", "handoff"], [Plug, "Integrations", "integrations"], ];