Repository navigation
fix(clipboard): copy macOS file references without Finder automation - #156
Open
gregpriday wants to merge 1 commit into
Open
gregpriday wants to merge 1 commit into
gregpriday wants to merge 1 commit into
Conversation
- Write the file URL to NSPasteboard from osascript's own process (JXA AppKit bridge) instead of `tell app "Finder"`, which macOS refuses with -1743 and no prompt in terminals that lack Apple Events access, such as Daintree's - Pass the path as an argument after `--`, so it needs no escaping and a leading dash is not read as an option - copyFileReference now reports when it could only copy the path as text, with the reason, on every platform - Report that as "Path copied as text, not as a file reference" rather than "File reference copied", and fail it under --strict (exit 1); ignore context warns the same way - Cover the fallback with a cross-platform deliverOutput test and a macOS e2e, and document it
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.
Summary
On macOS, copying a file reference ran
osascriptto tell Finder to set the clipboard. That's an Apple Event, and in a terminal without Apple Events access (Daintree, for one) macOS refuses it with-1743and never prompts. CopyTree then copied the path as plain text and still printedFile reference copied, so pasting into ChatGPT gave you a path instead of an attachment.This writes the file URL to
NSPasteboarddirectly throughosascript's JavaScript AppKit bridge, which needs no permission in any terminal, and stops reporting a text fallback as a success.Changes
src/utils/clipboard.js: macOS writes the pasteboard in-process instead of through Finder.writeObjectswith anNSURLpublishespublic.file-urlandNSFilenamesPboardType, which is what browsers read for a file paste. The path goes in as an argument after--, so there's no escaping and a leading-isn't read as an option.copyFileReferencenow resolves{ asText, cause }on every platform, so callers know when only the path made it to the clipboard.src/commands/copy.js,src/ui/feedback/model.js: a text fallback reportsPath copied as text, not as a file referencewith the reason, and fails under--strict(exit 1, like the other clipboard fallbacks).src/commands/ignore.js:ignore contextwarns the same way.docs/reference/migrating-to-1.0.mdanddocs/technical/behavior-ledger.md.Testing
jestovertests/unit/utils,tests/unit/ui/feedback,tests/unit/commands,tests/unit/api/copy,tests/unit/cliandtests/e2e/file-reference: 32 suites, 692 tests pass. New: a cross-platformdeliverOutputtest, and a macOS e2e that stubs a failingosascriptand checks--strictexits 1.npm run lintpasses.-1743, the new one exits 0, and the pasteboard reads back both the file URL and the filename list.Codex reviewed it before commit. Its fixes (the
--terminator, first-line error causes, Windows and Linux return assertions, the docs) are in.