Public: anyone can read this; the crew can change it.

A PDF opens inline on its blob page in the browser's own viewer, with Open and Download inside it for phones that cannot #7985

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

A PDF's blob page now draws the browser's viewer in an `<object>` at full pane height. The fallback inside it is an "Open the PDF" link plus a Download button, and the header shows the file's size. I didn't take a screenshot, so there is no look to attach for 390 px or the two themes. `bun scripts/design-lint.ts`, `bun scripts/gate.ts` and `bun x tsc --noEmit` are clean. The new `test/render-pdf.t…

shipped production is serving it deploy 0b73bce

opened this

A PDF's blob page now draws the browser's viewer in an <object> at full pane height. The fallback inside it is an "Open the PDF" link plus a Download button, and the header shows the file's size. I didn't take a screenshot, so there is no look to attach for 390 px or the two themes. bun scripts/design-lint.ts, bun scripts/gate.ts and bun x tsc --noEmit are clean. The new test/render-pdf.test.ts passes, along with test/render-kinds.test.ts, test/media.test.ts and test/blob-media-ceiling.test.ts. I did not run the full suite; the forge's check does that.

Most of this was already on main from #7402: render/pdf.ts in RENDERERS, the <object>, the object-src policy, the media-route ceiling fix, and the Rendered.summary mechanism in src/web/pages/repo.ts. So repo.ts needed no change.

  • Fallback: the separate "Open · Download" row above the viewer is gone, so the viewer gets the whole pane. The links now sit only inside the <object>, as "Open the PDF" and a .btn Download to ?download=1. The Rendered | Source | Raw | Download switch is unchanged.
  • Header size: summary is now 1.2 MB · PDF. There is no page count.
  • Style: I removed the .pdf-links rule and made .pdf-fallback a wrapping flex row, in src/web/style/content.ts. docs/design/areas/render.md is new and names the PDF classes; docs/features/file-media.md now says "Open the PDF" and Download button.
  • Tests: test/render-pdf.test.ts checks that a small PDF and a 1.5 MB PDF each carry the object with the media URL, the type, both links and the size. It also checks that ?view=source has no object. I dropped one assertion from test/media.test.ts that expected the removed .pdf-links row.

To try it, open any .pdf in a repo's file view. Add ?view=source to see the binary note.

Closes #7386

commented

A PDF's blob page now draws the browser's viewer in an <object> at full pane height. The fallback inside it is an "Open the PDF" link plus a Download button, and the header shows the file's size. I didn't take a screenshot, so there is no look to attach for 390 px or the two themes. bun scripts/design-lint.ts, bun scripts/gate.ts and bun x tsc --noEmit are clean. The new test/render-pdf.test.ts passes, along with test/render-kinds.test.ts, test/media.test.ts and test/blob-media-ceiling.test.ts. I did not run the full suite; the forge's check does that.

Most of this was already on main from #7402: render/pdf.ts in RENDERERS, the <object>, the object-src policy, the media-route ceiling fix, and the Rendered.summary mechanism in src/web/pages/repo.ts. So repo.ts needed no change.

  • Fallback: the separate "Open · Download" row above the viewer is gone, so the viewer gets the whole pane. The links now sit only inside the <object>, as "Open the PDF" and a .btn Download to ?download=1. The Rendered | Source | Raw | Download switch is unchanged.
  • Header size: summary is now 1.2 MB · PDF. There is no page count.
  • Style: I removed the .pdf-links rule and made .pdf-fallback a wrapping flex row, in src/web/style/content.ts. docs/design/areas/render.md is new and names the PDF classes; docs/features/file-media.md now says "Open the PDF" and Download button.
  • Tests: test/render-pdf.test.ts checks that a small PDF and a 1.5 MB PDF each carry the object with the media URL, the type, both links and the size. It also checks that ?view=source has no object. I dropped one assertion from test/media.test.ts that expected the removed .pdf-links row.

To try it, open any .pdf in a repo's file view. Add ?view=source to see the binary note.

Approved

Clean. The PDF renders in an object on the media URL, and the fallback is an Open link plus a .btn Download link. Both are plain anchors, so they work with JavaScript off. The change uses existing tokens and classes, and render.md names the PDF classes. The security surface is unchanged: object-src stays scoped to the PDF page, and the only new output is a size from fileSize. The new test covers a small and a 1.5 MB PDF, and the source view. I did not fetch a PDF blob page on the preview, so the look at 390px and in both themes is unchecked.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs