Files
fusion/packages/dashboard/app/utils/findInReviewStallLogEntry.ts
Fusion 3874780cb7 feat(FN-4288): complete Step 2 — add stall log entry locator
Fusion-Task-Id: FN-4288
Fusion-Task-Lineage: 09c6efc0-ea0b-443a-ab45-a89188fcf888
2026-05-13 16:29:37 -07:00

32 lines
843 B
TypeScript

import type { InReviewStallCode, Task, TaskLogEntry } from "@fusion/core";
export const IN_REVIEW_STALL_LOG_PREFIX = "In-review stall surfaced [";
export const IN_REVIEW_STALL_LOG_REGEX = /^In-review stall surfaced \[([^\]]+)\]/;
export interface InReviewStallLogMatch {
entry: TaskLogEntry;
reversedIndex: number;
code: InReviewStallCode;
}
export function findInReviewStallLogEntry(
task: Pick<Task, "log">,
code: InReviewStallCode,
): InReviewStallLogMatch | undefined {
if (!task.log?.length) {
return undefined;
}
const reversed = [...task.log].reverse();
for (const [reversedIndex, entry] of reversed.entries()) {
const match = entry.action.match(IN_REVIEW_STALL_LOG_REGEX);
if (!match || match[1] !== code) {
continue;
}
return { entry, reversedIndex, code };
}
return undefined;
}