Scanned docs are messy — duplicate transcriptions (typed + handwritten), two classification variants of the same narrative, OCR noise, repeated banners. The doc page showed raw chunks, so everything appeared twice. 40_reading_version.py generates ONE clean, deduplicated, well-structured bilingual Markdown reading version per doc (Sonnet): merges duplicate versions without losing unique lines, drops page furniture, formats transcripts as dialogue. Faithful — invents nothing; redactions kept as markers. /d/[docId] now defaults to a "📖 leitura" tab rendering this clean version, with "🔍 trechos · scan original" preserving the faithful per-chunk + per-page scan view. reading.md lives in raw/<doc>--subagent/ alongside the chunks. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
62 lines
1.9 KiB
TypeScript
62 lines
1.9 KiB
TypeScript
"use client";
|
|
|
|
/**
|
|
* DocReadingView — toggles between the clean LLM reading version (default) and
|
|
* the raw extracted chunks. The per-page "ver scan original" stays available
|
|
* inside the chunks renderer. When no reading version exists, only chunks show.
|
|
*/
|
|
import { useState } from "react";
|
|
import { MarkdownBody } from "@/components/markdown-body";
|
|
import { DocRendererV2 } from "@/components/doc-renderer-v2";
|
|
import type { ParsedChunk } from "@/lib/chunks";
|
|
|
|
type View = "reading" | "chunks";
|
|
|
|
export function DocReadingView({
|
|
docId,
|
|
reading,
|
|
chunksByPage,
|
|
}: {
|
|
docId: string;
|
|
reading: string | null;
|
|
chunksByPage: Array<[number, ParsedChunk[]]>;
|
|
}) {
|
|
const [view, setView] = useState<View>(reading ? "reading" : "chunks");
|
|
|
|
return (
|
|
<div>
|
|
{reading && (
|
|
<div className="mb-6 flex items-center gap-2 font-mono text-xs">
|
|
<button
|
|
onClick={() => setView("reading")}
|
|
className={`px-3 py-1.5 border rounded ${
|
|
view === "reading"
|
|
? "border-[#00ff9c] text-[#00ff9c] bg-[rgba(0,255,156,0.08)]"
|
|
: "border-[rgba(0,255,156,0.20)] text-[#8896aa]"
|
|
}`}
|
|
>
|
|
📖 leitura
|
|
</button>
|
|
<button
|
|
onClick={() => setView("chunks")}
|
|
className={`px-3 py-1.5 border rounded ${
|
|
view === "chunks"
|
|
? "border-[#7fdbff] text-[#7fdbff] bg-[rgba(127,219,255,0.08)]"
|
|
: "border-[rgba(127,219,255,0.20)] text-[#8896aa]"
|
|
}`}
|
|
>
|
|
🔍 trechos · scan original
|
|
</button>
|
|
</div>
|
|
)}
|
|
|
|
{view === "reading" && reading ? (
|
|
<article className="markdown-body max-w-3xl text-[#c8d4e6] leading-relaxed">
|
|
<MarkdownBody>{reading}</MarkdownBody>
|
|
</article>
|
|
) : (
|
|
<DocRendererV2 docId={docId} chunksByPage={chunksByPage} />
|
|
)}
|
|
</div>
|
|
);
|
|
}
|