| 579 | } |
| 580 | |
| 581 | func fallbackChatTitle(message string) string { |
| 582 | const maxWords = 6 |
| 583 | const maxRunes = 80 |
| 584 | |
| 585 | words := strings.Fields(message) |
| 586 | if len(words) == 0 { |
| 587 | return "New Chat" |
| 588 | } |
| 589 | |
| 590 | truncated := false |
| 591 | if len(words) > maxWords { |
| 592 | words = words[:maxWords] |
| 593 | truncated = true |
| 594 | } |
| 595 | |
| 596 | title := strings.Join(words, " ") |
| 597 | if truncated { |
| 598 | return truncateRunes(title, maxRunes-1) + "…" |
| 599 | } |
| 600 | |
| 601 | return truncateRunes(title, maxRunes) |
| 602 | } |
| 603 | |
| 604 | // contentBlocksToText concatenates the text parts of SDK chat |
| 605 | // message parts into a single space-separated string. |