Repository navigation
fix: ocr_region not read everything above a window far from the menu bar - #59
Open
bluzername wants to merge 1 commit into
Open
bluzername wants to merge 1 commit into
bluzername wants to merge 1 commit into
Conversation
ocr_region joined the window rect with a box that always start at y=0, so a window low on the screen pull in all the text above it in its columns too. On a 5K display with Finder at y=609 over a full terminal, this make one OCR step take 46s and mostly return the terminal's text. Now ocr_region just read the window rect with its margin, clamped to the display. The menu bar text still reach the model through the accessibility tree as AXMenuBarItem controls, so nothing is lost. Co-Authored-By: Claude Sonnet 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 #35.
ocr_regionjoined the window rect with a box that start at y=0, so a windowlow on the screen pull in all the text above it in its own columns too. On a
5K display with a Finder window at y=609 pt over a full-screen terminal, this
make one OCR step take 46s and read mostly the terminal text, not Finder.
The fix is simple: read the window rect with its margin, clamped to the
display, nothing else. The menu bar text still reach the model through the
accessibility tree as AXMenuBarItem controls (as the issue says), so this
lose nothing.
Root cause:
min(window[1], 0.0)always resolve to 0.0 since a window top isalmost never negative, so the top of the region was always the top of the
display, not the menu bar strip the comment describe.
Test approach (TDD): added
test_region_does_not_reach_above_a_window_low_on_the_displayin
tests/test_ocr_cache.py, confirmed RED against current main (region[1] was 0.0instead of the window top), then fixed
ocr_regionand confirmed GREEN. Alsoupdated the two older tests that asserted the old, buggy join behavior
(
test_region_reaches_the_menu_bar_even_for_a_window_low_on_the_displayandtest_region_is_at_least_the_menu_bar_strip_for_a_window_above_it) to matchthe corrected behavior.
Verification:
uv run ruff check . && uv run ruff format .clean,uv run pytest -q730 passed, 2 skipped, 1 xfailed (same totals as main, just two tests renamed
to match the fix).
🤖 Generated with Claude Code