fix: nws area truncation — configurable word-boundary cap (default 80)

Replace hardcoded 50-char area cap with adapter_config key
nws.area_max_chars (default 80). Truncation now appends ellipsis when
cut, matching the locations_max_chars pattern from the prior commit.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Matt Johnson (via Claude) 2026-06-10 02:26:31 +00:00
commit 860d06c4a3
2 changed files with 11 additions and 2 deletions

View file

@ -576,6 +576,11 @@ REGISTRY: dict[tuple[str, str], dict[str, Any]] = {
"type": "int",
"description": "Maximum characters for the locations field on line 4 of NWS wire. Truncates at word boundary.",
},
("nws", "area_max_chars"): {
"default": 80,
"type": "int",
"description": "Maximum characters for the area field on line 2 of NWS wire. Truncates at last word boundary.",
},
# =================================================================
# AVALANCHE -- 1 setting (min danger level broadcast floor)

View file

@ -324,8 +324,12 @@ def _render(*, event_type, area_desc, geocoder_city, county, state,
else:
time_seg = ""
area = (area_desc or "").split(";")[0].strip()
if len(area) > 50:
area = area[:50].rsplit(" ", 1)[0]
_area_limit = int(adapter_config.nws.area_max_chars)
if len(area) > _area_limit:
cut = area[:_area_limit].rsplit(" ", 1)[0]
if not cut:
cut = area[:_area_limit]
area = cut + "\u2026"
if time_seg and area:
line2 = f"{time_seg}{area}"
elif time_seg: