console: make ui actually leave console mode

Typing `ui` or `exit` rebooted straight back into the console.

touchPrefsSetConsoleMode() does not write the pref, it QUEUES an A/B snapshot:
SdNvsPrefs deliberately keeps filesystem I/O off the calling thread, and
touchPrefsFlush() is what forces the queue out. The console called
ESP.restart() directly, so the queued write was discarded and the next boot
still read "console". The Settings toggle never showed this because it goes
through rebootDevice(), whose last act is that flush.

The console now exits through the same path, which also means it leaves on the
same terms as everything else: chat history, the Discovered ring and the sync
replay ring are persisted first. rebootDevice()'s save-failure branch called
lv_refr_now() unconditionally, which is not survivable with no LVGL, so that
one call is now conditional; showAlert was already console-aware.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Kaj SchittecatandClaude Opus 5 committed 2026-08-22 23:34:50 +02:00
1 parent c2357f032e
commit e9bf6d9e17
2 files changed
+33 -3

No files matched your search

+7 -2
View File
@@ -50,6 +50,9 @@ extern int luaHostDiscoverAt(int idx, char* pk_hex, size_t pk_cap, char* name,
// Board touch driver, read directly. lvglTouchRead() is only an adapter that
// feeds LVGL, so there is nothing to unpick here: the driver polls either way.
extern bool heltecV4CapTouchGetLive(uint16_t* x, uint16_t* y);
#if defined(ESP32)
extern void consoleHostRebootToUi(); // clears the pref, flushes it, reboots
#endif
#endif
namespace {
@@ -526,11 +529,13 @@ void submit() {
// The way back to the graphical UI. One of three, per CONSOLE_MODE.md: this,
// a key held at boot, and clearing the pref over serial or the flasher.
if (!strcasecmp(cmd, "ui") || !strcasecmp(cmd, "exit")) {
touchPrefsSetConsoleMode(false);
consoleWriteLine("switching to the graphical UI, rebooting...");
render();
delay(600); // let the line land on the panel before the reset
ESP.restart();
// Clears the pref AND flushes it. Doing the write here and calling
// ESP.restart() left the queued snapshot unwritten, so this came straight
// back to the console.
consoleHostRebootToUi();
return;
}
#endif