Repository navigation
fix(editor): route zoom gestures and app zoom to the PDF viewer - #26652
Conversation
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]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughEditor 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 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)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
7f841e0a-05d0-4624-a1ca-9b0b3fc73772
📒 Files selected for processing (13)
src/renderer/src/components/editor/EditorPanel.tsxsrc/renderer/src/components/editor/PdfViewer.tsxsrc/renderer/src/components/editor/editor-command-owner-context.tssrc/renderer/src/components/editor/image-viewer-zoom.test.tssrc/renderer/src/components/editor/image-viewer-zoom.tssrc/renderer/src/components/editor/pdf-scale-preference.test.tssrc/renderer/src/components/editor/pdf-scale-preference.tssrc/renderer/src/components/editor/pdf-viewer-session.tssrc/renderer/src/components/editor/pdf-viewer-zoom-ownership.test.tsxsrc/renderer/src/components/editor/pdf-zoom-request.test.tssrc/renderer/src/components/editor/pdf-zoom-request.tssrc/renderer/src/hooks/ipc-events/zoom-ipc-bridge.tssrc/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.
08a0b8a to
2761a8b
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
a59b61dd-4310-4562-84f5-14fd5cd45c74
📒 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.
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:
=/-/0changed the code-editor font size. That does nothing visible on a PDF, so the PDF stayed the same.After:
0) means fit to width. Any other editor tab still gets editor font zoom.How it works:
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:
updateScalerounds each step to 0.01, so small pinch steps were lost.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.

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.

Testing
Automated tests:
Gates:
pnpm tcandpnpm run check:code-quality:changedpass. 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-eventpath: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.tsandpdf-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
Notes
metaKeychecks: pinch arrives as Ctrl+wheel on every OS.Known existing issues, not addressed here:
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)