From 4c2da2f36455a6c05512857352e5cc0cfeb94627 Mon Sep 17 00:00:00 2001 From: Jakub <106778416+MarekZegare4@users.noreply.github.com> Date: Tue, 26 May 2026 16:18:17 +0200 Subject: [PATCH] =?UTF-8?q?fix(ui):=20home=20pages=20=E2=80=94=20unconditi?= =?UTF-8?q?onal=20SHUTDOWN=20eviction=20when=20required=20page=20absent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previous fix only evicted SHUTDOWN when cur_len == PAGE_ORDER_LEN (full). If the array was not yet full but had SHUTDOWN + 2 missing pages (TOOLS and QUICK_MSG), TOOLS would fill the last slot but QUICK_MSG would be left out. Remove the cur_len guard: evict SHUTDOWN whenever any required page is missing, regardless of array fullness. This frees one slot before the append loop so all missing required pages can be added in a single pass. Co-Authored-By: Claude Sonnet 4.6 --- .../companion_radio/ui-new/SettingsScreen.h | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/examples/companion_radio/ui-new/SettingsScreen.h b/examples/companion_radio/ui-new/SettingsScreen.h index 5900520e..803d4ab4 100644 --- a/examples/companion_radio/ui-new/SettingsScreen.h +++ b/examples/companion_radio/ui-new/SettingsScreen.h @@ -305,21 +305,21 @@ class SettingsScreen : public UIScreen { #endif NodePrefs::HPB_SETTINGS, NodePrefs::HPB_TOOLS, NodePrefs::HPB_QUICK_MSG, }; - // If the array is full but a required page is missing, evict SHUTDOWN - // (it is handled by buildVisibleOrder's fallback and need not be explicit). - if (cur_len == NodePrefs::PAGE_ORDER_LEN) { - bool any_missing = false; - for (int ri = 0; ri < (int)(sizeof(REQUIRED)/sizeof(REQUIRED[0])); ri++) { - if (!(present & (uint16_t)(1u << REQUIRED[ri]))) { any_missing = true; break; } - } - if (any_missing) { - for (int i = 0; i < cur_len; i++) { - if (p->page_order[i] == NodePrefs::HPB_SHUTDOWN + 1) { - for (int j = i; j < cur_len - 1; j++) p->page_order[j] = p->page_order[j + 1]; - p->page_order[--cur_len] = 0; - present &= ~(uint16_t)(1u << NodePrefs::HPB_SHUTDOWN); - break; - } + // If any required page is missing, evict SHUTDOWN to make room — it is + // handled by buildVisibleOrder's fallback and need not be in the explicit + // list. This frees a slot regardless of whether the array is full or not, + // so multiple missing pages (e.g. TOOLS + QUICK_MSG) can all be appended. + bool any_missing = false; + for (int ri = 0; ri < (int)(sizeof(REQUIRED)/sizeof(REQUIRED[0])); ri++) { + if (!(present & (uint16_t)(1u << REQUIRED[ri]))) { any_missing = true; break; } + } + if (any_missing && (present & (uint16_t)(1u << NodePrefs::HPB_SHUTDOWN))) { + for (int i = 0; i < cur_len; i++) { + if (p->page_order[i] == NodePrefs::HPB_SHUTDOWN + 1) { + for (int j = i; j < cur_len - 1; j++) p->page_order[j] = p->page_order[j + 1]; + p->page_order[--cur_len] = 0; + present &= ~(uint16_t)(1u << NodePrefs::HPB_SHUTDOWN); + break; } } }