8b11249755
Importing tui_gateway.entry from a worker thread raised 'ValueError: signal only works in main thread of the main interpreter' because signal.signal() was called unconditionally at import time. On the Desktop/WebSocket path, server._build() runs in a daemon thread and does 'from tui_gateway.entry import ensure_mcp_discovery_started' as the first import of entry (entry.main() is never run there), which crashed and aborted MCP discovery startup — every session then lost its MCP servers (e.g. Dart-mcp) with ClosedResourceError. signal handlers are process-global, so installing them only when the module is first imported in the main thread is sufficient; importing from a worker thread becomes a safe no-op. Fixes #72667