feat: render full agent lifecycle text from notification_body in Telegram

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
PTah
2026-05-31 18:11:17 +10:00
parent 9dacbd7944
commit 4baa2b426f
2 changed files with 41 additions and 0 deletions
@@ -309,8 +309,26 @@ _LIFECYCLE_TRIGGER_LABELS: dict[str, str] = {
}
def _format_lifecycle_body_html(body: str) -> str:
text = body.replace("\r\n", "\n").strip()
if not text:
return ""
parts: list[str] = []
for i, line in enumerate(text.split("\n")):
esc = html.escape(line)
if i == 0 and line.strip():
parts.append(f"<b>{esc.strip()}</b>")
else:
parts.append(esc)
return "\n".join(parts).strip()
def format_lifecycle_html(event: Event) -> str:
details = _details_dict(event)
notification_body = details.get("notification_body")
if isinstance(notification_body, str) and notification_body.strip():
return _format_lifecycle_body_html(notification_body)
lifecycle = _detail(details, "lifecycle", default="started").strip().lower()
trigger = _detail(details, "trigger", default="").strip().lower()
header = _LIFECYCLE_HEADERS.get(lifecycle, f"📋 Lifecycle: {html_escape(lifecycle)}")