Skip to content

Add a bounded async Clipboard API host ABI for native runtimes #86

Description

@wieslawsoltes

AppScene coordination epic: SceneTech/AppScene#66

Problem

The native V8 runtime currently exposes ClipboardItem and navigator.clipboard.write(items), but writes are fire-and-forget JSON host requests and clipboard reads are absent. Code OSS's browser clipboard service calls writeText, readText, write, and read; copy can fall through to an unsupported legacy execCommand, and paste/image operations cannot reach the operating-system clipboard.

Proposed contract

  • Add a versioned native clipboard request/completion ABI with request ID, operation, MIME type, immutable bytes, and explicit completed/cancelled/failed status.
  • Implement Promise-based navigator.clipboard.writeText, readText, write, and read, plus ClipboardItem, on top of that ABI.
  • Dispatch bubbling, cancelable browser copy, cut, and paste events for non-prevented native Ctrl/Command-C/X/V shortcuts. Expose bounded clipboardData text/plain and text/html representations and preserve the initiating target across async paste reads.
  • Preserve the existing host-request write path only as a compatibility fallback for older hosts; report its partial capability accurately.
  • Support text/plain, text/html, and bounded image bytes initially. Reject unsupported MIME types explicitly.
  • Require a trusted top-level document and recent user activation for reads. Bind requests to the originating realm/navigation generation and cancel them on navigation or engine teardown.
  • Bound pending requests, item count, per-item bytes, and total bytes. Do not serialize binary payloads through base64 JSON in the new ABI.

Acceptance criteria

  • Web IDL/API shape, brand checks, Promise behavior, MIME handling, and DOMException names match the supported subset.
  • Native Ctrl/Command-C/X/V dispatches browser-compatible clipboard events; exact text/HTML host bytes, paste target lifetime, event cancellation, and input-queue ordering are covered.
  • Native contracts cover text/typed success, cancellation, host failure, unsupported MIME, invalid receiver/input, queue saturation, stale/double completion, navigation, and teardown.
  • A 10,000-operation small-text round-trip gate and maximum-payload gate publish elapsed time and retained-memory/request-pool high-water metrics; no timing sleeps determine correctness.
  • Existing Avalonia/Uno hosts either implement the ABI or expose an explicit unsupported result without regression.
  • Hosted and packaged Windows, macOS, and Linux jobs plus cross-RID/consumer checks pass.
  • The Code OSS package passes real native copy/paste text and image qualification through AppScene with no VS Code source change.

This belongs in WebScene because it is a standard browser API and shared native host ABI, independent of Electron and of any one application.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions