+ {paragraph} +
+ ))} ++ Written automatically from the change history for this item. +
+ + ); +} diff --git a/src/components/card/commit-history.tsx b/src/components/card/commit-history.tsx new file mode 100644 index 0000000..5a0a6e1 --- /dev/null +++ b/src/components/card/commit-history.tsx @@ -0,0 +1,83 @@ +"use client"; + +import { useState } from "react"; +import { Code2 } from "lucide-react"; + +import { relativeTime } from "@/lib/time/relative"; +import type { CommitRecord } from "@/lib/pb/types"; + +/** + * A card's commits, in the client's language. + * + * Two rules, both from the spec: + * - A commit with no summary shows its raw subject. Never a gap — a card that + * renders blank because the provider was down looks like no work happened. + * - The raw commit is always one toggle away. The humanised text is a + * translation, not a replacement, and a client who wants to check it must be + * able to. + */ +export function CommitHistory({ commits }: { commits: CommitRecord[] }) { + const [showRaw, setShowRaw] = useState(false); + + if (commits.length === 0) return null; + + return ( ++ {/* Fall back to the raw subject — never render nothing. */} + {commit.summary || commit.subject} +
++ {relativeTime(commit.authored_at)} +
+ + {showRaw && ( ++ {commit.url ? ( + + {commit.short_sha} + + ) : ( + commit.short_sha + )}{" "} + {commit.subject} +
+ )} +