From bc72f6c84c029ef8fb59c6fb12a0ebf1baf6f3da Mon Sep 17 00:00:00 2001 From: curtisblanchette Date: Thu, 25 Jun 2026 13:59:57 -0700 Subject: [PATCH] fix(reveal_in_finder): coerce POSIX file to alias Finder's `reveal` expects an alias/file reference. Passing a bare `POSIX file` specifier makes Finder raise -1728 ("Can't get POSIX file ...") for every path, so reveal_in_finder never worked. Coerce to `as alias` (the path is already existence-checked in Python). Add a test assertion covering the coercion. Fixes #7 --- tests/test_files.py | 5 +++++ tools/files.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_files.py b/tests/test_files.py index 309d261..538542a 100644 --- a/tests/test_files.py +++ b/tests/test_files.py @@ -202,6 +202,11 @@ def fake_run(args, **kwargs): assert result["action"] == "reveal_in_finder" assert seen["args"][0] == "osascript" + # Finder's `reveal` needs an alias/file reference; a bare `POSIX file` + # specifier raises -1728 ("Can't get POSIX file ..."). Ensure we coerce. + script = " ".join(seen["args"]) + assert "as alias" in script + assert "reveal POSIX file (item 1 of argv)" not in script def test_get_finder_selection_parses_alias_output(monkeypatch): diff --git a/tools/files.py b/tools/files.py index a71069a..ff82116 100644 --- a/tools/files.py +++ b/tools/files.py @@ -470,7 +470,7 @@ def reveal_in_finder(path: str) -> str: script = ( 'on run argv\n' ' tell application "Finder"\n' - ' reveal POSIX file (item 1 of argv)\n' + ' reveal (POSIX file (item 1 of argv) as alias)\n' " activate\n" " end tell\n" "end run\n"