Skip to content

fix: macOS file copy-to-clipboard using NSFilenamesPboardType#11

Merged
Coder-soft merged 1 commit intoRenderdragonorg:mainfrom
musarrat950:fix/macos-file-copy-clipboard
Feb 12, 2026
Merged

fix: macOS file copy-to-clipboard using NSFilenamesPboardType#11
Coder-soft merged 1 commit intoRenderdragonorg:mainfrom
musarrat950:fix/macos-file-copy-clipboard

Conversation

@musarrat950
Copy link
Contributor

@musarrat950 musarrat950 commented Feb 11, 2026

  • Replace writeObjects:{fileURL} (public.file-url) with declareTypes + setPropertyList using NSFilenamesPboardType, which Finder requires for Cmd+V paste
  • Move 'use framework' to top level (AppleScript syntax requirement)
  • Add post-download file existence check for safer error handling

Summary by cubic

Fixes macOS file copy-to-clipboard so Finder recognizes files for Cmd+V paste. Uses NSFilenamesPboardType and adds a safer post-download check.

  • Bug Fixes
    • Use NSPasteboard declareTypes + setPropertyList with NSFilenamesPboardType to make files pasteable in Finder.
    • Move use framework "AppKit" to the top level per AppleScript requirements.
    • Check that the downloaded temp file exists before copying; return a clear error if missing.

Written for commit 12e295c. Summary will update on new commits.

- Replace writeObjects:{fileURL} (public.file-url) with declareTypes +
  setPropertyList using NSFilenamesPboardType, which Finder requires for
  Cmd+V paste
- Move 'use framework' to top level (AppleScript syntax requirement)
- Add post-download file existence check for safer error handling
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 11, 2026

Greptile Overview

Greptile Summary

This PR adjusts the macOS “copy downloaded file to clipboard” flow so Finder can paste the file via Cmd+V. It replaces the previous pasteboard writeObjects(file URL) approach with an AppleScriptObjC pasteboard write using declareTypes + setPropertyList for NSFilenamesPboardType, and moves use framework "AppKit" to the top level of the AppleScript snippet. It also adds a simple post-download fs.existsSync check before attempting to set the clipboard.

Changes are localized to main.js in the main-process clipboard helper (copyFileToClipboard) and the IPC handler that downloads to a temp file and then copies it.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk.
  • The changes are narrowly scoped to the macOS clipboard AppleScript snippet and add a straightforward existence check. No new security footguns were introduced (path is still passed via argv to osascript), and the Windows/Linux paths are untouched.
  • No files require special attention

Important Files Changed

Filename Overview
main.js Updates macOS clipboard copy AppleScript to use NSPasteboard declareTypes + setPropertyList with NSFilenamesPboardType for Finder paste support; moves use framework "AppKit" to top level; adds temp file existence check before copying.

Sequence Diagram

sequenceDiagram
  participant R as Renderer
  participant M as Main (main.js)
  participant DL as downloadToFile
  participant FS as Filesystem
  participant OSAS as osascript/AppKit
  participant PB as NSPasteboard

  R->>M: ipc "copy-to-clipboard"(url, filename, ext)
  M->>M: sanitizeFilename()
  M->>DL: downloadToFile(url, tempPath)
  DL->>FS: createWriteStream(tempPath)
  DL-->>M: resolve(success)
  M->>FS: existsSync(tempPath)
  alt file missing
    M-->>R: {success:false, message:"Downloaded file not found"}
  else file exists
    M->>OSAS: execFile osascript -e <AppleScript> tempPath
    OSAS->>PB: clearContents()
    OSAS->>PB: declareTypes(NSFilenamesPboardType)
    OSAS->>PB: setPropertyList([tempPath], NSFilenamesPboardType)
    alt osascript error
      M->>OSAS: execFile fallback osascript (alias)
      alt fallback error
        M->>M: clipboard.writeText(tempPath)
        M-->>R: success (text)
      else fallback ok
        M-->>R: success (file)
      end
    else ok
      M-->>R: success (file)
    end
  end
Loading

@Coder-soft Coder-soft merged commit 5d2359d into Renderdragonorg:main Feb 12, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants