Repository navigation
apps/mac: verify and harden click-to-jump from PDF preview to source - #1100
Merged
Merged
Conversation
d-q222
added a commit
that referenced
this pull request
Sep 25, 2026
Round 2 independent review confirmed the resolveTap extraction is sound (no duplicated hit-testing, coordinate math consistent, V2Geometry.hit wrapper forwards correctly) but found the test only ever passed navigation: nil, so .link was unreachable and untested. Added a sibling test at the same tap location with a matching Navigation.Link, asserting resolveTap returns .link before falling through to span selection. Implementation-Agent: daniel-muse-lead (Claude Sonnet) Commit-Executor: daniel-muse-lead (Claude Sonnet) Reviewed-by: daniel-muse-lead (Claude Sonnet) Co-authored-by: d-q222 <[email protected]>
Investigated the reported gap ("no SyncTeX-equivalent click-to-jump"): the
click handler in PageV2View's onTapGesture already called onSelect(hit) on
a successful V2Geometry.hit, and onSelect was already wired through to
navigateV2 -> Navigation.navigateExactly, which already moves the editor
caret to the hit's source span. That existing path had no test exercising
the actual click coordinate flow end-to-end, so the "gap" was real from a
verification standpoint even though the wiring existed.
Adds a coordinate-precision-preserving V2Geometry.hit(page:viewPoint:scale:)
overload (used by both the hover and tap handlers) instead of pre-dividing
the point into page-local coordinates inline, and a regression test
(testScaledPreviewClickNavigatesToTheClickedSourceSpan) that computes a real
scaled view-space click point for a known glyph run and asserts the click
lands the caret at the exact expected source byte and substring.
xcodebuild test -scheme FlashTeXMac -only-testing:FlashTeXMacTests/PreviewV2ShellTests:
10 passed, 0 failed (new test included, no regressions).
Implementation-Agent: gpt-5.6-luna (Codex, apps/mac:source-pdf-sync)
Commit-Executor: daniel-muse-lead (Claude Sonnet)
Reviewed-by: daniel-muse-lead (Claude Sonnet)
Co-authored-by: d-q222 <[email protected]>
Review found the click-to-jump test called V2Geometry.hit + model.navigateV2 directly, bypassing .onTapGesture's closure and the onSelect wiring, so it couldn't catch a regression in the actual production tap-handling code. Extracts the closure's logic (link check, then text-hit fallback) into resolveTap(location:scale:page:navigation:) -> TapResolution, an Equatable enum (.link/.select/.none). The closure is now a thin dispatcher over this function's result. The test now calls resolveTap directly and asserts the exact .select(hit) value, genuinely exercising the same code the real tap gesture runs, then still calls navigateV2 on the result to verify the caret move. xcodebuild test -scheme FlashTeXMac -only-testing:FlashTeXMacTests/PreviewV2ShellTests: 10 passed, 0 failed. Implementation-Agent: gpt-5.6-luna (Codex, apps/mac:source-pdf-sync) Commit-Executor: daniel-muse-lead (Claude Sonnet) Reviewed-by: daniel-muse-lead (Claude Sonnet) Co-authored-by: d-q222 <[email protected]>
Round 2 independent review confirmed the resolveTap extraction is sound (no duplicated hit-testing, coordinate math consistent, V2Geometry.hit wrapper forwards correctly) but found the test only ever passed navigation: nil, so .link was unreachable and untested. Added a sibling test at the same tap location with a matching Navigation.Link, asserting resolveTap returns .link before falling through to span selection. Implementation-Agent: daniel-muse-lead (Claude Sonnet) Commit-Executor: daniel-muse-lead (Claude Sonnet) Reviewed-by: daniel-muse-lead (Claude Sonnet) Co-authored-by: d-q222 <[email protected]>
Round 3 review: resolveTap divided location by scale before any validation. With navigation present and scale <= 0, that produces NaN/infinity, which DisplayListLinks.ticks then traps converting to Int64. Guard scale > 0 at the top and return .none. Also rebased onto current main — the previous diff appeared to delete unrelated operator-limits/hhline code, which was a stale-branch artifact (both landed on main after this branch was cut), not an actual regression in this PR. Implementation-Agent: daniel-muse-lead (Claude Sonnet) Commit-Executor: daniel-muse-lead (Claude Sonnet) Reviewed-by: daniel-muse-lead (Claude Sonnet) Co-authored-by: d-q222 <[email protected]>
d-q222
force-pushed
the
agent/daniel-muse-lead/source-pdf-click-to-jump
branch
from
September 25, 2026 21:14
a7124f1 to
8d88c1a
Compare
…olveTap test Round 4 review: the invalid-scale test only passed navigation: nil, so both assertions would have passed via V2Geometry.hit alone even without the new guard -- it never exercised the DisplayListLinks.hit path the guard exists to protect. Added navigation-present cases with a real link at the tap point. Also found the same unguarded scale division in onContinuousHover's .active case, a sibling of resolveTap that independently calls DisplayListLinks.hit before validating scale. Same guard, same fallback (clear hover state) as the .ended case already does. Verified: xcodebuild test -only-testing:FlashTeXMacTests/PreviewV2ShellTests -> 12 passed, 0 failed. Implementation-Agent: daniel-muse-lead (Claude Sonnet) Commit-Executor: daniel-muse-lead (Claude Sonnet) Reviewed-by: daniel-muse-lead (Claude Sonnet) Co-authored-by: d-q222 <[email protected]>
Round 5 review: the scale: -1 case used location (10, 10), which misses the ffi link rect regardless of the guard -- V2Geometry.hit independently returns nil there too, so the assertion passed for the wrong reason and never proved the guard rejects negative scale. Fixed by negating the link's own page-point midpoint as the location, so location/scale lands exactly on the link if the guard is removed. Fail-before demonstrated honestly: weakened the guard to `scale != 0` (dropping the sign check) and confirmed this exact test then fails; reverted before commit (touch confirms no stale build reused). Verified: xcodebuild test -only-testing:FlashTeXMacTests/PreviewV2ShellTests -> 12 passed, 0 failed. Implementation-Agent: daniel-muse-lead (Claude Sonnet) Commit-Executor: daniel-muse-lead (Claude Sonnet) Reviewed-by: daniel-muse-lead (Claude Sonnet) Co-authored-by: d-q222 <[email protected]>
Contributor
Author
|
flashtex-2a/opus-9 review @745646a8d: MERGE-READY
(flashtex-2a/opus-9, mac-m5pro-dq222, independent review for d-q222) |
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.
Overleaf-gap as filed: no SyncTeX-equivalent click-to-jump. Investigation found this was already partially wired: `PageV2View`'s tap handler already called `onSelect(hit)` on a successful `V2Geometry.hit`, and `onSelect` was already connected to `navigateV2 → Navigation.navigateExactly`, which already moves the caret to the hit's source span. There was no test exercising the actual click-coordinate flow end-to-end, so the gap was real from a verification standpoint even though the underlying wiring existed.
Changes:
`xcodebuild test -scheme FlashTeXMac -only-testing:FlashTeXMacTests/PreviewV2ShellTests`: 10 passed, 0 failed (re-verified after rebase), including the pre-existing 9 tests with no regressions.
🤖 Generated with Claude Code