import { useEffect, useRef } from "react" import { VersionCard } from "@/components/canvas/version-card" import { useDictionary } from "@/hooks/use-dictionary" import type { Dictionary } from "@/lib/i18n/dictionaries" import type { NodeVersion } from "./node-versions-source" /** What a card says happened: the web app's chat knows the tool that ran, * the shell tells from who made the entry and what changed */ export function versionLabel(version: NodeVersion, dict: Dictionary): string { if (version.source === "user" || version.source === "recover") { return dict.shell.userEdit } return version.fromScratch ? dict.versions.created : dict.versions.edited } /** The version cards, oldest first, as the web app's chat shows them */ export function VersionsPanel({ versions }: { versions: NodeVersion[] }) { const dict = useDictionary() const listRef = useRef(null) // Keep the newest version in view useEffect(() => { const el = listRef.current if (el) el.scrollTo({ top: el.scrollHeight, behavior: "smooth" }) }, [versions.length]) return ( ) }