Skip to content

fix(doc-preview): serve web fonts (.woff2/.woff/.ttf/.otf) from the preview reader - #26629

Closed
noan98 wants to merge 2 commits into
stablyai:mainfrom
noan98:fix/doc-preview-web-fonts
Closed

noan98 wants to merge 2 commits into
stablyai:mainfrom
noan98:fix/doc-preview-web-fonts

Conversation

@noan98

@noan98 noan98 commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When Orca previews an HTML page that lives on a remote machine, the page's custom fonts were not sent along, so the page fell back to system fonts and showed "files could not be loaded". Now fonts are sent the same way images are.

What Changed

Before: opening a local HTML file in the document preview on a runtime (or SSH) workspace showed "4 files in this document could not be loaded", and every @font-face (.woff2, .woff, .ttf, .otf) failed with a 415 unsupported-asset.

After: those font files load and the page renders with its own fonts.

Mechanism: readAuthorizedDocPreviewFile (src/shared/doc-preview-file-access.ts) only returns bytes for extensions in its binary MIME table (images + PDF). Any other binary comes back as empty content with no type, which toOutcome in doc-preview-file-reader.ts correctly reports as 415. The protocol's content-type table and CSP (font-src 'self' data:) already expect fonts, so the gap was only in the reader table. This adds the four font types there.

Why

The reader table is the single place that decides which binaries a host is willing to send, and both the runtime (files.readDocPreview) and the SSH relay (fs.readDocPreview) use it, so one entry fixes both. The native-chat attachment store also calls this reader but gates on image extensions first, so it is unaffected.

Wire compatibility: an older host still answers with no type, and the client keeps reporting that as unsupported-asset exactly as before; a newer host answering an older client sends base64 + mimeType, which older clients already decode. The comment that said fonts are refused "by design" on SSH is updated to describe that older-host case instead.

Linked Issue

Fixes #26614

Visual Proof

N/A: this is a host-side reader change; I could not run the Electron app with a paired runtime in my environment. The behavior is covered by a unit test that reads real font files through the reader.

Testing

  • vitest run src/shared/doc-preview-file-access.test.ts src/main/browser/doc-preview-file-reader.test.ts src/main/browser/doc-preview-protocol.test.ts: 48 passed. The new test fails without the change.

  • tsc --noEmit -p config/tsconfig.node.json: passes.

  • oxlint and oxfmt on the changed files: clean.

  • Tested on Linux only (unit tests); not manually tested in the app.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Written with Claude Code (Anthropic) and reviewed by the submitter.

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Security: only adds four font MIME types to an already-authorized, size-capped read; path authorization is unchanged. Cross-platform: no platform-specific code. SSH: the relay picks up the same table on its next upload.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

noan98 and others added 2 commits October 8, 2026 17:00
…ader

A previewed HTML page's @font-face files (.woff2/.woff/.ttf/.otf) came back
from readAuthorizedDocPreviewFile as an empty, untyped binary, which the
orca-preview protocol turns into a 415 unsupported-asset. Type them like
images and PDFs so their bytes are returned.

Fixes stablyai#26614

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…e refused by design

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@noan98
noan98 force-pushed the fix/doc-preview-web-fonts branch from 7c212df to ec37957 Compare October 8, 2026 17:05
@coderabbitai

coderabbitai Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b7f04030-ddec-4a6e-b7e0-cc82427730d6
📥 Commits

Reviewing files that changed from the base of the PR and between 51e2895 and ec37957.

📒 Files selected for processing (4)
  • src/main/browser/doc-preview-file-reader.test.ts
  • src/main/browser/doc-preview-file-reader.ts
  • src/shared/doc-preview-file-access.test.ts
  • src/shared/doc-preview-file-access.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The preview reader now classifies .woff, .woff2, .ttf, and .otf files as binary files and assigns each a MIME type. Tests verify base64 content and MIME types for authorized font files. Comments now describe host-dependent support for font file formats.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to ec379

The change enables local font resources in document previews, and the inspected runtime and SSH paths pass and serve them without filtering. No concrete merge-blocking issue remains.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: serving web fonts from the document preview reader.
Description check ✅ Passed The description includes all required sections, explains the user impact and implementation, links issue #26614, documents testing and limitations, and addresses security, compatibility, SSH, and perf…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 4…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

nwparker added a commit that referenced this pull request Oct 9, 2026
Records the retained adapted contribution from #26629 in replacement PR #26849.

Co-authored-by: noan98 <[email protected]>
@nwparker

Copy link
Copy Markdown
Contributor

Thanks @noan98 for tracking this down! This is already fixed on main by #26849 (38aa54f): DOC_PREVIEW_BINARY_MIME_TYPES now includes FONT_FILE_MIME_TYPES (.woff/.woff2/.ttf/.otf), so the shared preview reader used by both the runtime and SSH paths returns @font-face files as typed binary bytes instead of a 415. (Your work is credited as co-author on that commit.) If you still see fonts failing to load in a remote HTML preview on the latest build, please comment or reopen.

@nwparker nwparker closed this Oct 26, 2026
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.

[Bug]: HTML document preview drops web fonts (.woff2/.woff) — runtime reader returns them empty, preview answers 415 unsupported-asset

2 participants