userMessageText function
Flattens a user-message content (plain text or content blocks) to its text — the same fold every projection and preview uses. Non-text blocks collapse away; an empty list folds to the empty string.
Implementation
String userMessageText(Object content) {
if (content is String) return content;
if (content is! List) return '';
return [
for (final block in content)
if (block is TextContent) block.text,
].join(' ');
}