Skip to content

Add an opt-in PDF download opener - #2689

Open
banjerluke wants to merge 3 commits into
get-bb:mainfrom
banjerluke:feat/pdf-download-opener
Open

Add an opt-in PDF download opener#2689
banjerluke wants to merge 3 commits into
get-bb:mainfrom
banjerluke:feat/pdf-download-opener

Conversation

@banjerluke

Copy link
Copy Markdown

Human comments

On my Android 13 eInk tablet (Boox Note Max), PDF links would open a side panel browser but wouldn't display, I assume due to platform limitations. The ideal flow on that device is to download the PDF, which sends it right into the Notes app where I can review and/or annotate it.

What was wrong

The file-opener system could select the built-in preview or a plugin viewer, but it had no first-class download action. This left users dependent on the browser’s PDF preview support, which is unreliable on some tablet browsers, without a persistent or one-off way to download the file.

What changed

  • Added Download as a built-in opener choice for .pdf files under Settings → File openers.
  • Preserved the existing built-in preview as the default when no PDF plugin is selected.
  • Added one-off “Download PDF” and “Open preview” actions to thread file-link context menus, including long-press menus.
  • Routed workspace, thread-storage, and host-file downloads through their existing content endpoints with an optional disposition=attachment query.
  • Added safe Content-Disposition filenames with ASCII fallback and RFC 5987 UTF-8 encoding.
  • Downloads now validate the HTTP response and show an error toast rather than saving an error response as a PDF.
  • Explicit preview actions bypass the saved Download preference.
  • No host-daemon protocol bump was needed because the server-to-daemon wire contract did not change.
  • No new Plugin SDK surface or user-facing CLI setting was added. Existing agent file-reading commands remain unchanged.

How you verified

Added focused coverage for:

  • PDF opener preference persistence and default behavior.
  • Saved and one-off download selection.
  • Explicit preview overrides.
  • Workspace, thread-storage, and host-file download routing.
  • Failed-download error handling.
  • Unresolved workspace routing.
  • Attachment query contracts and Content-Disposition headers.

Commands run:

  • pnpm exec turbo run typecheck --filter=@bb/app --filter=@bb/server --filter=@bb/server-contract
  • pnpm exec turbo run test --filter=@bb/app -- src/lib/file-download.test.ts src/components/secondary-panel/useThreadFileTabs.test.ts src/components/settings/FileOpenersSettingsSection.test.tsx src/lib/plugin-slot-resolvers.test.ts
  • pnpm exec turbo run test --filter=@bb/server -- test/hosts/daemon-file-response.test.ts test/public/public-thread-data.test.ts test/public/public-projects-local-host.test.ts
  • pnpm exec turbo run test --filter=@bb/server-contract -- test/contract.test.ts
  • pnpm exec turbo run build

The focused suites passed with 34 app tests, 90 server tests, and 35 server-contract tests. The full build completed successfully with 18/18 tasks.

Fixes #

AGENT GENERATED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant