Skip to content

fix(editor): route zoom gestures and app zoom to the PDF viewer - #26652

Merged
Jinwoo-H merged 4 commits into
mainfrom
pr-17241-pdf-zoom-rewrite
Oct 8, 2026
Merged

Jinwoo-H merged 4 commits into
mainfrom
pr-17241-pdf-zoom-rewrite

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​187 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​182
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​195 $\color{#cf222e}{\Huge{\mathbf{−}}}$​85 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​110

ELI5

Zooming a PDF in Orca now zooms the PDF. Pinching on a trackpad, Ctrl+scrolling, and the zoom shortcuts (Cmd/Ctrl + =, -, 0) all change the page size, and the spot under your cursor stays put.

What Changed

Before, with a PDF open in an editor tab:

  • Cmd/Ctrl + = / - / 0 changed the code-editor font size. That does nothing visible on a PDF, so the PDF stayed the same.
  • Pinching or Ctrl+scrolling over the PDF just scrolled the document.

After:

  • Pinch and Ctrl+scroll zoom the PDF around the pointer, up to the viewer's 25%–500% limits. Slow pinches move smoothly.
  • The zoom shortcuts zoom the PDF in the focused pane. Reset (0) means fit to width. Any other editor tab still gets editor font zoom.
  • Every zoom path saves the zoom. This covers the toolbar, shortcuts, and pinch/scroll, so reopening the file restores it.
  • Pinch zoom is 2× faster for PDFs and image previews. It used to lag well behind your fingers.

How it works:

  • Gestures. Chromium reports a trackpad pinch as a Ctrl+wheel event. The PDF viewer's pdf.js session now owns a wheel listener on its scroll container. The listener is removed together with the viewer.
  • Zoom math. The listener sets an absolute zoom, then scrolls so the content under the pointer doesn't move. It reuses the image viewer's pinch math.
  • Shortcuts. The main process intercepts zoom shortcuts before the page sees them, so the PDF's old key handler never ran (removed here). Now the zoom bridge first offers the command to a PDF. It only falls back to editor font zoom if no PDF takes it.
  • Which PDF answers. The editor pane already knows whether it is the focused pane; Cmd+S uses that signal. A small React context passes it down, so a PDF in an unfocused split or a background workspace never reacts.

Why

This builds on #17241 by @moeinfinityx, credited as co-author. That PR had the right idea: hook the zoom bridge and reuse the image viewer's pinch math. On current main, though, its gesture path had three problems:

  • Slow pinches did nothing. pdf.js updateScale rounds each step to 0.01, so small pinch steps were lost.
  • The page drifted under the cursor, about 100px per scroll notch. The pointer position was measured from the window, but pdf.js measures from the container.
  • Pinch/scroll zoom wasn't saved.

It also worked out "am I the active PDF?" separately in each viewer, from global state plus DOM checks, and moved listeners around with callback refs. Here that decision comes from the layout, which already knows the focused pane, and each listener lives exactly as long as the viewer it drives.

Pinch speed: the zoom-per-event divisor went from 300 to 150. The per-event cap went from 200 to 100, so a single event still zooms less than 2×. Tracking the fingers exactly (100) would make a mouse Ctrl+scroll notch jump about 2.7×.

Linked Issue

Supersedes #17241 (no separate issue).

Visual Proof

Zoom is an interaction, so screenshots can only show the end state. Measured results are in Testing.

Before (main): the PDF stays at its zoom; Cmd+= only changes the hidden editor font size.
main-before.png

After: a split with the PDF pane focused; Cmd+-, Cmd+= and pinch change the PDF (296% here), and the code pane on the right is unaffected.
rewrite-split-pdf-focused.png

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Automated tests:

  • Wheel math: plain scroll is ignored, the pointer anchor holds, slow pinches add up, zoom stops at the limits.
  • The zoom-request claim.
  • Which PDF answers: a PDF in an unfocused pane does not claim. Checked by mutation: removing the check makes the test fail.
  • Bridge routing.

Gates: pnpm tc and pnpm run check:code-quality:changed pass. In the editor folder plus the zoom-routing tests, 2554 pass; the one failure (rich-markdown-escape-fidelity) also fails on main.

Manual, on macOS dev build. Key and wheel input went through the real before-input-event path:

  • Shortcuts change the PDF (156% → 195% → 156%, reset = fit width), and the editor font is untouched.
  • A Ctrl+scroll notch keeps the content under the pointer fixed.
  • 40 small pinch-sized events build up and reverse exactly.
  • Wheel zoom is kept after closing and reopening the file.
  • Split, code pane focused: Cmd+= is editor font zoom.
  • Split, PDF pane focused: Cmd+= zooms the PDF.
  • No change to markdown preview, Tasks-view app zoom, terminal font zoom, or image pinch.
  • Real trackpad pinch tried by hand.

Windows/Linux: no platform branches. Ctrl+scroll and Ctrl+= go through the same path as on macOS.

Review

Look at:

  • pdf-viewer-session.ts: the wheel listener.
  • pdf-scale-preference.ts: zoomPdfViewerWithWheel.
  • zoom-ipc-bridge.ts and pdf-zoom-request.ts: the command claim.
  • EditorPanel.tsx: the owner context. That file's diff is mostly re-indentation; view it with whitespace hidden.

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

  • Changes are renderer-only.
  • No new IPC, preload API, or wire changes, so nothing changes for SSH, remote hosts, or mobile.
  • No metaKey checks: pinch arrives as Ctrl+wheel on every OS.
  • Performance: one wheel listener per open PDF viewer, active only while Ctrl is held.

Known existing issues, not addressed here:

  • A PDF's Cmd+F handler is not limited to the focused pane.
  • Image previews have the same keyboard-zoom gap that PDFs had.
  • A PDF opened for the first time starts at 100% instead of fit-to-width.

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)

Jinwoo-H and others added 2 commits October 8, 2026 15:30
Ctrl-wheel / trackpad pinch over a PDF scrolled it instead of zooming, and
Cmd/Ctrl +/-/0 changed the (invisible) editor font zoom because the main
process intercepts zoom shortcuts before the PDF's keydown listener runs.

- The pdf.js session owns a non-passive ctrl-wheel listener for its
  container and zooms to an absolute scale anchored at the pointer.
- App zoom commands on an editor tab are first offered to the PDF in the
  command-owning (focused) editor pane; unclaimed commands keep editor font
  zoom.
- Wheel, toolbar and shortcut zoom all record the persisted scale.

Co-authored-by: Infinity_X <[email protected]>
Halve the wheel-zoom divisor so pinch zoom in PDFs and images moves twice as fast, and halve the per-event delta cap so a single event still zooms less than 2x.

Co-authored-by: Infinity_X <[email protected]>
@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: 64c5ddcc-2cbd-4a18-b0a1-220b26daf625
📥 Commits

Reviewing files that changed from the base of the PR and between 2761a8b and f60d40d.

📒 Files selected for processing (3)
  • src/renderer/src/components/editor/pdf-scale-preference.test.ts
  • src/renderer/src/components/editor/pdf-scale-preference.ts
  • src/renderer/src/components/editor/pdf-viewer-zoom-ownership.test.tsx

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


📝 Walkthrough

Walkthrough

Editor zoom requests now reach PDF zoom handling before editor font zoom. A PDF viewer handles those requests only when it owns editor commands. PDF wheel gestures now adjust scale while retaining the pointer’s content position, and changed scales are recorded as preferences. Image wheel-delta normalization and zoom sensitivity values are also updated.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to f60d4

PDF zoom requests and trackpad gestures are routed to the preview, with pointer anchoring covered by the supplied tests. No unresolved user-impacting regression is identified, so this change appears ready to merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.77% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 13 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: routing editor zoom gestures and application zoom commands to the PDF viewer.
Description check ✅ Passed The description is complete and relevant. It covers the user-visible behavior, implementation approach, rationale, linked work, visual proof, testing, platform considerations, known limitations, and c…
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7f841e0a-05d0-4624-a1ca-9b0b3fc73772
📥 Commits

Reviewing files that changed from the base of the PR and between 04ac6d6 and 08a0b8a.

📒 Files selected for processing (13)
  • src/renderer/src/components/editor/EditorPanel.tsx
  • src/renderer/src/components/editor/PdfViewer.tsx
  • src/renderer/src/components/editor/editor-command-owner-context.ts
  • src/renderer/src/components/editor/image-viewer-zoom.test.ts
  • src/renderer/src/components/editor/image-viewer-zoom.ts
  • src/renderer/src/components/editor/pdf-scale-preference.test.ts
  • src/renderer/src/components/editor/pdf-scale-preference.ts
  • src/renderer/src/components/editor/pdf-viewer-session.ts
  • src/renderer/src/components/editor/pdf-viewer-zoom-ownership.test.tsx
  • src/renderer/src/components/editor/pdf-zoom-request.test.ts
  • src/renderer/src/components/editor/pdf-zoom-request.ts
  • src/renderer/src/hooks/ipc-events/zoom-ipc-bridge.ts
  • src/renderer/src/hooks/zoom-routing.test.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.

@Jinwoo-H
Jinwoo-H force-pushed the pr-17241-pdf-zoom-rewrite branch from 08a0b8a to 2761a8b Compare October 8, 2026 19:32

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a59b61dd-4310-4562-84f5-14fd5cd45c74
📥 Commits

Reviewing files that changed from the base of the PR and between 08a0b8a and 2761a8b.

📒 Files selected for processing (1)
  • src/renderer/src/components/editor/pdf-viewer-zoom-ownership.test.tsx

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

pdf.js refreshes its saved location on the next frame, so a second wheel event in the same frame zoomed around the old location and drifted. Call viewer.update() after the anchor scroll. Also make the ownership test's reset assertion depend on reset running.
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