feat(files): add Markdown PDF download - #6511
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview The PDF path rate-limits exports, reads stored Markdown and authorized embedded images under tighter byte caps than ZIP export, and returns a direct The client download helper and Reviewed by Cursor Bugbot for commit 2b17c81. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryAdds direct server-generated PDF downloads for stored Markdown files while preserving the existing export behavior for other requests.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the prior production font-path and component-props findings are resolved in the current code.
|
| Filename | Overview |
|---|---|
| apps/sim/app/api/files/export/[id]/markdown-pdf.tsx | Adds the bounded Markdown PDF renderer, font fallback selection, image normalization, and document layout. |
| apps/sim/app/api/files/export/[id]/route.ts | Adds an isolated authenticated and rate-limited PDF branch without changing ordinary export behavior. |
| apps/sim/app/workspace/[workspaceId]/files/files.tsx | Adds the Markdown-only Download PDF action with duplicate-request suppression and existing error handling. |
| apps/sim/lib/uploads/client/download.ts | Extends the download helper to request and save PDF exports through the binary route contract. |
| docker/app.Dockerfile | Copies runtime fallback-font packages required by standalone PDF rendering. |
Sequence Diagram
sequenceDiagram
participant U as Files UI
participant E as Export API
participant S as Object Storage
participant R as PDF Renderer
U->>E: "GET /api/files/export/:id?format=pdf"
E->>E: Authenticate, authorize, rate-limit
E->>S: Read stored Markdown
E->>S: Resolve and read authorized images
E->>R: Render Markdown and images
R-->>E: PDF buffer
E-->>U: PDF attachment
Reviews (2): Last reviewed commit: "fix(files): preserve PDF image links and..." | Re-trigger Greptile
f3a00a2 to
0a6aa50
Compare
d2c8849 to
dc1a853
Compare
9b9a2c9 to
a30daac
Compare
a30daac to
2b17c81
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 46ecbf4. Configure here.

Summary
Adds a Markdown-only Download PDF action to the Files header. It downloads a server-generated PDF directly, without opening print preview.
PDF reuses the existing file export route's authentication and file-access checks, the browser download helper, filename handling, error toast, audit event, and authorized workspace image resolution. It intentionally exports the latest durable stored revision, matching ordinary Markdown Download; neither action forces or waits for a collaborative save.
The optional
format=pdfquery enters an isolated PDF-only branch. Whenformatis absent, the original non-Markdown redirect, raw Markdown response, image-ID ZIP creation and rewriting, filename rules, size limits, telemetry, client fetch behavior, Markdown eligibility rules, and preview behavior remain unchanged—including their existing quirks.The PDF renderer invokes the Files editor's existing Markdown parser directly. Its small lazy
jsdomsetup is private to the PDF renderer; the existing collaboration converter is byte-for-byte identical tostaging, and no shared parser abstraction, collaboration change, or realtime behavior is introduced.The renderer supports headings, paragraphs, marks, lists/task lists, blockquotes, code, tables, links, rules, and authorized embedded images on light A4 pages. PDF-only byte, image-pixel, normalized-image, document-node, and request-rate limits bound server work. Fallback fonts preserve supported multilingual text; unsupported emoji use readable code-point labels.
Type of Change
Testing
bun run type-checkpassedgit diff --checkpassedconverter.tshas no diff fromorigin/stagingChecklist
Screenshots/Videos
No new screenshot is attached in this update because no controllable localhost browser session was available. The action remains the existing Markdown-only Download PDF header action and downloads directly without print preview.