feat(FN-4288): complete Step 2 — add stall log entry locator

Fusion-Task-Id: FN-4288
Fusion-Task-Lineage: 09c6efc0-ea0b-443a-ab45-a89188fcf888
This commit is contained in:
Fusion
2026-05-13 15:35:56 -07:00
committed by gsxdsm
parent 6dd3a01b67
commit 3874780cb7
2 changed files with 92 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
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;
}