fix(desktop): PDFs in the preview can be annotated#24022

merged2
main
GitHub fork: issue-watch/24002
opened28d agobySshivam
View on GitHubTwo-way sync enabledPR last imported 28d ago

Refs #24002

Problem

In the desktop app, Annotate does nothing on a PDF. Select shows no outline, clicks do nothing, and Region or Draw drags leave no mark. Chromium draws a PDF in its own viewer frame, and the annotation picker only listens to the tab's page, so it never gets the pointer input.

I reproduced this with a PDF from a remote workspace, which opens in a tab on this computer (since #17316). That matches #24002, but the issue doesn't say how the reporter opened the PDF, so this PR refs it instead of closing it.

Fix

In PickPreload.ts, when the page is a PDF (document.contentType === "application/pdf"), annotation adds a transparent layer above the viewer, under the annotation UI, so pointer input reaches the picker. The layer also takes keyboard focus, because Chrome's PDF viewer otherwise keeps it and Escape and the R/D/E tool keys never reach the annotator. Annotation starts on Region for PDFs because a PDF has no elements to select (the PDF page's own DOM is an empty <body>). The layer goes away when annotation ends, so the PDF scrolls and clicks normally again. Other pages are unchanged.

Evidence

Linux desktop app (dev build) on a remote environment, opening a workspace PDF in the browser panel. The URL bar and the annotation's URL are masked because they show a private address.

Before (main): Select shows nothing over the PDF, and a Region drag draws nothing.

https://github.com/user-attachments/assets/d0fb648a-234e-47b0-99ab-e38547f5b407

After (this branch): annotation starts on Region, the drag draws the region, the note is attached, and the composer chip carries a screenshot of that part of the PDF.

https://github.com/user-attachments/assets/19652c6c-acd3-46d8-a29c-4547c754fbe7

Draw also works on the PDF, and leaving annotation removes the layer. On the second commit's build, after clicking into the PDF (keys then went to the viewer), starting Annotate let d switch to Draw and Escape end annotation. The recordings are from the first commit; the pointer behavior they show is unchanged.

Not covered

  • Tabs streamed from the environment's browser (agent-opened tabs, and web and mobile clients) still have no Annotate button for any page, PDF or not. That's the separate limit noted in #16934.
  • No unit test: the bug only exists with Chromium's PDF viewer frame, and the desktop tests have no DOM to load the preload in. The recordings above are the proof.

vp run check:changed passes.

🤖 Generated with Claude Code (Opus 5.5)

Checks

22 successful · 11 skipped · 1 neutral
All checks passed
a63f9a9

Added 1 commit

  • fix(desktop): annotate PDFs in the preview85f31a7
Synced from GitHub

Approvability

Verdict: Needs Human Approval

Macroscope's review found this PR requires human approval — This adds PDF-specific pointer and keyboard interception and changes PDFs to start annotation in Region mode instead of Select mode. The scope is narrow, but the altered starting mode is a product-default change that warrants human review.

You can add or adjust custom eligibility rules. Learn more.

Synced from GitHub

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 85f31a782714516da3850288ae1f854567934092 and a63f9a93779bea3b25e1d41249a21c2164135e94.

đź“’ Files selected for processing: 1
  • apps/desktop/src/preview/PickPreload.ts

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

📝 Walkthrough

The desktop preview creates a focusable input layer for PDF annotation sessions. PDF sessions start in marquee mode, and element picking skips the input layer. Other documents retain the select mode default.

Changes: PDF annotation input

Layer / File(s)Summary
Create and manage the PDF input layer
apps/desktop/src/preview/PickPreload.ts
For PDF documents, the preview creates and focuses an input layer and starts in marquee mode. Element picking skips the layer.

Priority: âž– Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: maria-rcks, not-compromised

Merge Risk: ⚪ Minimal · up to a63f9

The reported PDF region-selection concern does not apply to this viewer configuration. No identified issue remains to block merging after normal checks.

Pre-merge checks: Passed 4
Check nameStatusExplanation
Title checkPassedThe title clearly and concisely states the main change: enabling PDF annotation in the desktop preview.
Description checkPassedThe description explains the problem, implementation, scope, verification results, limitations, issue reference, and UI evidence. It uses a “Fix” section instead of the template’s “Change” heading and…
Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the problem, implementation, scope, verification results, limitations, issue reference, and UI evidence. It uses a “Fix” section instead of the template’s “Change” heading and an “Evidence” section instead of “Verification,” but the required information is present and sufficiently detailed.

✨ Finishing Touches
đź§Ş Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Added 1 commit

  • fix(desktop): Escape and tool keys work while annotating a PDFa63f9a9