| 1683 | } |
| 1684 | |
| 1685 | function fallbackTitleFromMessage(message: MessageV2.WithParts) { |
| 1686 | for (const part of message.parts) { |
| 1687 | if (part.type === "text" && !part.synthetic && part.text.trim().length > 0) { |
| 1688 | const cleaned = part.text.replace(/\s+/g, " ").trim() |
| 1689 | return cleaned.length > 100 ? cleaned.substring(0, 97) + "..." : cleaned |
| 1690 | } |
| 1691 | } |
| 1692 | for (const part of message.parts) { |
| 1693 | if (part.type === "file" && part.filename) { |
| 1694 | const cleaned = `File: ${part.filename}` |
| 1695 | return cleaned.length > 100 ? cleaned.substring(0, 97) + "..." : cleaned |
| 1696 | } |
| 1697 | } |
| 1698 | return undefined |
| 1699 | } |
| 1700 | |
| 1701 | async function ensureTitle(input: { |
| 1702 | session: Session.Info |