| 1 | export function resolveRemainingFailedPageInfo(args: { |
| 2 | previousFailures: Map<string, { title: string; reason: string }> |
| 3 | failedResults: Array<{ pageId: string; reason: string }> |
| 4 | completedPageIds: Set<string> |
| 5 | pageRefs: Array<{ pageId: string; title: string }> |
| 6 | }): Map<string, { title: string; reason: string }> { |
| 7 | const remaining = new Map(args.previousFailures) |
| 8 | const titleByPageId = new Map(args.pageRefs.map((page) => [page.pageId, page.title])) |
| 9 | |
| 10 | for (const failed of args.failedResults) { |
| 11 | remaining.set(failed.pageId, { |
| 12 | title: titleByPageId.get(failed.pageId) || failed.pageId, |
| 13 | reason: failed.reason |
| 14 | }) |
| 15 | } |
| 16 | for (const pageId of args.completedPageIds) { |
| 17 | remaining.delete(pageId) |
| 18 | } |
| 19 | return remaining |
| 20 | } |
| 21 |