-
-
Notifications
You must be signed in to change notification settings - Fork 69.4k
Feature: optionally preserve newlines in system-event previews (avoid flattening multi-line Markdown) #12850
Description
Summary
Today the Mattermost channel (and possibly other channels) emits an inbound activity systemEvent preview computed as:
preview = bodyText.replace(/\s+/g, " ").slice(0, 160)
This collapses all whitespace including \n, so multi-line Markdown appears as a single line in the system-event preview.
Importantly: the full inbound envelope body forwarded to the agent still preserves \n — this is only about the preview string.
Why this matters
When debugging or scanning inbound context, the system-event preview is often the most visible/compact representation. Flattening newlines makes it harder to see Markdown block structure (lists, quotes, code fences), and can be misinterpreted as “newlines were lost in ingestion”.
Proposal
Add an option (config or per-channel setting) to generate previews that preserve newlines, e.g.:
- keep
\nand normalize only spaces/tabs within each line - or produce a multi-line preview capped by max lines + max chars
Keep current behavior as default (compact 1-line preview), but allow opting into a “faithful preview” mode.
Evidence
Instrumented logs show rawText and bodyText preserve \n; only preview flattens due to /\s+/g.
Related
Closed as not-a-bug: #12247 (root cause was preview flattening, not inbound newline loss)