fix: resolve macOS screenshot paths with narrow no-break space in load_image - #911
Open
andrewtvuong wants to merge 2 commits into
Open
fix: resolve macOS screenshot paths with narrow no-break space in load_image#911andrewtvuong wants to merge 2 commits into
andrewtvuong wants to merge 2 commits into
Conversation
…path fix: resolve macOS screenshot paths with narrow no-break space in load_image
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.
Problem
macOS names screenshots with U+202F (narrow no-break space) before
AM/PM.That character is visually identical to an ordinary space, and copying such a
path into a prompt typically turns it into U+0020 — a genuinely different
filename on disk.
load_imagedid a barePath(image_path), so those pathsfailed the
exists()check and came back as "Image file not found".for example: Screenshot 2026-08-28 at 8.55.11 PM
Fix
_normalized_filename()— NFKC normalize, then collapse every whitespacecharacter to a plain space.
_resolve_image_path()— the exact path always wins. A fallback is acceptedonly when exactly one file in the requested parent normalizes to the same
name, so it fails closed on ambiguity instead of guessing.
load_imagenow reports the resolved path in the success message andreturn_value, and its metadata carriesimage_path(resolved),requested_image_path, andpath_was_resolved.Tests
New
tests/tools/test_image_tools.py(there were noload_imagetests before):resolves the U+202F screenshot name, prefers an exact path over a normalized
sibling, fails closed on an ambiguous match, and handles a missing parent
directory. Unicode characters are written as
\u202f/\u2009escapes so theysurvive copy-paste and stay visible in review.
Notes
read_fileand the other path-taking tools infile_operations.pyhave thesame class of issue; this change deliberately does not touch them.