feat: gate decision-type validation, force-advance, and frontend fixes
Gate (tht-gate.js): - Pre-validate decision types against workflow.yaml before showing reviewer widget - Reject decisions emitted by later phases (min-phase check) - Copy top-level `kind` into artifact when model forgets it (prevents loop) - Force-advance on reviewer_decide/schema_linking when advance:true — skip redundant reviewer_confirm gate Backend: - Emit agent_end on clean Pi exit (code 0 + bridge idle) instead of marking failed Frontend: - Strip <think> tags from transcript and activity panel - Fix mermaid render with offscreen container + cleanup - Graceful mermaid error: show source code instead of red error, fall back to table Workflow: - F2 now emits table_promoted and table_excluded (early schema linking decisions) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,8 @@ import { isNearBottom } from "./activityScroll";
|
||||
function transcriptLines(transcript: Array<{ text: string }>): string[] {
|
||||
return transcript.flatMap(({ text }) =>
|
||||
text
|
||||
.replace(/<think>[\s\S]*?<\/think>/g, "")
|
||||
.replace(/<\/?think>/g, "")
|
||||
.split("\n")
|
||||
.map((line) => line.trimEnd())
|
||||
.filter((line) => line.trim() !== ""),
|
||||
|
||||
@@ -25,6 +25,8 @@ export function isVisibleModelActivity(entry: ActivityEntry): boolean {
|
||||
|
||||
export function formatModelActivity(text: string): string {
|
||||
return text
|
||||
.replace(/<think>[\s\S]*?<\/think>/g, "")
|
||||
.replace(/<\/?think>/g, "")
|
||||
.replace(/\r\n?/g, "\n")
|
||||
.replace(/([.!?])(?=[A-ZÀ-ÖØ-Þ])/g, "$1\n\n")
|
||||
.replace(/^[\t ]*[•‣–]\s+/gm, "- ")
|
||||
|
||||
@@ -16,7 +16,7 @@ function MermaidBlock({ code }: { code: string }) {
|
||||
);
|
||||
}, [code]);
|
||||
|
||||
if (error) return <pre className="text-destructive text-xs">{error}</pre>;
|
||||
if (error) return <pre className="overflow-auto rounded-lg bg-muted p-3 text-xs opacity-60">{code}</pre>;
|
||||
if (!svg) return <pre className="text-xs opacity-50">{code}</pre>;
|
||||
// eslint-disable-next-line react/no-danger
|
||||
return <div dangerouslySetInnerHTML={{ __html: svg }} />;
|
||||
|
||||
@@ -116,9 +116,9 @@ export function SchemaLinkingViewer({ linking }: { linking: SchemaLinking }) {
|
||||
if (view !== "chart" || oversized) return;
|
||||
let cancelled = false;
|
||||
const def = buildErDiagram(promoted, linking.joins);
|
||||
renderMermaid(def).then((s) => {
|
||||
if (!cancelled) setSvg(s);
|
||||
});
|
||||
renderMermaid(def)
|
||||
.then((s) => { if (!cancelled) setSvg(s); })
|
||||
.catch(() => { if (!cancelled) setView("table"); });
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
|
||||
@@ -7,6 +7,15 @@ export async function renderMermaid(def: string): Promise<string> {
|
||||
_initialized = true;
|
||||
}
|
||||
const id = `mermaid-${Math.random().toString(36).slice(2)}`;
|
||||
const { svg } = await mermaid.render(id, def);
|
||||
return svg;
|
||||
const container = document.createElement("div");
|
||||
container.style.position = "absolute";
|
||||
container.style.left = "-9999px";
|
||||
document.body.appendChild(container);
|
||||
try {
|
||||
const { svg } = await mermaid.render(id, def, container);
|
||||
return svg;
|
||||
} finally {
|
||||
container.remove();
|
||||
document.getElementById(id)?.remove();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user