""" Flask Extensions Module Provides singleton instances of Flask extensions to ensure consistency across the application. This fixes the WebSocket AI mode issue by ensuring all parts of the app use the same SocketIO instance. """ from flask_socketio import SocketIO # Create the SINGLE SocketIO instance that will be used throughout the application # This is the singleton pattern recommended by GPT-5 to fix AI mode WebSocket issues socketio = SocketIO( cors_allowed_origins="*", async_mode="eventlet", ping_timeout=120, # 2 minutes timeout for ping response ping_interval=45, # Send ping every 45 seconds logger=False, # Disable verbose socketio logging (reduces log noise) engineio_logger=False # Disable verbose engineio logging (reduces PING/PONG spam) ) # Note: The app will be bound to this instance using socketio.init_app(app) in create_app()