Feature: open PDFs in the preview pane - #59
Merged
Merged
Conversation
PDFs previously fell through to "preview is available for code, text, configuration, and common image files" and could only be opened in an external application. WebView2 carries Edge's PDF viewer, so rendering one in the docked pane costs a single entry in the Explorer's browser-preview set. The agent's allowlist deliberately does NOT gain .pdf. A PDF's text, pages, and fields are drawn by that viewer and never reach the DOM, so letting the agent open one would hand it a page that looks successfully loaded and inspects as completely empty — the same false "there is nothing here" conclusion an uninspected frame used to produce. For the case where the user opens a PDF and then asks about it, DOM operations now report what the document is instead of returning an empty snapshot, and point at a screenshot on a vision-capable model. Screenshot support operations stay exempt, since an image is precisely how a PDF should be judged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Selecting a PDF in the file Explorer now opens it in the preview pane, using the browser's own PDF viewer — scroll, zoom, search, print. Previously PDFs were not previewable at all and could only be handed off to another application.
Why this matters
The preview pane already renders web pages through an embedded browser, and that browser ships with a full PDF viewer. Wiring PDFs to it is a single entry in the list of file types the pane handles, so a common document type stops being a dead end in the file tree.
The deliberate limitation
The assistant cannot read PDFs, and this change does not give it that ability.
A PDF is drawn by the browser's viewer. Its text, pages, and form fields never appear in the page structure the assistant inspects. If the assistant were allowed to open one, it would see a page that loaded successfully and contained nothing at all — and would report the document as empty or broken.
That is the same false conclusion this project has already fixed twice: once for embedded forms inside frames, and once for elements hidden behind overlays. So this PR keeps the two paths separate on purpose:
Screenshot operations stay exempt from that refusal, because an image is exactly the right tool for a PDF.
What this is not
Text extraction. Making a PDF's contents readable to the assistant is a separate and much larger piece of work belonging in the engine's file-reading tools, not in the preview pane. It was considered and deliberately deferred; nothing here blocks it later.
Scope and risk
Low. One file type added to the preview pane's list, and one guard in the page-inspection script. No change to how web previews, screenshots, or any existing tool behaves. Large PDFs stream from the same local host the pane already uses.
Verification
Worth a manual check: open a real PDF from the file tree and confirm the browser viewer appears in the pane. That path needs a live window and a real file, so no test harness here covers it.