Skip to content

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

Merged
shunkakinoki merged 1 commit into
mainfrom
claude/screenshot-service-restore-ee6999
Oct 28, 2026
Merged

shunkakinoki merged 1 commit into
mainfrom
claude/screenshot-service-restore-ee6999

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

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.

Written for commit cdcc089. Summary will update on new commits.

View guided diff Turn on auto-fix

@indent

indent Bot commented Oct 28, 2026

Copy link
Copy Markdown

Warning

This organization's free trial has ended, so Indent couldn't start this review. Manage billing to resume reviews on this repository.

Review agents

Select any unchecked box below to run or rerun that agent.

Pending (1)
  • Indent Review Agent · This agent has not run.
Full results

Indent Review Agent

  • Summary: This agent has not run.
  • Latest resultNo result — this agent has not run.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e1cb2616-9309-4e75-84f6-36d9bda9398f
Commits

Reviewing files that changed from the base of the PR and between 7ae47e1 and cdcc089.

Files selected for processing: 4
  • home-manager/services/screenshot-clipboard/copy-latest.sh
  • home-manager/services/screenshot-clipboard/default.nix
  • home-manager/services/screenshot-clipboard/pasteboard-png.m
  • spec/screenshot_clipboard_copy_latest_spec.sh
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ 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_IMAGE now 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 a pasteboardPng derivation via runCommandCC compiling pasteboard-png.m with -fobjc-arc -O2 -framework AppKit; sets CLIPBOARD_COPY_IMAGE to the helper's bin path in the launchd agent's EnvironmentVariables.
  • pasteboard-png.m:1-22 — New Objective-C helper that reads a PNG file and writes it directly to NSPasteboard (general pasteboard), replacing the ~1.2s osascript AppleScript runtime load with ~10ms warm / ~0.29s cold.
  • spec/screenshot_clipboard_copy_latest_spec.sh:60-91 — New test verifying CLIPBOARD_COPY_IMAGE override is respected by copy-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.

Pullfrog  | View workflow run | Using free | 𝕏

@shunkakinoki
shunkakinoki merged commit 3d69a16 into main Oct 28, 2026
11 checks passed
@shunkakinoki
shunkakinoki deleted the claude/screenshot-service-restore-ee6999 branch October 28, 2026 02:49
@linear-code

linear-code Bot commented Oct 28, 2026

Copy link
Copy Markdown

SHUN-33083

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.

1 participant