| 1 | import type { ReviewSectionItem } from "./reviewModel"; |
| 2 | |
| 3 | export interface ReviewSectionMenu { |
| 4 | readonly workingTree: ReviewSectionItem | null; |
| 5 | readonly branchChanges: ReviewSectionItem | null; |
| 6 | readonly latestTurn: ReviewSectionItem | null; |
| 7 | readonly turns: ReadonlyArray<ReviewSectionItem>; |
| 8 | } |
| 9 | |
| 10 | export function buildReviewSectionMenu( |
| 11 | sections: ReadonlyArray<ReviewSectionItem>, |
| 12 | ): ReviewSectionMenu { |
| 13 | const turns = sections.filter((section) => section.kind === "turn"); |
| 14 | |
| 15 | return { |
| 16 | workingTree: sections.find((section) => section.kind === "working-tree") ?? null, |
| 17 | branchChanges: sections.find((section) => section.kind === "branch-range") ?? null, |
| 18 | latestTurn: turns[0] ?? null, |
| 19 | turns, |
| 20 | }; |
| 21 | } |