( inner: Generator<PipelineEvent>, )
| 66 | * so the UI modal can show summarization activity. |
| 67 | */ |
| 68 | export function* wrapWithSummaries( |
| 69 | inner: Generator<PipelineEvent>, |
| 70 | ): Generator<PipelineEvent> { |
| 71 | let summarized = 0; |
| 72 | let total = 0; |
| 73 | |
| 74 | yield { |
| 75 | kind: 'stage_start', |
| 76 | phase: 'summarizing', |
| 77 | message: 'Summarizing nodes...', |
| 78 | }; |
| 79 | |
| 80 | for (const event of inner) { |
| 81 | if (event.nodes) { |
| 82 | for (const node of event.nodes) { |
| 83 | total++; |
| 84 | if (!node.properties?.summary) { |
| 85 | const summary = summarizeNode(node); |
| 86 | if (summary) { |
| 87 | node.properties = { ...node.properties, summary }; |
| 88 | summarized++; |
| 89 | } |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | yield { |
| 94 | kind: 'stage_progress', |
| 95 | phase: 'summarizing', |
| 96 | message: `Summarized ${summarized} of ${total} nodes`, |
| 97 | detail: { current: summarized, total }, |
| 98 | }; |
| 99 | } |
| 100 | yield event; |
| 101 | } |
| 102 | |
| 103 | yield { |
| 104 | kind: 'stage_stop', |
| 105 | phase: 'summarizing', |
| 106 | message: `Summarized ${summarized} nodes`, |
| 107 | }; |
| 108 | } |
no test coverage detected