fix(enrich): normalize the click tolerance ring per axis - #55
Open
Sarcastic-Soul wants to merge 1 commit into
Open
fix(enrich): normalize the click tolerance ring per axis#55Sarcastic-Soul wants to merge 1 commit into
Sarcastic-Soul wants to merge 1 commit into
Conversation
_resolve_click compares against per-axis normalized coordinates (xn by width, yn by height) but derived a single tolerance from screen_w, so the vertical ring was shrunk by the display aspect ratio: 40px became 26px on 1728x1117. Vertical near-misses fell through to the coarse zone branch, losing the element's real label and dropping confidence to low. Derive tol_x and tol_y separately. Adds a symmetry test (equal pixel offsets past the right and bottom edges must both resolve as "tolerance") and a companion test that the ring still has an outer edge. Fixes nossa-y#50 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Fixes #50
The bug
_resolve_clicknormalizes a click's coordinates per axis —xnby screen width,ynby screen height — but derived its tolerance ring fromscreen_wonly, then applied that one value to both:tol_nis in normalized-x units. Using it againstynscales it by the display aspect ratio, so on the default 1728x1117 the documented 40px ring is really 25.9px vertically:What that costs
A click 30px past an element's edge — comfortably inside the 40px ring:
('Btn', 'tolerance')('Btn', 'tolerance')('main content', 'zone')('Btn', 'tolerance')The click was never lost — the resolution chain always ends somewhere. But it fell through to the coarse screen-zone branch, so the label degraded from the element's real name to
"main content"and_confidencedropped frommediumtolow. Clicks near the bottom edge of small controls were the most affected, since those are exactly the ones that land in the ring rather than the box.The change
One tolerance per axis:
Plus a short comment recording why they can't be shared, so the next reader doesn't re-collapse them.
Tests
Two new tests in
tests/test_enrich.py, both driven by a tiny helper that builds a one-frame/one-element database so the geometry is explicit rather than inferred from the shared fixture:test_tolerance_ring_is_symmetric_in_pixels— equal pixel offsets past the right and bottom edges must both resolve astolerance. This is the regression guard: it fails onmain(the vertical case returnszone) and passes here.test_tolerance_ring_still_has_an_edge— well outside the ring on either axis still falls through tozone, so the fix widens the ring correctly rather than removing its boundary.Full suite: 109 passed (107 before, +2).
Scope
enrich.pyonly, inside the tolerance branch. Exact containment, the zone fallback, the rescue-window logic, and_confidenceare all untouched — a click that resolved exactly before still resolves exactly, with the same label.