fix(screenshot-clipboard): copy via native pasteboard helper

Merged
SH
10d ago
+43-1

Summary

  • The first screenshot copy after the agent idles took about 1.2s. Warm copies took about 0.18s. macOS finishes writing each capture within about 7ms, so the delay is osascript loading the AppleScript runtime inside clipboard-copy-image.
  • Add pasteboard-png, a small Objective-C helper built with runCommandCC. It writes the PNG to NSPasteboard in about 10ms when warm and 0.29s on its first run.
  • The launchd agent passes it through CLIPBOARD_COPY_IMAGE. copy-latest.sh uses that variable and falls back to ~/.local/scripts/clipboard-copy-image when it is not set. Linux is unchanged.

Validation

  • shellspec spec/screenshot_clipboard_copy_latest_spec.sh: 7 examples, 0 failures (one new test for the override)
  • The helper builds with nix, and darwinConfigurations.galactica evaluates the agent env with the helper path
  • nixfmt --check and shellcheck are clean
  • Not verified end to end with make switch yet

šŸ¤– Generated with Claude Code


Summary by cubic

Fixes slow first screenshot copy after the agent idles on macOS. The old osascript-based copier reloaded the AppleScript runtime (~1.2s); the new native helper writes directly to NSPasteboard in milliseconds.

  • Adds pasteboard-png, a small Objective-C helper built with runCommandCC, that writes PNG data to the general pasteboard.
  • The launchd agent sets CLIPBOARD_COPY_IMAGE to the helper; copy-latest.sh respects that variable and falls back to the old script when unset.
  • Linux behavior is unchanged.