From daaa5b150379470f100464950a669021e9788bd1 Mon Sep 17 00:00:00 2001 From: Jakub <106778416+MarekZegare4@users.noreply.github.com> Date: Thu, 4 Jun 2026 12:15:30 +0200 Subject: [PATCH] fix(messages): allow full-length text on the compose/send paths too After widening the history buffers, the compose side was still the bottleneck: the keyboard capped input at 139 bytes and the quick-message expand buffers were 140. Raise KB_MAX_LEN to 160 (MeshCore's MAX_TEXT_LEN) and size the expand/compose buffers to MSG_TEXT_BUF, so a message can be typed, expanded, sent, stored and displayed at the full protocol length on every path. The custom-message editor now passes an explicit max bound to its 140-byte store, so the wider keyboard buffer can't overflow it; the bot editor already passed per-field maxima. Co-Authored-By: Claude Opus 4.8 --- examples/companion_radio/ui-new/KeyboardWidget.h | 5 ++++- examples/companion_radio/ui-new/QuickMsgScreen.h | 4 ++-- examples/companion_radio/ui-new/SettingsScreen.h | 5 ++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/examples/companion_radio/ui-new/KeyboardWidget.h b/examples/companion_radio/ui-new/KeyboardWidget.h index c450a953..6a532d5d 100644 --- a/examples/companion_radio/ui-new/KeyboardWidget.h +++ b/examples/companion_radio/ui-new/KeyboardWidget.h @@ -14,7 +14,10 @@ static const char KB_CHARS[4][10] = { static const int KB_ROWS_CHAR = 4; static const int KB_COLS_CHAR = 10; static const int KB_SPECIAL = 5; // [^] [Sp] [De] [{}] [OK] -static const int KB_MAX_LEN = 139; +// Buffer cap for typed text, in bytes. Matches MeshCore's MAX_TEXT_LEN +// (10*CIPHER_BLOCK_SIZE = 160) so a full-length message can be composed; each +// field passes its own smaller max to begin() where its store is smaller. +static const int KB_MAX_LEN = 160; static const int KB_PH_MAX = 12; // max placeholders in list static const int KB_PH_LEN = 9; // max placeholder string length incl. null diff --git a/examples/companion_radio/ui-new/QuickMsgScreen.h b/examples/companion_radio/ui-new/QuickMsgScreen.h index 05dd5418..c3ee4ddc 100644 --- a/examples/companion_radio/ui-new/QuickMsgScreen.h +++ b/examples/companion_radio/ui-new/QuickMsgScreen.h @@ -1589,9 +1589,9 @@ public: NodePrefs* p = _task->getNodePrefs(); int slot = _active_msgs[_msg_sel - 1]; const char* tmpl = p ? p->custom_msgs[slot] : "OK"; - char msg[140]; + char msg[MSG_TEXT_BUF]; if (_reply_mode) { - char body[140]; + char body[MSG_TEXT_BUF]; expandMsg(tmpl, body, sizeof(body)); snprintf(msg, sizeof(msg), "%s%s", _reply_prefix, body); } else { diff --git a/examples/companion_radio/ui-new/SettingsScreen.h b/examples/companion_radio/ui-new/SettingsScreen.h index 6246bf22..ac564e5b 100644 --- a/examples/companion_radio/ui-new/SettingsScreen.h +++ b/examples/companion_radio/ui-new/SettingsScreen.h @@ -810,7 +810,10 @@ public: if (isMsgSlot(_selected) && enter) { int slot = msgSlotIndex(_selected); _edit_slot = slot; - _kb.begin(p ? p->custom_msgs[slot] : ""); + // Bound to the custom_msgs store (140 B) so the wider keyboard buffer + // can't overflow it on save. + _kb.begin(p ? p->custom_msgs[slot] : "", + p ? (int)sizeof(p->custom_msgs[slot]) - 1 : KB_MAX_LEN); kbAddSensorPlaceholders(_kb, &sensors); return true; }