(m: Message)
| 114 | * implausible (an interrupt implies a prior prompt already flowed through). |
| 115 | */ |
| 116 | export function extractTitleText(m: Message): string | undefined { |
| 117 | if (m.type !== 'user' || m.isMeta || m.toolUseResult || m.isCompactSummary) |
| 118 | return undefined |
| 119 | if (m.origin && (m.origin as { kind?: string }).kind !== 'human') |
| 120 | return undefined |
| 121 | const content = m.message!.content |
| 122 | let raw: string | undefined |
| 123 | if (typeof content === 'string') { |
| 124 | raw = content |
| 125 | } else { |
| 126 | for (const block of content ?? []) { |
| 127 | if (block.type === 'text') { |
| 128 | raw = block.text |
| 129 | break |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | if (!raw) return undefined |
| 134 | const clean = stripDisplayTagsAllowEmpty(raw) |
| 135 | return clean || undefined |
| 136 | } |
| 137 | |
| 138 | const SYSTEM_REMINDER_TAG = 'system-reminder' |
| 139 | const XML_BLOCK_PATTERN = /\s*<([a-z][\w-]*)(?:\s[^>]*)?>[\s\S]*?<\/\1>\s*/gy |
no test coverage detected