fix(app_state): stop overwriting UI_ERROR before it can render #16

Merged
troed merged 1 commit from fix/connect-failure-flash into devel 2026-10-14 10:43:00 +02:00
Owner

fix: a failed connect was completely silent

What this is

main/app_state.c's connect-failure path set UI_ERROR and returned to IDLE
in the same breath, and enter(APP_IDLE) immediately sets UI_IDLE. The ring
task samples every 33 ms, so the error state was never observed: a failed
connect produced a brief blue ring and then nothing at all.

That is the failure chased on hardware during the fleet TLS-only work: the
device joined its network, obtained an IP, and then died at the WebSocket
upgrade because the server serves wss:// while the flashed build spoke
plaintext ws://. A plaintext upgrade into a TLS listener is closed with zero
bytes, so the symptom read as "the wake word stopped working" — and the one
signal that could have said otherwise was never drawn.

Change

Surface the error after the app has settled into idle, and hold it past one ring
animation cycle, then return to idle:

if (from_retry) disconnect_and_idle();
else enter(APP_IDLE);
show_error_briefly();      /* set UI_ERROR, hold past one animation, then IDLE */

UI_ERROR is a notification, not a state — the ring animates a triple flash
over 12 steps and then restores s_prev — so the hold is what makes it visible.
The trailing ui_ring_set(UI_IDLE) makes the end of the flash deterministic
rather than dependent on the auto-revert. This also gives the mid-conversation
retry failure an indication it never had.

Verification

Induced three real connect failures on hardware (temporarily pointing the build
at a dead port): the log shows connect stages: ... -> failed → state -> IDLE
each time, and the ring showed the red triple flash each time.

power_idle_set() only flips the ring's low-power flag (speaker amp off, slower
key poll) and never cuts an LED rail, and the UI_ERROR branch deliberately
ignores that flag — so it renders in low-power idle.

No automated test, and that is a gap rather than a claim: the host suite
covers only the pure-logic components (protocol, ed25519, creds), and this
is ordering/timing inside the FreeRTOS state machine. A ring-state test seam
would be a reasonable follow-up.

Notes

Independent of the per-device Wi-Fi feature; cherry-picked onto devel after
that branch merged, so it can be reviewed on its own.

# fix: a failed connect was completely silent ## What this is `main/app_state.c`'s connect-failure path set `UI_ERROR` and returned to `IDLE` in the same breath, and `enter(APP_IDLE)` immediately sets `UI_IDLE`. The ring task samples every 33 ms, so the error state was never observed: a failed connect produced a brief blue ring and then nothing at all. That is the failure chased on hardware during the fleet TLS-only work: the device joined its network, obtained an IP, and then died at the WebSocket upgrade because the server serves `wss://` while the flashed build spoke plaintext `ws://`. A plaintext upgrade into a TLS listener is closed with zero bytes, so the symptom read as "the wake word stopped working" — and the one signal that could have said otherwise was never drawn. ## Change Surface the error after the app has settled into idle, and hold it past one ring animation cycle, then return to idle: ```c if (from_retry) disconnect_and_idle(); else enter(APP_IDLE); show_error_briefly(); /* set UI_ERROR, hold past one animation, then IDLE */ ``` `UI_ERROR` is a notification, not a state — the ring animates a triple flash over 12 steps and then restores `s_prev` — so the hold is what makes it visible. The trailing `ui_ring_set(UI_IDLE)` makes the end of the flash deterministic rather than dependent on the auto-revert. This also gives the mid-conversation retry failure an indication it never had. ## Verification Induced three real connect failures on hardware (temporarily pointing the build at a dead port): the log shows `connect stages: ... -> failed` → `state -> IDLE` each time, and the ring showed the red triple flash each time. `power_idle_set()` only flips the ring's low-power flag (speaker amp off, slower key poll) and never cuts an LED rail, and the `UI_ERROR` branch deliberately ignores that flag — so it renders in low-power idle. **No automated test**, and that is a gap rather than a claim: the host suite covers only the pure-logic components (`protocol`, `ed25519`, `creds`), and this is ordering/timing inside the FreeRTOS state machine. A ring-state test seam would be a reasonable follow-up. ## Notes Independent of the per-device Wi-Fi feature; cherry-picked onto `devel` after that branch merged, so it can be reviewed on its own.
The failure path set UI_ERROR and returned to IDLE in the same breath, and
enter(APP_IDLE) immediately sets UI_IDLE, so the ring task (33 ms tick) never
observed the error state: a failed connect was completely silent. Surface the
error after the app has settled into idle and hold past one animation cycle.
Also covers the mid-conversation retry failure, which had no indication.
troed merged commit bd2c9e3561 into devel 2026-10-14 10:43:00 +02:00
troed deleted branch fix/connect-failure-flash 2026-10-14 10:43:00 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starfleet/communicator-esp32!16
No description provided.