Repository navigation
fix(editor): route zoom gestures to PDF viewer - #17241
moeinfinityx wants to merge 2 commits into
Conversation
Greptile SummaryThe PR routes wheel gestures, configured shortcuts, and Electron zoom commands to the active PDF viewer while retaining zoom preferences across document reloads.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| src/renderer/src/components/editor/PdfViewer.tsx | Integrates the dedicated PDF zoom-input hook and retains existing find and toolbar behavior. |
| src/renderer/src/components/editor/use-pdf-zoom-input.ts | Owns native wheel handling, configured shortcut routing, command subscription, and listener rebinding. |
| src/renderer/src/components/editor/pdf-scale-preference.ts | Adds bounded wheel-scale calculations, pointer-origin application, and platform modifier detection. |
| src/renderer/src/lib/pdf-zoom-command.ts | Introduces active-viewer ownership checks and a cancelable renderer-local PDF zoom command channel. |
| src/renderer/src/hooks/ipc-events/zoom-ipc-bridge.ts | Gives the active PDF first refusal on Electron zoom commands before existing editor and UI routing. |
| src/renderer/src/components/editor/use-pdf-zoom-input.test.ts | Covers native wheel-listener migration when the PDF container is replaced. |
| src/renderer/src/components/editor/pdf-scale-preference.test.ts | Covers wheel direction, bounds, modifier handling, pointer origin, and unknown initial scale. |
| src/renderer/src/lib/pdf-zoom-command.test.ts | Covers active split-pane selection, hidden viewers, legacy ownership, and command claiming. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Zoom input] --> B{Input source}
B -->|Ctrl or Command wheel| C[PDF container wheel listener]
B -->|Configured shortcut| D[Active PDF target check]
B -->|Electron zoom command| E[PDF command dispatch]
E --> D
C --> F[Compute bounded cursor-centered scale]
D -->|Active PDF| G[Apply zoom command]
D -->|No active PDF| H[Allow existing zoom routing]
F --> I[Update PDF scale preference]
G --> I
Reviews (2): Last reviewed commit: "fix(editor): rebind PDF wheel zoom after..." | Re-trigger Greptile
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughPDF zoom handling now uses a shared command event system and active-target detection. The Merge Risk: 🟡 Moderate · up to The PR routes zoom gestures and shortcuts to PDFs, but current behavior can still zoom an inactive split-pane PDF and may stop responding after an error-view remount. These localized correctness issues should be fixed or explicitly accepted before merging. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the change, motivation, testing, review focus, platform impact, and checklist items. However, the required Linked Issue section contains "N/A" even though the template requires an issue link.
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: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f1ca837b-4a48-4d86-8093-be8e99fd8918
📒 Files selected for processing (7)
src/renderer/src/components/editor/PdfViewer.tsxsrc/renderer/src/components/editor/pdf-scale-preference.test.tssrc/renderer/src/components/editor/pdf-scale-preference.tssrc/renderer/src/components/editor/use-pdf-zoom-input.tssrc/renderer/src/hooks/ipc-events/zoom-ipc-bridge.tssrc/renderer/src/lib/pdf-zoom-command.test.tssrc/renderer/src/lib/pdf-zoom-command.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
|
Remount rebinding is fixed in e9c19c5. Inactive-pane wheel zoom is intentionally pointer-owned, consistent with the image viewer; keyboard and menu zoom remain active-pane-owned. No further changes are planned for these items. |
|
I'd really like to see this land — pinch and Ctrl/⌘+scroll zoom feel like baseline expectations for a PDF viewer, and right now neither works. I checked this PR against current
So the last row also confirms the bug described above: on @Jinwoo-H @nwparker — since you've both worked on the PDF viewer recently, would one of you be able to review this? Thanks! |
|
Hey @moeinfinityx, thanks for digging into this, and sorry it sat so long! You found the real cause: main takes the zoom shortcuts before the PDF's keydown handler runs. Hooking the zoom bridge and reusing the image viewer's pinch math were both the right calls. While testing on current main we hit a few gesture issues:
We also found the editor pane already knows which pane is focused (the same signal Cmd+S uses). So instead of each viewer working it out from the store and the DOM, we put the wheel listener inside the pdf.js session and set absolute scales anchored at the pointer. The PDF in the focused pane takes the zoom command through a small React context. We also made pinch a bit faster while we were there. That version is up in #26652, with your commit credited as co-author. Thanks again for the thorough PR description and tests! 🙏 |
|
Thanks for the thorough review and for getting this merged! The fixes and the focused-pane approach make a lot of sense, and I appreciate the co-author credit. I’ll close this PR in favor of #26652. 🙏 |
ELI5
Zoom gestures and shortcuts now zoom the PDF itself instead of changing Orca’s editor font size.
What Changed
Why
Electron captures standard zoom commands before the PDF viewer receives them. Because an open PDF uses an editor tab, those commands were incorrectly routed to editor-font zoom, which has no visible effect on the document.
The PDF viewer now claims zoom input only when it is the active target and uses pdf.js’s existing scaling API with the pointer position as the zoom origin.
Linked Issue
N/A
Visual Proof
N/A, No visible UI changes are made, only hotkey behavior changed.
Testing
Validated with:
Automated coverage includes Linux/Windows Ctrl modifiers, macOS Command-wheel, trackpad-style Ctrl-wheel events, scale bounds, pointer-origin scaling, hidden viewers, and focused split-pane ownership.
AI Disclosure
OpenAI Codex (GPT-5.6 Sol) was used to implement this change. Code are manually reviewed and tested.
Review
Review focus:
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)