* Builds searchable text for a log including messages, titles, summaries, and metadata. * Crops long transcripts to first/last N messages for performance.
(log: LogOption)
| 1535 | * Crops long transcripts to first/last N messages for performance. |
| 1536 | */ |
| 1537 | function buildSearchableText(log: LogOption): string { |
| 1538 | const searchableMessages = log.messages.length <= DEEP_SEARCH_MAX_MESSAGES ? log.messages : [...log.messages.slice(0, DEEP_SEARCH_CROP_SIZE), ...log.messages.slice(-DEEP_SEARCH_CROP_SIZE)]; |
| 1539 | const messageText = searchableMessages.map(extractSearchableText).filter(Boolean).join(' '); |
| 1540 | const metadata = [log.customTitle, log.summary, log.firstPrompt, log.gitBranch, log.tag, log.prNumber ? `PR #${log.prNumber}` : undefined, log.prRepository].filter(Boolean).join(' '); |
| 1541 | const fullText = `${metadata} ${messageText}`.trim(); |
| 1542 | return fullText.length > DEEP_SEARCH_MAX_TEXT_LENGTH ? fullText.slice(0, DEEP_SEARCH_MAX_TEXT_LENGTH) : fullText; |
| 1543 | } |
| 1544 | function groupLogsBySessionId(filteredLogs: LogOption[]): Map<string, LogOption[]> { |
| 1545 | const groups = new Map<string, LogOption[]>(); |
| 1546 | for (const log of filteredLogs) { |