diff --git a/apps/fabro-web/app/routes/run-files.render.test.tsx b/apps/fabro-web/app/routes/run-files.render.test.tsx index 962c9b4e2..3fcb01b89 100644 --- a/apps/fabro-web/app/routes/run-files.render.test.tsx +++ b/apps/fabro-web/app/routes/run-files.render.test.tsx @@ -258,6 +258,22 @@ describe("RunFiles rendering", () => { expect(multiFileDiffCalls).toHaveLength(1); }); + test("shows deleted Markdown files as a diff instead of an empty preview", () => { + currentFilesPayload = makePayload(1); + currentFilesPayload.data[0] = { + change_kind: "deleted", + old_file: { name: "docs/plan.md", contents: "# Plan\n\nReview this\n" }, + new_file: { name: "", contents: "" }, + }; + + const renderer = renderRunFiles(); + + expect(renderer.root.findAllByProps({ "data-markdown-preview": "true" })).toHaveLength(0); + expect(multiFileDiffCalls).toHaveLength(1); + expect(multiFileDiffCalls[0].oldFile.contents).toBe("# Plan\n\nReview this\n"); + expect(multiFileDiffCalls[0].newFile.contents).toBe(""); + }); + test("passes the selected URL scope to useRunFiles", () => { currentFilesPayload = makePayload(1); diff --git a/apps/fabro-web/app/routes/run-files.tsx b/apps/fabro-web/app/routes/run-files.tsx index 5c68d7e5e..c44f72a53 100644 --- a/apps/fabro-web/app/routes/run-files.tsx +++ b/apps/fabro-web/app/routes/run-files.tsx @@ -255,6 +255,7 @@ const RunFileRow = memo(function RunFileRow({ const oldPath = file.old_file.name || display; const newPath = file.new_file.name || display; const canPreviewMarkdown = + file.change_kind !== "deleted" && /\.md$/i.test(newPath) && newContents != null && !placeholder; const [showMarkdownPreview, setShowMarkdownPreview] = useState(canPreviewMarkdown);