fix(screenshot-clipboard): copy via native pasteboard helper
Merged
SH
10d ago+43+43+01234567890123456789-1-1-0123456789
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
osascriptloading the AppleScript runtime insideclipboard-copy-image. - Add
pasteboard-png, a small Objective-C helper built withrunCommandCC. It writes the PNG toNSPasteboardin about 10ms when warm and 0.29s on its first run. - The launchd agent passes it through
CLIPBOARD_COPY_IMAGE.copy-latest.shuses that variable and falls back to~/.local/scripts/clipboard-copy-imagewhen 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.galacticaevaluates the agent env with the helper path nixfmt --checkandshellcheckare clean- Not verified end to end with
make switchyet
š¤ 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 withrunCommandCC, that writes PNG data to the general pasteboard. - The launchd agent sets
CLIPBOARD_COPY_IMAGEto the helper;copy-latest.shrespects that variable and falls back to the old script when unset. - Linux behavior is unchanged.