"use client"; import { Blocks, CheckCircle2, LayoutTemplate, Layers3 } from "lucide-react"; import { countUiSurfaceComponents, getUiSurfaceChildren, getUiSurfaceScreenComponents, resolveUiSurfaceTextBinding, type UiSurfaceSnapshot, } from "@/lib/ui-surface-protocol"; import { cn } from "@/lib/utils"; type DetailSurfaceInspectorReviewState = { screenIndex: number; action?: "pass" | "protocol_patch" | "regenerate_image"; passed?: boolean; }; function getActionLabel(action?: DetailSurfaceInspectorReviewState["action"]) { if (action === "protocol_patch") return "协议修正"; if (action === "regenerate_image") return "重生图"; return "通过"; } function getActionClassName(action?: DetailSurfaceInspectorReviewState["action"]) { if (action === "protocol_patch") { return "bg-blue-50 text-blue-700 ring-1 ring-inset ring-blue-500/20 dark:bg-blue-500/10 dark:text-blue-300"; } if (action === "regenerate_image") { return "bg-red-50 text-red-700 ring-1 ring-inset ring-red-500/20 dark:bg-red-500/10 dark:text-red-300"; } return "bg-emerald-50 text-emerald-700 ring-1 ring-inset ring-emerald-500/20 dark:bg-emerald-500/10 dark:text-emerald-300"; } export function DetailSurfaceInspectorPanel(params: { surface: UiSurfaceSnapshot | null; latestScreenValidation?: DetailSurfaceInspectorReviewState | null; }) { if (!params.surface) return null; const screenComponents = getUiSurfaceScreenComponents(params.surface); const totalComponents = countUiSurfaceComponents(params.surface); const totalTextBlocks = countUiSurfaceComponents(params.surface, "detail_text_block"); const totalScreens = screenComponents.length; return (

Detail Surface Inspector

{params.surface.surfaceId}

{params.surface.generationMode === "agent_layout" ? "AGENT Surface" : "Classic Surface"}
Screens
{totalScreens}
Components
{totalComponents}
Text Blocks
{totalTextBlocks}
Surface Validation
{params.surface.validation?.passed === false ? params.surface.validation.issues[0] || "存在待优化项" : "当前 surface 已通过基础校验"}
{params.surface.validation?.passed === false ? "待优化" : "通过"}
{screenComponents.slice(0, 6).map((screenComponent) => { const screenIndex = Number(screenComponent.props?.screenIndex || 0); const textStack = getUiSurfaceChildren(params.surface, screenComponent.id).find( (component) => component.type === "detail_text_stack", ); const textBlocks = textStack ? getUiSurfaceChildren(params.surface, textStack.id).filter( (component) => component.type === "detail_text_block", ) : []; const titleBlock = textBlocks.find((component) => component.props?.blockType === "title") || null; const subtitleBlock = textBlocks.find((component) => component.props?.blockType === "subtitle") || null; const isLatestScreen = params.latestScreenValidation?.screenIndex === screenIndex; return (
第 {screenIndex} 屏 {screenComponent.props?.screenType ? ` · ${String(screenComponent.props?.screenType)}` : ""}
{resolveUiSurfaceTextBinding(params.surface, titleBlock, "content") || "未定义标题"}
{subtitleBlock ? (
{resolveUiSurfaceTextBinding(params.surface, subtitleBlock, "content")}
) : null}
{textBlocks.length} 块 {isLatestScreen ? ( {getActionLabel(params.latestScreenValidation?.action)} ) : null}
); })}
); }