Skip to content

PDF file previews show "Preview not available for application/pdf" #1985

Closed

Description

@jsilets

Summary

Opening any PDF in the file preview panel shows an error message instead of
the document. The content routes already serve the bytes with the correct
mime type; the app has no branch for application/pdf, so every PDF falls
through to the unsupported state. Images, video, CSV, and markdown all
render.

Versions and environment

  • bb 0.39.0, desktop app, macOS 26
  • Code path confirmed unchanged on main at b61ec88

To be precise about the repro: I observed the message in the packaged 0.39.0
desktop app, and confirmed by reading main that the same code path still
produces it. I did not click through a from-source build to see the message
a second time.

Steps to reproduce

  1. Open a thread.
  2. Open any PDF in the preview panel, either from a file link in the
    timeline or from a file tab.

Expected vs actual

Expected: the document renders, the way images, video, CSV, and markdown do.

Actual, verbatim:

Preview not available for application/pdf.

The path header and open-in-editor action render normally. Only the body
shows the error.

Evidence

Image

buildFilePreview tests the mime type in this order: image types, known
text types, a UTF-8 fallback, then video types. application/pdf matches
none of them, so the function returns kind unsupported:

export function buildFilePreview(args: BuildFilePreviewArgs): FilePreview {
const base = {
mimeType: args.mimeType,
name: args.name,
path: args.path,
url: args.url,
};
if (args.mimeType.startsWith("image/")) {
return {
kind: "image",
...base,
};
}
if (isKnownTextMimeType(args.mimeType)) {
const textContent = decodeDeclaredTextContent(args.contentBytes);
if (textContent === null) {
return {
kind: "unsupported",
...base,
};
}
return {
kind: "text",
...base,
content: textContent,
};
}
const fallbackTextContent = decodeUtf8Text(args.contentBytes);
if (fallbackTextContent !== null) {
return {
kind: "text",
...base,
content: fallbackTextContent,
};
}
if (args.mimeType.startsWith("video/")) {
return {
kind: "video",
...base,
};
}
return {
kind: "unsupported",
...base,
};
}

SecondaryPanelFilePreview then renders the message above:

return (
<FilePreviewSurface
path={activePath}
copyPath={copyPath}
onSelectionAddToChat={onSelectionAddToChat}
onOpenInEditor={onOpenInEditor}
onRefresh={onRefresh}
isRefreshing={isRefreshing}
statusLabel={statusLabel}
state={{
kind: "error",
message: `Preview not available for ${filePreview.mimeType}.`,
}}
/>
);

The server side already works. Against a dev server built from this
checkout, a GET to /api/v1/threads/:id/host-files/content for a PDF
returns 200, content-type: application/pdf, and the raw bytes.

What you ruled out

  • Not a server or route problem. The content route returns the correct mime
    type and bytes; see above.
  • Not a duplicate. No open or closed issue mentions PDF previews. HEIC images aren't rendered in the UI #1670 is
    the same class of gap (HEIC does not render) but a different format, and
    HEIC needs decoding rather than a new branch.
  • Not configuration. No plugin provides PDF rendering, and nothing in
    settings changes this path.

Suggested priority and effort

Small. Chromium renders a PDF with its built-in viewer when a frame loads an
application/pdf response, so the fix is one new preview kind plus an
iframe, with no PDF library and no new dependency. Same shape and files as
#520, which added CSV previews.

PR open at #1979.

Checks

  • I reproduced this on the latest release or on main, or I say above that I could not.
  • I searched open and closed issues for the same problem.
  • If an agent wrote this, the body ends with > AGENT GENERATED: by <model> and links the thread or report.

AGENT GENERATED: by Claude Opus 5 and Claude Fable 5

Activity

  1. added theissue type on Aug 20, 2026
  2. added
    ui
    on Aug 20, 2026
  3. SawyerHood commented on Aug 20, 2026

    @SawyerHood
    Collaborator

    Reproduction & root-cause report: https://get-bb.github.io/reports/issues/1985.html

    • Verdict: REPRODUCED · root-cause confidence: high
    • Root cause (short): buildFilePreview() in packages/client-core/src/file-preview.ts (moved from apps/app by Extract platform-neutral client logic into @bb/client-core #1986) has no branch for application/pdf, so binary PDFs fall through to kind "unsupported" which SecondaryPanelFilePreview renders as "Preview not available for application/pdf." (all-ASCII PDFs are instead mis-rendered as text by the UTF-8 fallback); the server already serves PDFs correctly.
    • Linked PR review: Render PDF file previews instead of "Preview not available" #1979 → REQUEST CHANGES — Correct approach and verified rendering PDFs in Chromium and Electron 41 (both data: URL and API-URL frames; sandboxed frames confirmed blank), but the PR is CONFLICTING with main because Extract platform-neutral client logic into @bb/client-core #1986 moved file-preview.ts to packages/client-core, and once rebased the new 'pdf' kind breaks @bb/mobile typec
    • Proposed fix: Add a PdfFilePreview kind in packages/client-core/src/file-preview.ts returned for application/pdf before the text/UTF-8 checks (export from client-core and the apps/app re-export); in apps/app add {kind:"pdf",url} to FilePreviewState rendered as a full-height <iframe src={url}> with no sandbox (sandbox blocks Chromium's viewer), route it in SecondaryPanelFilePreview, and include pdf in buildEnvironmentFilePreview's data: URL rewrite; in apps/mobile handle the pdf case in file-preview-model.ts and FilePreviewView.tsx (map to unsupported or render in a WebView). Consider a byte route or cap for…
    • Caveats: Reproduced on Linux web app + Electron dev shell under Xvfb, not the macOS packaged 0.39.0 app from the issue (code path is platform-neutral). PR Render PDF file previews instead of "Preview not available" #1979 was evaluated by locally merging it onto c7c6642 and relocating the classifier hunk to packages/client-core; the author's own branch does not build against main as-is. The Electron desktop used --no-sandbox due to the SUID sandbox helper on this …

    The report has copy-paste repro steps, screenshots where the bug is visual, code permalinks at the base commit, and repro artifacts. It was independently re-run by a second agent (see its Verification section).

    AGENT GENERATED: by Claude Opus 5

  4. added
    confirmed-repro
    on Aug 20, 2026
  5. jsilets commented on Aug 20, 2026

    @jsilets
    ContributorAuthor

    Rebased #1979 onto current main with the requested changes:

    • The classifier now lives in packages/client-core/src/file-preview.ts, with PdfFilePreview re-exported through apps/app/src/lib/file-preview.ts.
    • apps/mobile maps the new pdf kind to unsupported, so mobile behavior is unchanged. A WebView preview would only work on iOS (WKWebView renders PDFs, Android's WebView does not), so a native mobile PDF view is a separate change.
    • Added the missing test for the data: URL branch of buildEnvironmentFilePreview: an application/pdf response returns kind: "pdf" with a data:application/pdf;base64, URL.
    • Full-repo typecheck passes, including @bb/mobile and @bb/client-core.

    On size: the daemon caps non-image reads at 25 MiB (NON_IMAGE_FILE_SIZE_LIMIT_BYTES in apps/host-daemon/src/command-handlers/file-read.ts), so about 33 MB of base64 is the worst case, and image and video previews on this surface already pay the same cost. The better fix is a raw byte route for diff-side reads, so image, video, and pdf src attributes never need a data: URL. That helps all three kinds, so I would rather do it as a follow-up PR than grow this one. I can take that on if you want it.

  6. added a commit that references this issue on Aug 20, 2026
    5154a94
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-reproui

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions