artifacts tab: inline PDF preview via iframe (task #19)

This commit is contained in:
Omar Sobh
2026-07-19 18:43:46 -07:00
parent 267b28a762
commit 278cbf90b7
@@ -83,6 +83,7 @@ export function MissionCanvas({
const [launching, setLaunching] = useState(false); const [launching, setLaunching] = useState(false);
const [refining, setRefining] = useState(false); const [refining, setRefining] = useState(false);
const [phaseBusy, setPhaseBusy] = useState<string | null>(null); const [phaseBusy, setPhaseBusy] = useState<string | null>(null);
const [pdfPreviewId, setPdfPreviewId] = useState<string | null>(null);
const load = useCallback(async () => { const load = useCallback(async () => {
if (!selectedId) { if (!selectedId) {
@@ -567,9 +568,14 @@ export function MissionCanvas({
{mission.artifacts.length === 0 ? ( {mission.artifacts.length === 0 ? (
<Empty label="no artifacts yet — phases produce them as they run" /> <Empty label="no artifacts yet — phases produce them as they run" />
) : ( ) : (
mission.artifacts.map((a) => ( mission.artifacts.map((a) => {
const isPreviewing = pdfPreviewId === a.id;
return (
<div <div
key={a.id} key={a.id}
style={{ display: "flex", flexDirection: "column", gap: 8 }}
>
<div
style={{ style={{
padding: 11, padding: 11,
borderRadius: 10, borderRadius: 10,
@@ -590,6 +596,20 @@ export function MissionCanvas({
</div> </div>
</div> </div>
{a.rendered_pdf_path ? ( {a.rendered_pdf_path ? (
<>
<button
type="button"
onClick={() =>
setPdfPreviewId(isPreviewing ? null : a.id)
}
style={{
...secondaryBtn,
padding: "5px 10px",
fontSize: 11,
}}
>
{isPreviewing ? "Hide" : "Preview"}
</button>
<a <a
href={a.rendered_pdf_path} href={a.rendered_pdf_path}
target="_blank" target="_blank"
@@ -601,8 +621,9 @@ export function MissionCanvas({
textDecoration: "none", textDecoration: "none",
}} }}
> >
Open PDF Open
</a> </a>
</>
) : a.render_pdf_status !== "skip" ? ( ) : a.render_pdf_status !== "skip" ? (
<span <span
style={{ style={{
@@ -618,7 +639,22 @@ export function MissionCanvas({
</span> </span>
) : null} ) : null}
</div> </div>
)) {isPreviewing && a.rendered_pdf_path && (
<iframe
src={a.rendered_pdf_path}
title={a.title ?? a.path}
style={{
width: "100%",
height: 640,
border: "1px solid rgba(255,255,255,.06)",
borderRadius: 8,
background: "#0a0a0d",
}}
/>
)}
</div>
);
})
)} )}
</div> </div>
)} )}