Repository navigation
fix(screenshot-clipboard): copy via native pasteboard helper - #3232
Conversation
|
Warning This organization's free trial has ended, so Indent couldn't start this review. Manage billing to resume reviews on this repository.
Select any unchecked box below to run or rerun that agent. Full resultsIndent Review Agent
|
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 47 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — Reviewed PR #3232 "fix(screenshot-clipboard): copy via native pasteboard helper" against main at cdcc0894, one commit, 4 files changed.
copy-latest.sh:6—CLIPBOARD_COPY_IMAGEnow falls back to${CLIPBOARD_COPY_IMAGE:-...}so the launchd-set env var overrides the legacy script path while preserving backward compatibility when unset.default.nix:9-12— Adds apasteboardPngderivation viarunCommandCCcompilingpasteboard-png.mwith-fobjc-arc -O2 -framework AppKit; setsCLIPBOARD_COPY_IMAGEto the helper's bin path in the launchd agent'sEnvironmentVariables.pasteboard-png.m:1-22— New Objective-C helper that reads a PNG file and writes it directly toNSPasteboard(general pasteboard), replacing the ~1.2sosascriptAppleScript runtime load with ~10ms warm / ~0.29s cold.spec/screenshot_clipboard_copy_latest_spec.sh:60-91— New test verifyingCLIPBOARD_COPY_IMAGEoverride is respected bycopy-latest.sh.
No behavioral issues found. The macOS fast path is gated behind the launchd env var; Linux (watch.sh) is unchanged and continues using the legacy script with wl-copy/xclip. Objective-C error handling (argc, nil data, pasteboard rejection) and shell set -euo pipefail are both correct.
free | 𝕏

Summary
osascriptloading the AppleScript runtime insideclipboard-copy-image.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.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)darwinConfigurations.galacticaevaluates the agent env with the helper pathnixfmt --checkandshellcheckare cleanmake 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 toNSPasteboardin milliseconds.pasteboard-png, a small Objective-C helper built withrunCommandCC, that writes PNG data to the general pasteboard.CLIPBOARD_COPY_IMAGEto the helper;copy-latest.shrespects that variable and falls back to the old script when unset.Written for commit cdcc089. Summary will update on new commits.