From e0312c2b6bd6f1412c797a82ef9b83176b798726 Mon Sep 17 00:00:00 2001 From: Jakub <106778416+MarekZegare4@users.noreply.github.com> Date: Thu, 21 May 2026 16:37:25 +0200 Subject: [PATCH] fix: strip @[nick] reply prefix in channel and DM history card previews Reply prefix was eating ~9 chars of display width, causing the actual message body to be ellipsized in list cards. Fullscreen view already showed the recipient correctly via the To: header line. Co-Authored-By: Claude Sonnet 4.6 --- .../companion_radio/ui-new/QuickMsgScreen.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/examples/companion_radio/ui-new/QuickMsgScreen.h b/examples/companion_radio/ui-new/QuickMsgScreen.h index 002895cf..6febeba3 100644 --- a/examples/companion_radio/ui-new/QuickMsgScreen.h +++ b/examples/companion_radio/ui-new/QuickMsgScreen.h @@ -88,6 +88,15 @@ class QuickMsgScreen : public UIScreen { &sensors, batt); } + // Strip "@[nick] " reply prefix from a message body for compact list display. + static const char* skipReplyPrefix(const char* text) { + if (text[0] == '@' && text[1] == '[') { + const char* close = strchr(text + 2, ']'); + if (close && close[1] == ' ' && close[2]) return close + 2; + } + return text; + } + // Build "@[nick] " prefix from a channel message text ("nick: body") into _reply_prefix. // Returns false if sender is "Me" (own message — no reply prefix needed). bool buildChannelReplyPrefix(const char* text) { @@ -642,7 +651,7 @@ public: display.setColor(DisplayDriver::DARK); display.drawTextEllipsized(3, y + 1, display.width() - 6 - age_w, sender); if (age[0]) { display.setCursor(display.width() - 3 - display.getTextWidth(age), y + 1); display.print(age); } - display.drawTextEllipsized(3, y + 10, display.width() - 6, e.text); + display.drawTextEllipsized(3, y + 10, display.width() - 6, skipReplyPrefix(e.text)); } else { display.setColor(DisplayDriver::LIGHT); display.drawRect(0, y, display.width(), HIST_BOX_H); @@ -651,7 +660,7 @@ public: display.drawTextEllipsized(3, y + 1, display.width() - 6 - age_w, sender); if (age[0]) { display.setCursor(display.width() - 3 - display.getTextWidth(age), y + 1); display.print(age); } display.setColor(DisplayDriver::LIGHT); - display.drawTextEllipsized(3, y + 10, display.width() - 6, e.text); + display.drawTextEllipsized(3, y + 10, display.width() - 6, skipReplyPrefix(e.text)); } } @@ -749,7 +758,7 @@ public: display.setColor(DisplayDriver::DARK); display.drawTextEllipsized(3, y + 1, display.width() - 6 - age_w, sender); if (age[0]) { display.setCursor(display.width() - 3 - display.getTextWidth(age), y + 1); display.print(age); } - display.drawTextEllipsized(3, y + 10, display.width() - 6, msg_part); + display.drawTextEllipsized(3, y + 10, display.width() - 6, skipReplyPrefix(msg_part)); } else { display.setColor(DisplayDriver::LIGHT); display.drawRect(0, y, display.width(), HIST_BOX_H); @@ -758,7 +767,7 @@ public: display.drawTextEllipsized(3, y + 1, display.width() - 6 - age_w, sender); if (age[0]) { display.setCursor(display.width() - 3 - display.getTextWidth(age), y + 1); display.print(age); } display.setColor(DisplayDriver::LIGHT); - display.drawTextEllipsized(3, y + 10, display.width() - 6, msg_part); + display.drawTextEllipsized(3, y + 10, display.width() - 6, skipReplyPrefix(msg_part)); } }