Open History to see the last commit
1import { deriveThreadCheckpointSummaries } from "@t3tools/client-runtime/state/thread-checkpoints";
2import type { OrchestrationV2ThreadProjection } from "@t3tools/contracts";
3import { inferCheckpointTurnCountByRunId } from "../session-logic";
4import type { TurnDiffSummary } from "../types";
5
6export function useTurnDiffSummaries(projection: OrchestrationV2ThreadProjection | null) {
7 // No hook calls here, so the compiler only memoizes it when asked.
8 "use memo";
9 const turnDiffSummaries: ReadonlyArray<TurnDiffSummary> =
10 projection === null ? [] : deriveThreadCheckpointSummaries(projection);
11 const inferredCheckpointTurnCountByRunId = inferCheckpointTurnCountByRunId(turnDiffSummaries);
12
13 return { turnDiffSummaries, inferredCheckpointTurnCountByRunId };
14}