The best way to control Claude Code, Codex and more from any computer or phone

main
ts 20 lines 805 Bytes
Raw
1 import type { PullRequestState } from "@t3tools/contracts";
2
3 interface ObservedPullRequest {
4 readonly state: PullRequestState;
5 readonly updatedAt?: string | undefined;
6 readonly observedAt?: number | undefined;
7 }
8
9 /** Older than what is shown by host update time, then server read time, or a merge undone. */
10 export function isStalePullRequestReply(
11 shown: ObservedPullRequest,
12 reply: ObservedPullRequest,
13 ): boolean {
14 if (shown.state === "merged" && reply.state !== "merged") return true;
15 if (shown.updatedAt !== undefined && reply.updatedAt !== undefined) {
16 const updated = Date.parse(reply.updatedAt) - Date.parse(shown.updatedAt);
17 if (Number.isFinite(updated) && updated !== 0) return updated < 0;
18 }
19 return (reply.observedAt ?? -Infinity) < (shown.observedAt ?? -Infinity);
20 }