feat: render full agent lifecycle text from notification_body in Telegram
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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)}")
|
||||
|
||||
Reference in New Issue
Block a user