feat: a message's bytes left, counted as it will be sent, on every screen

The limit is what the send leaves of MAX_TEXT_LEN: a channel post carries
"<node name>: ", a direct message resent more than three times keeps two
bytes spare, and placeholders count as they expand (msgtext::limit/sentLen).
Bytes, not characters. The path and packet header sit outside the payload;
static_asserts keep a full message within the radio frame on the longest path.

From 40 bytes left the count shows: on the L2 as a tag on the field's top
edge, on OLED/e-ink at the right of the preview's last line with the text
wrapped short of it. Input stops at the limit; a send still over (a
placeholder grew) is held. Sim hooks to open a compose with text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-10-07 22:58:01 +02:00
co-authored by Claude Opus 5.5
parent 60df2a3268
commit 6c9186dc54
7 changed files with 179 additions and 9 deletions
@@ -2190,6 +2190,13 @@ void UITask::gotoMessagesScreen() {
setCurrScreen(messages_screen);
}
#ifdef SIM_PLATFORM
void UITask::simCompose(const char* text) {
gotoMessagesScreen();
((MessagesScreen*)messages_screen)->simCompose(text);
}
#endif
void UITask::openContactDM(const ContactInfo& ci) {
((MessagesScreen*)messages_screen)->reset();
((MessagesScreen*)messages_screen)->enterDM(ci);
@@ -2661,6 +2668,11 @@ extern "C" EMSCRIPTEN_KEEPALIVE void sim_enqueue_key(char c) {
if (g_sim_ui_task_for_js) g_sim_ui_task_for_js->injectSimKey(c);
}
// Sim tests: a channel post's keyboard, holding `text`.
extern "C" EMSCRIPTEN_KEEPALIVE void sim_compose(const char* text) {
if (g_sim_ui_task_for_js) g_sim_ui_task_for_js->simCompose(text);
}
// Long-press counterpart -- the host page's own press-and-hold timer (see
// web/index.html/mesh.html) calls this instead of sim_enqueue_key() once a
// button/key has been held past the same ~1000ms threshold every real