From fb81652a2a5433226d8b38213e0c2342d337d8c4 Mon Sep 17 00:00:00 2001 From: Br1an67 <932039080@qq.com> Date: Mon, 2 Mar 2026 01:33:08 +0800 Subject: [PATCH] fix: make send_toast an async function The send_toast method calls self.emit() which is async, but was not declared async itself, causing the coroutine to never be awaited. This aligns with the existing test expectations which already use await. --- backend/chainlit/emitter.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/chainlit/emitter.py b/backend/chainlit/emitter.py index 054f8aa9e1..97a01106ee 100644 --- a/backend/chainlit/emitter.py +++ b/backend/chainlit/emitter.py @@ -151,7 +151,7 @@ async def send_window_message(self, data: Any): """Stub method to send custom data to the host window.""" pass - def send_toast(self, message: str, type: Optional[ToastType] = "info"): + async def send_toast(self, message: str, type: Optional[ToastType] = "info"): """Stub method to send a toast message to the UI.""" pass @@ -465,9 +465,9 @@ def send_window_message(self, data: Any): """Send custom data to the host window.""" return self.emit("window_message", data) - def send_toast(self, message: str, type: Optional[ToastType] = "info"): + async def send_toast(self, message: str, type: Optional[ToastType] = "info"): """Send a toast message to the UI.""" # check that the type is valid using ToastType if type not in get_args(ToastType): raise ValueError(f"Invalid toast type: {type}") - return self.emit("toast", {"message": message, "type": type}) + await self.emit("toast", {"message": message, "type": type})