Skip to content

coding-agent startup can abort on macOS when pasteboard access is denied #4492

@thegalexc

Description

@thegalexc

What happened?

What happened?
On macOS, @mariozechner/clipboard aborts if pasteboard access is denied by a sandbox or isolation profile. In current pi, coding-agent startup imports clipboard helpers eagerly, so interactive mode can die before any user clipboard action.

Observed failure:

unexpected NULL returned from +[NSPasteboard generalPasteboard]
thread caused non-unwinding panic. aborting.

Steps to reproduce

  1. Run Node on macOS under a sandbox-exec profile that denies pasteboard lookup.
  2. In that sandboxed process, load @mariozechner/clipboard.
  3. Call a clipboard method that touches NSPasteboard, for example hasImage().

Minimal shape:

const clipboard = require("@mariozechner/clipboard");
clipboard.hasImage();

On my machine that aborts with exit 134 and:

unexpected NULL returned from +[NSPasteboard generalPasteboard]
thread caused non-unwinding panic. aborting.

I also have verified local fixtures for both the failing raw path and the succeeding lazy-load path, and a clean fix branch ready if maintainers want me to open the PR:
https://github.com/thegalexc/pi-mono/tree/fix/clipboard-sandbox-pasteboard-crash

Expected behavior

Interactive startup should succeed. Clipboard access should only reach the native addon on actual clipboard use, and denied pasteboard access should not abort startup.

Version
@earendil-works/pi-coding-agent 0.74.0, Node 24.12.0, macOS

Version

0.74.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingclosed-because-refactorClosed while the project refactor is in progressinprogressIssue is being worked on

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions