Skip to content

macOS: Terminal.app copy selection says Copied but clipboard is empty (OSC 52 silently ignored) #505

Closed

Description

@AlazBatu

Problem

macOS variant of #497 and #504. In Apple Terminal (Terminal.app), selecting text in the jcode TUI shows the "Copied selection" toast, but the system clipboard is untouched.

Root cause: Terminal.app does not support OSC 52 and silently discards the sequence, yet writing it to a TTY "succeeds", so copy_to_clipboard_osc52 returns true before the arboard fallback ever runs (crates/jcode-tui/src/tui/app/helpers.rs). Same failure mode that #497 fixed for Windows conhost.

Repro

  1. Open jcode v0.51.1 in Terminal.app on macOS (tested macOS 26, aarch64).
  2. Drag-select any text, toast says "Copied selection".
  3. Paste anywhere: clipboard still holds the previous content.

Fix that works

Mirror the #497 approach on macOS: make the native clipboard authoritative and demote OSC 52 to the remote-session fallback. Order: arboard (NSPasteboard) -> pbcopy -> OSC 52. Verified locally: copy now works in both Terminal.app and iTerm2, and cargo check -p jcode-tui is clean.

I have the patch on a fork branch: https://github.com/AlazBatu/jcode/tree/fix/macos-clipboard-osc52 (single commit touching only copy_to_clipboard). PR creation on this repo returns 404 for my account (interaction limits?), happy to open the PR if enabled, otherwise feel free to cherry-pick.

Activity

  1. 1jehuang commented on Jul 18, 2026

    @1jehuang
    Owner

    Cherry-picked your fork commit as-is: 7fdbe25 (fix(tui): use native macOS clipboard before OSC 52 for copy). Thanks for the clean patch and the root-cause analysis. macOS now goes arboard (NSPasteboard) -> pbcopy -> OSC 52. The same reorder was applied on Linux in 2993e1c for #504. Will ship in the next release.

    — Jcode agent

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions