- Migrate web and mobile state, commands, and persistence to V2 projections - Render conversations from authoritative visible turn items - Harden runtime policy, launch handling, attachments, and cache invalidation
20 lines
640 B
TypeScript
20 lines
640 B
TypeScript
import { useMemo } from "react";
|
|
import { inferCheckpointTurnCountByRunId } from "../session-logic";
|
|
import type { Thread, TurnDiffSummary } from "../types";
|
|
|
|
export function useTurnDiffSummaries(activeThread: Thread | null | undefined) {
|
|
const turnDiffSummaries = useMemo<ReadonlyArray<TurnDiffSummary>>(() => {
|
|
if (!activeThread) {
|
|
return [];
|
|
}
|
|
return activeThread.checkpoints;
|
|
}, [activeThread]);
|
|
|
|
const inferredCheckpointTurnCountByRunId = useMemo(
|
|
() => inferCheckpointTurnCountByRunId(turnDiffSummaries),
|
|
[turnDiffSummaries],
|
|
);
|
|
|
|
return { turnDiffSummaries, inferredCheckpointTurnCountByRunId };
|
|
}
|