Skip to content

feat(editor): add explicit macOS clipboard commands - #182

Merged
owainlewis merged 1 commit into
mainfrom
codex/issue-167-macos-clipboard
Sep 8, 2026
Merged

feat(editor): add explicit macOS clipboard commands#182
owainlewis merged 1 commit into
mainfrom
codex/issue-167-macos-clipboard

Conversation

@owainlewis

Copy link
Copy Markdown
Owner

M-w copies the active region to the macOS clipboard without deleting text or changing the selection or kill ring. C-c C-v and clipboard-paste insert literal clipboard text as one edit; the shortcut also works inside editable prompts without submitting them. copy-region has the clipboard-copy alias.

The adapter invokes fixed pbcopy/pbpaste paths only on explicit commands. Nonblocking pipe I/O and child exit polling share a two-second deadline, transfers are capped at 16 MiB, invalid UTF-8 is rejected, and failures kill and reap children without editing the buffer. Copy checks the Rope range size before materializing it. Prompt errors preserve the entered text and clear on the next key, including an empty successful retry.

Validation: formatting, strict all-target Clippy, release build, and 388 unit tests pass. Ten focused clipboard tests use controlled executable adapters and cover exact UTF-8 transfer, copy/paste keys and aliases, prompt behavior, failures, size limits, timeouts, and process cleanup. Eleven of thirteen terminal integration tests pass locally; the two existing redirected-input tests remain sandbox-restricted and require macOS CI. Fresh review approved after the empty-retry regression was reproduced and fixed.

Manual limit: the native pbcopy command exits 1 in this environment before Cortex is involved, so a successful system clipboard round trip could not be verified here. The release PTY check verified visible paste errors in the editor and command prompt, preserved text and entered commands, save, quit, and shell restoration. Successful copy/paste behavior is verified with controlled adapters.

Closes #167.

@greptile-apps

greptile-apps Bot commented Sep 8, 2026

Copy link
Copy Markdown

Greptile Summary

Adds explicit macOS clipboard integration to the editor.

  • Binds M-w to copy the active region and C-c C-v to paste clipboard text.
  • Supports clipboard paste inside editable prompts without submitting them.
  • Introduces bounded, nonblocking pbcopy/pbpaste process handling with size and UTF-8 validation.
  • Adds command registration, documentation, and focused tests for success, failure, limits, timeouts, prompt behavior, and cleanup.

Confidence Score: 5/5

The PR appears safe to merge; no actionable correctness, security, or repository-rule violations were identified.

Clipboard operations are explicit, bounded, validated before application, and tested across editor, prompt, failure, timeout, and cleanup paths without an established behavioral regression.

Important Files Changed

Filename Overview
src/clipboard.rs Implements bounded nonblocking clipboard subprocess I/O, validation, timeout cleanup, and focused adapter tests.
src/app.rs Integrates copy and paste commands into editor and prompt flows while preserving expected edit, selection, and error behavior.
src/keymap.rs Adds the M-w copy binding and C-c C-v clipboard-paste prefix.
src/buffer.rs Exposes Rope range byte length so copy limits can be checked before materializing selected text.
src/command_registry.rs Registers the clipboard commands and the clipboard-copy alias.

Reviews (1): Last reviewed commit: "feat(editor): add explicit macOS clipboa..." | Re-trigger Greptile

@owainlewis
owainlewis merged commit b147457 into main Sep 8, 2026
2 checks passed
@owainlewis
owainlewis deleted the codex/issue-167-macos-clipboard branch September 8, 2026 19:23
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.

Add explicit macOS clipboard copy and paste commands

1 participant