|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import gradio as gr |
|
|
|
|
|
def setup_mobile_event_handlers(demo, handlers, message_input, chatbot, session_info, |
|
|
show_reasoning, show_agent_trace, reasoning_display, |
|
|
performance_display, send_btn, mobile_navigation): |
|
|
""" |
|
|
Set up mobile-optimized event handlers |
|
|
NOTE: All UI components must be passed as parameters |
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
message_input.submit( |
|
|
fn=handlers.handle_mobile_submit, |
|
|
inputs=[message_input, chatbot, session_info, show_reasoning, show_agent_trace], |
|
|
outputs=[chatbot, message_input, reasoning_display, performance_display], |
|
|
queue=True, |
|
|
show_progress="minimal" |
|
|
) |
|
|
|
|
|
send_btn.click( |
|
|
fn=handlers.handle_mobile_submit, |
|
|
inputs=[message_input, chatbot, session_info, show_reasoning, show_agent_trace], |
|
|
outputs=[chatbot, message_input, reasoning_display, performance_display], |
|
|
queue=True, |
|
|
show_progress="minimal" |
|
|
) |
|
|
|
|
|
|
|
|
chat_nav_btn.click(lambda: ("chat_tab", False), None, [main_tabs, mobile_navigation]) |
|
|
details_nav_btn.click(lambda: ("details_tab", False), None, [main_tabs, mobile_navigation]) |
|
|
|
|
|
|
|
|
menu_toggle.click( |
|
|
lambda visible: not visible, |
|
|
settings.visible, |
|
|
settings.visible |
|
|
) |
|
|
|
|
|
return demo |
|
|
|
|
|
def is_mobile(): |
|
|
""" |
|
|
Detect if user is on mobile device (simplified) |
|
|
""" |
|
|
|
|
|
return False |
|
|
|
|
|
def setup_advanced_mobile_handlers(demo, handlers, performance_manager): |
|
|
""" |
|
|
Set up advanced mobile event handlers with performance optimization |
|
|
""" |
|
|
|
|
|
demo.keypress( |
|
|
("Enter", message_input), |
|
|
fn=handlers.handle_mobile_submit, |
|
|
inputs=[message_input, chatbot, session_info, show_reasoning, show_agent_trace], |
|
|
outputs=[chatbot, message_input, reasoning_display, performance_display], |
|
|
queue=True |
|
|
) |
|
|
|
|
|
|
|
|
new_session_btn.click( |
|
|
fn=lambda: str(uuid.uuid4())[:8], |
|
|
outputs=session_info |
|
|
) |
|
|
|
|
|
|
|
|
if is_mobile(): |
|
|
demo.load( |
|
|
fn=refresh_context, |
|
|
inputs=[session_info], |
|
|
outputs=[context_display], |
|
|
every=30 |
|
|
) |
|
|
|
|
|
return demo |
|
|
|
|
|
def refresh_context(session_id): |
|
|
""" |
|
|
Refresh session context for mobile |
|
|
""" |
|
|
|
|
|
return {} |
|
|
|
|
|
def setup_mobile_gestures(): |
|
|
""" |
|
|
Set up mobile gesture handlers |
|
|
""" |
|
|
return { |
|
|
"swipe_left": "next_tab", |
|
|
"swipe_right": "prev_tab", |
|
|
"pull_down": "refresh", |
|
|
"long_press": "context_menu" |
|
|
} |
|
|
|
|
|
|