| 120 | } |
| 121 | |
| 122 | function stableWorkflowOrder(workflows: readonly string[]): string[] { |
| 123 | const seen = new Set<string>(); |
| 124 | const ordered: string[] = []; |
| 125 | |
| 126 | for (const workflow of ALL_WORKFLOWS) { |
| 127 | if (workflows.includes(workflow) && !seen.has(workflow)) { |
| 128 | ordered.push(workflow); |
| 129 | seen.add(workflow); |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | const extras = workflows.filter((w) => !ALL_WORKFLOWS.includes(w as (typeof ALL_WORKFLOWS)[number])); |
| 134 | extras.sort(); |
| 135 | for (const extra of extras) { |
| 136 | if (!seen.has(extra)) { |
| 137 | ordered.push(extra); |
| 138 | seen.add(extra); |
| 139 | } |
| 140 | } |
| 141 | |
| 142 | return ordered; |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * Build a user-facing diff summary between two profile states. |