(text, fileName, filePath, side)
| 1604 | } |
| 1605 | |
| 1606 | function normalizeCopilotSessionMarkdown(text, fileName, filePath, side) { |
| 1607 | const sections = parseMarkdownSections(text); |
| 1608 | const metadata = extractSessionMetadata(text); |
| 1609 | const events = []; |
| 1610 | const thoughtEntries = []; |
| 1611 | const commandRuns = []; |
| 1612 | const finalResponses = []; |
| 1613 | const pythonScripts = []; |
| 1614 | const pythonSeen = new Set(); |
| 1615 | const detailEntries = []; |
| 1616 | const estimateParts = []; |
| 1617 | let taskPrompt = ''; |
| 1618 | let thoughtOrder = 0; |
| 1619 | let commandOrder = 0; |
| 1620 | let eventOrder = 0; |
| 1621 | if (metadata.sessionId || metadata.duration || metadata.started || metadata.exported) { |
| 1622 | const summary = [ |
| 1623 | metadata.sessionId ? 'session ' + metadata.sessionId : '', |
| 1624 | metadata.started ? 'started ' + metadata.started : '', |
| 1625 | metadata.duration ? 'duration ' + metadata.duration : '', |
| 1626 | metadata.exported ? 'exported ' + metadata.exported : '' |
| 1627 | ].filter(Boolean).join(' | '); |
| 1628 | events.push({ |
| 1629 | id: side + '-session-meta', |
| 1630 | kind: 'info', |
| 1631 | summary, |
| 1632 | timeLabel: 'session', |
| 1633 | chips: ['session metadata'] |
| 1634 | }); |
| 1635 | eventOrder += 1; |
| 1636 | } |
| 1637 | sections.forEach((section) => { |
| 1638 | if (section.type === 'user') { |
| 1639 | const clean = stripSessionMarkup(section.body); |
| 1640 | const textBody = shortMultiline(clean, 520); |
| 1641 | if (!taskPrompt && textBody) { |
| 1642 | taskPrompt = textBody; |
| 1643 | } |
| 1644 | if (clean) { |
| 1645 | estimateParts.push({ label: 'user sections', text: clean }); |
| 1646 | events.push({ id: side + '-session-user-' + eventOrder, kind: 'user_message', summary: textBody, timeLabel: section.timeLabel, chips: ['user'] }); |
| 1647 | detailEntries.push(createDetailEntry({ |
| 1648 | id: side + '-session-user-detail-' + eventOrder, |
| 1649 | kind: 'user_message', |
| 1650 | kindLabel: 'User', |
| 1651 | summary: textBody, |
| 1652 | timeLabel: section.timeLabel, |
| 1653 | chips: ['user'], |
| 1654 | sections: buildRichTextSections(clean, { textLabel: 'Prompt', detectCode: true }) |
| 1655 | })); |
| 1656 | eventOrder += 1; |
| 1657 | } |
| 1658 | return; |
| 1659 | } |
| 1660 | if (section.type === 'copilot') { |
| 1661 | const clean = stripSessionMarkup(section.body); |
| 1662 | if (!clean) { |
| 1663 | return; |
no test coverage detected