Files
ThothII/frontend/src/viewers/artifactV2.ts
T
marcopanandClaude Fable 5 b59b57c4e6 fix(review-gates): green success badges, null-safe preview rows, optional section items
- Extract shared statusBadgeClass() helper (src/viewers/statusBadge.ts) so
  SqlViewer, CteResultViewer and PhaseSummaryViewer can't drift: ok/success/
  passed/promoted render green (--success), warn renders amber (--warning),
  error/failed stay destructive red, everything else stays neutral outline.
  Previously CteResultViewer/PhaseSummaryViewer mapped "ok"/"promoted" to the
  default badge variant, which is bg-primary (GSD red) — success states
  rendered red.
- enrich.js: buildCteResultV2 now falls back preview.rows to [] instead of
  null when last_test.preview_rows is missing (pre-upgrade ok records), and
  CteResultViewer reads result.preview?.rows?.length with a null-safe
  fallback so it degrades to the "No preview rows" empty state instead of
  crashing.
- PhaseSummaryViewer: section.items is optional (model-authored sections can
  be prose-only); render (section.items ?? []) instead of crashing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 01:37:35 +02:00

122 lines
2.5 KiB
TypeScript

// TypeScript mirrors of the v2 artifact payload contracts (see
// .superpowers/sdd/review-gates-v2/contracts.md). Detection everywhere is
// `data.schema_version === 2` + a shape-guard; anything else falls back to the
// legacy renderers in ArtifactView.
// --- A. cte_plan v2 ---------------------------------------------------------
export interface CtePlanTable {
name: string;
description?: string;
}
export interface CtePlanFilter {
column: string;
op: string;
value: string;
description?: string;
rationale?: string;
}
export interface CtePlanCte {
name: string;
index: number;
purpose?: string;
rationale?: string;
depends_on?: string[];
tables?: CtePlanTable[];
keys?: string[];
filters?: CtePlanFilter[];
output_columns?: string[];
}
export interface CtePlanV2 {
schema_version: 2;
question?: string;
strategy?: string;
ctes: CtePlanCte[];
}
// --- B. cte_result v2 --------------------------------------------------------
export interface CteResultColumn {
name: string;
description?: string;
}
export interface CteResultPreview {
columns: string[];
rows: unknown[][];
}
export interface CteResultV2 {
schema_version: 2;
name: string;
index: number;
total: number;
purpose?: string;
rationale?: string;
depends_on?: string[];
sql: string;
status: "ok" | "error" | string;
execution_ms?: number;
row_sample?: number;
warnings?: string[];
sql_hash?: string;
columns?: CteResultColumn[];
preview?: CteResultPreview;
note?: string;
}
// --- C. phase summary v2 -----------------------------------------------------
export interface PhaseMeta {
id: string;
num: number;
name: string;
}
export interface PhaseCheck {
label: string;
status: "ok" | "warn" | "fail" | string;
detail?: string;
}
export interface PhaseSectionItem {
label: string;
table?: string;
column?: string;
value?: string;
kind?: "table" | "column" | "filter" | "join" | "metric" | "note" | string;
description?: string;
rationale?: string;
}
export interface PhaseSection {
title: string;
items?: PhaseSectionItem[];
}
export interface PhaseTableColumn {
name: string;
description?: string;
value_filter?: string;
}
export interface PhaseTable {
name: string;
role: "promoted" | "excluded" | string;
description?: string;
columns?: PhaseTableColumn[];
}
export interface PhaseSummaryV2 {
schema_version: 2;
phase: PhaseMeta;
summary?: string;
checks?: PhaseCheck[];
sections?: PhaseSection[];
tables?: PhaseTable[];
open_questions?: string[];
}