Skip to content

Add image clipboard sync support#2

Merged
offbyonebit merged 2 commits intomainfrom
claude/add-image-copy-paste-88XBb
Apr 19, 2026
Merged

Add image clipboard sync support#2
offbyonebit merged 2 commits intomainfrom
claude/add-image-copy-paste-88XBb

Conversation

@offbyonebit
Copy link
Copy Markdown
Owner

Summary

  • Adds image (PNG) sync via a new clipboard.png sidecar file alongside the existing clipboard.txt
  • Generalizes _encrypt/_decrypt to operate on raw bytes so both text and image payloads are encrypted the same way
  • Platform clipboard access: ctypes+CF_DIB on Windows, AppKit NSPasteboard on macOS, xclip/wl-paste subprocesses on Linux
  • All existing text sync behaviour and tests are unchanged; 6 new image-specific tests added (sync A→B, B→A, no oscillation, text regression, encrypted sync, mismatched passphrase)

Test plan

  • Run pytest tests/ — all 28 tests should pass
  • Copy an image on one device, verify it appears on the other
  • Copy text after an image, verify text replaces it (no stale image)
  • Enable encryption passphrase on both devices, verify image still syncs
  • Set mismatched passphrases, verify image is not applied on the receiving side

https://claude.ai/code/session_01HaCGbmbaF3rBff9fxyP7TS

claude and others added 2 commits April 19, 2026 18:22
Syncs images (PNG) via a new clipboard.png sidecar file alongside the
existing clipboard.txt. The OUT loop tries image first, falls back to
text. The IN watcher dispatches to separate text/image handlers based on
which file changed. Encryption works for both types: _encrypt/_decrypt
now operate on bytes directly, with callers handling text encoding.

Platform clipboard access:
- Windows: ctypes + CF_DIB (no extra deps)
- macOS: AppKit NSPasteboard via pyobjc
- Linux: xclip or wl-paste/wl-copy subprocesses

https://claude.ai/code/session_01HaCGbmbaF3rBff9fxyP7TS
- Stub _read_clipboard_image / _write_clipboard_image in the text-only
  test fixtures. The new image-priority logic in _out_tick calls
  _read_clipboard_image() before the text path, and the previous fakes
  only mocked text access. On a Mac with a real PNG sitting on the
  system clipboard, every text test in test_mac_windows_sync.py and
  test_cross_os_sync.py would pick that image up instead of the fake
  text payload and time out waiting for propagation.
- Declare pyobjc-core and pyobjc-framework-Cocoa as explicit macOS
  deps in requirements.txt. They previously arrived transitively via
  pystray's rumps backend, but the new NSPasteboard image writer
  imports AppKit and Foundation directly, so the dependency is now
  first-party.
- Add --hidden-import AppKit and --hidden-import Foundation to the
  PyInstaller build on macOS. Both modules are imported lazily inside
  _write_image_to_system_clipboard, which PyInstaller's static
  analysis sometimes misses; without the hints, the frozen bundle
  would silently fail at image paste time.
- Minor ruff-format reflow picked up on paths the branch touched.

Verified end-to-end on Mac: putting a PNG on the system clipboard
triggers 'OUT: N bytes image written' from both the source run and
the PyInstaller .app, and clipboard.png appears in the sync folder
encrypted (CSENC-prefixed) when a passphrase is set.
@offbyonebit offbyonebit merged commit e9e7161 into main Apr 19, 2026
12 of 15 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