mirror of
https://github.com/torlando-tech/pyxis.git
synced 2026-09-25 06:04:51 +00:00
Every message send on the device was deterministically rebooting it: send_message() ran the full pipeline (identity recall, message construction, RouterLock-scoped router admission, and LittleFS persistence) synchronously on LVGL's 8 KiB task while holding the LVGL mutex. On this device's degraded filesystem a single save takes ~7s of 400ms-2s per-op gaps, tripping the 5s LVGL deadlock guard and asserting at LVGLLock.h:45 (assert failed: LVGL mutex timeout (5s)). The receive path already carries the fix pattern for exactly this failure class (see on_message_received); the send path never got it. Restructure the send path as a mailbox handoff, following the existing CallStartMailbox / LocationShareCommandMailbox precedent: - send_message() (LVGL task) now only validates and publishes (destination, content, source) into a mutex-guarded single-slot OutgoingSendMailbox. No router lock, no I/O, no message construction. - update() services the mailbox in service_pending_sends() on the main loop, before the big LVGL_LOCK() — the only place in the send path that may take the router lock, block on admission, or wait on LittleFS. - On acceptance, a brief LVGL_LOCK in apply_outbound_result() commits the UI (add_message / clear_composer / compose->chat navigation, route-guarded). The admitted packed form is unpacked for display with incoming/state flags restored. - On rejection (storage error, router busy, queue full) the user's input is retained for retry, matching the old behavior. The 500-char UI cap bounds the mailbox payload. Build tdeck SUCCESS, 170/170 contract tests pass.