diff --git a/src/webui/components/browser_use_agent_tab.py b/src/webui/components/browser_use_agent_tab.py index a488e70..b51a166 100644 --- a/src/webui/components/browser_use_agent_tab.py +++ b/src/webui/components/browser_use_agent_tab.py @@ -632,11 +632,8 @@ async def run_agent_task( last_chat_len = len(webui_manager.bu_chat_history) yield update_dict # Wait until response is submitted or task finishes - while ( - webui_manager.bu_response_event is not None - and not agent_task.done() - ): - await asyncio.sleep(0.2) + await webui_manager.bu_response_event.wait() + # Restore UI after response submitted or if task ended unexpectedly if not agent_task.done(): yield { @@ -1071,7 +1068,7 @@ def create_browser_use_agent_tab(webui_manager: WebuiManager): # --- Connect Event Handlers using the Wrappers -- run_button.click( - fn=submit_wrapper, inputs=all_managed_components, outputs=run_tab_outputs + fn=submit_wrapper, inputs=all_managed_components, outputs=run_tab_outputs, trigger_mode="multiple" ) user_input.submit( fn=submit_wrapper, inputs=all_managed_components, outputs=run_tab_outputs