import type { GitFileDiff } from "@opengeni/sdk"; import { useState } from "react"; import { cn } from "../lib/cn"; import { useThemeType } from "../lib/use-theme-type"; import { PierreDiff } from "../components/pierre-diff"; import { useOpenGeniText } from "../messages/runtime"; /* ---------------------------------------------------------------------------- Tool diff Renders parsed `GitFileDiff[]` (from the V4A apply_patch parser) through the EXACT same diff stack the Files/Changes tabs use: `PierreDiff` (Shiki- highlighted), with a built-in plain-text degrade for a host without `@pierre/diffs` — one renderer, a single data contract. A per-block Unified/Split toggle sits in the header. -------------------------------------------------------------------------- */ export function ToolDiff({ files }: { files: GitFileDiff[] }) { const [layout, setLayout] = useState<"unified" | "split">("unified"); // Resolve the host theme (auto-detect via `data-og-theme`) with the SAME hook // the Files tab uses, then thread it into Pierre. Without it Pierre falls back // to its hard dark default and renders a github-dark slab inside a light page. const themeType = useThemeType(undefined); return (
{t("timeline.toolDiff.rawPatchCouldNotParse")}
{lines.map(({ key, line }) => (
{line || " "}
))}