From 6bf0e3427e1a6f34970289620b1bfd48babfe323 Mon Sep 17 00:00:00 2001 From: K7ZVX Date: Wed, 6 May 2026 00:57:44 +0000 Subject: [PATCH] fix: !health packs into 2-3 messages with newlines inside Co-Authored-By: Claude Opus 4.5 --- meshai/mesh_reporter.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/meshai/mesh_reporter.py b/meshai/mesh_reporter.py index e15ea1a..93f48d3 100644 --- a/meshai/mesh_reporter.py +++ b/meshai/mesh_reporter.py @@ -1596,7 +1596,28 @@ class MeshReporter: if region_parts: lines.append(" | ".join(region_parts)) - return lines + # Pack lines into 2-3 messages under 220 bytes each + MAX_BYTES = 220 + messages = [] + current_lines = [] + current_bytes = 0 + + for line in lines: + line_bytes = len(line.encode('utf-8')) + separator_bytes = 1 if current_lines else 0 + + if current_bytes + separator_bytes + line_bytes > MAX_BYTES and current_lines: + messages.append("\n".join(current_lines)) + current_lines = [line] + current_bytes = line_bytes + else: + current_lines.append(line) + current_bytes += separator_bytes + line_bytes + + if current_lines: + messages.append("\n".join(current_lines)) + + return messages def _region_lora_compact(self, region) -> list[str]: """Compact region display. Returns list of messages."""