import { useMemo } from "react" import { CheckpointMenu } from "./CheckpointMenu" import { checkpointSchema } from "./schema" type CheckpointSavedProps = { ts: number commitHash: string currentHash?: string checkpoint?: Record } export const CheckpointSaved = ({ checkpoint, ...props }: CheckpointSavedProps) => { const isCurrent = props.currentHash === props.commitHash const metadata = useMemo(() => { if (!checkpoint) { return undefined } const result = checkpointSchema.safeParse(checkpoint) if (!result.success) { return undefined } return result.data }, [checkpoint]) if (!metadata) { return null } return (
{metadata.isFirst ? "Initial Checkpoint" : "Checkpoint"} {isCurrent && Current}
) }