From ddf24e10a906bb5c9c63ccd47d555e2e72978850 Mon Sep 17 00:00:00 2001 From: "Matt Johnson (via Claude)" Date: Mon, 8 Jun 2026 07:07:07 +0000 Subject: [PATCH] nws: truncate NWSheadline at word boundary, no ellipsis Cut at last space before 80 UTF-8 bytes instead of hard-slicing at 77 chars with trailing dots. Co-Authored-By: Claude Opus 4.6 --- meshai/central/nws_handler.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/meshai/central/nws_handler.py b/meshai/central/nws_handler.py index 2a50ccb..8240ece 100644 --- a/meshai/central/nws_handler.py +++ b/meshai/central/nws_handler.py @@ -319,8 +319,9 @@ def _render(*, event_type, area_desc, geocoder_city, county, state, nws_hl = (params.get("NWSheadline") or [""])[0].strip() if nws_hl: nws_hl = nws_hl.title() - if len(nws_hl) > 80: - nws_hl = nws_hl[:77] + "..." + if len(nws_hl.encode("utf-8")) > 80: + while len(nws_hl.encode("utf-8")) > 80: + nws_hl = nws_hl.rsplit(" ", 1)[0] line2 = nws_hl else: area_first = (area_desc or "").split(";")[0].strip()